Can I use a tensorflowjs model in Python? - python

I am not really a tensorflow expert. I have been using it with provided models and code, played around a bit and am trying to get better with it.
I got a hold of a model that I'd like to play around with in the form of a tensorflowjs model (?). It is in the form a model.json with some "shard1ofX" files. I also got some JS code to accompany it which I kind of understand, but I am not really a JS developer and also would like to use the model and code not on the net but in a standalone application.
The model gets loaded like that in the JS implementation:
tf.loadGraphModel(path_to_model_json)
Is it somehow possible to read said model in the Python tensorflow implementation to use it? Googling around I found a ton of information about converting a model TO tensorflowjs format, but not the other way around.
Help would be greatly appreciated!

The tfjs-converter project supports going from Javascript to Python. I haven't tested this but it looks like these flags should get the job done.
tfjs_converter --input_format tfjs_layers_model \
--output_format keras_saved_model \
/tmp/tensorflowjs_model \
/tmp/keras_model
https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/README.md#format-conversion-support-tables

Related

Is there a way to use pre-trained R ML model in python web app?

More of a theoretical question:
Use case: Create an API that takes json input, triggers ML algorithm inside of it and returns result to the user.
I know that in case of python ML model, I could just pack whole thing into pickle and use it easily inside of my web app. The problem is that all our algorithms are currently written in R and I would rather avoid re-writing them to python. I have checked a few libraries that allow to run R code within python but I cannot find a way to pack it "in a pickle way" and then just utilize.
It may be stupid but I have not had much to do with R so far.
Thank you in advance for any suggestions!
Not sure what calling R code from Python has to do with ML models.
If you have a trained model, you can try converting it into ONNX format (emerging standard), and try using the result from Python.

Data Privacy with Tensorboard

I've recently begun using Tensorflow via Keras and Python 3.5 to analyze company data, and I am by no means an expert and only recently built my first "real-world" model.
With my experimental data I used Tensorboard to visualiza how my neural network was working, and I would like to do the same with my real data. However, my company is extremely strict about company data leaving our servers - so my question is this:
Does tensorboard take the raw data used in the model and upload it off-site to generate its reports/visuals or does it only use processed data/results from my model?
I've done several google searches already, and I haven't found anything conclusive one way or the other.
If I'm not asking this question correctly, please let me know - I'm new to all of this.
Thank you.
No, Tensorboard does not upload the data to "the cloud" or anywhere outside the computer where it is running, it just interprets data produced by the model.

Monitor RSS/Atom feed

I want to figure out constantly monitor an RSS feed (Python 2.7, using feedparser) or any other library.
Means if blog add a new article we get alert.
and if article in db != new article then add this article in our db.
I don't know how to do that.
Always smart to start with the documentation of the module you intend to use. In the case of Feedparser that would be in the link below:
https://pythonhosted.org/feedparser/index.html
Follow the instructions, tinker the code, make a few mistakes, learn from them, get familiar with the module. It's the only way you can learn.

I cannot get the google-attention-ocr

I am new in Tensorflow and I am trying to build model which will be able to perform OCR on my images. I am reading the paper of google about the attention ocr.the project in github seems non-existent.I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.
https://github.com/tensorflow/models/tree/master/attention_ocr
The project moved into the research subfolder of tensorflow/models.
The new correct link is:
https://github.com/tensorflow/models/tree/master/research/attention_ocr

Microsoft Speech Recognition Custom Training

I have been wanting to create an application using the Microsoft Speech Recognition.
My application's users are expected to often say abbreviated things, such as 'LHC' for 'Large Hadron Collider' or 'CERN'. Given that exact order, my application will return
You said: At age C.
You said: Cern
While it did work for 'CERN', it failed very badly for 'LHC'.
However, if I could make my own custom training files, I could easily place the term 'LHC' somewhere in there. Then, I could make the user access the Speech Control Panel and run my training file.
All the links I have found for this have been frustratingly useless, as they just say things like 'This is ----, you should try going to the ---- forum instead'.
If it does help, here is a list of the links:
http://compgroups.net/comp.speech.users/add-my-own-training/153194
https://groups.google.com/forum/#!topic/microsoft.public.speech.server/v58SH1ov22s
http://social.msdn.microsoft.com/Forums/en/servercorefordevelopers/thread/f7a35f3f-b352-464a-b264-e16eb4afd049
Is my problem even possible? Or are the training files themselves in a special format? If so, can that format be reproduced?
A solution that can also work on Windows XP would be ideal.
Thanks in advance!
P.S. If there are any libraries or modules out there already for this, could anyone point me to some? A Python or C/C++ solution would be splendid. Also, since I'd rather not post another question regarding this, is it possible to utilize the train utilities from command prompt (or without the GUI visible, but still having total command of all controls)?
Okay, pulling this from a thing I wrote three or four years ago now, but I believe you want to do something like this.
The grammar library is a trained system which can recognize words. You can create your own grammar library cued to specific words.
C#, sorry
using System.Speech
using System.Speech.Recognition
using System.Speech.AudioFormat
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
string[] words = {"L H C", "CERN"};
Choices choices = new Choices(words);
GrammarBuilder gb = new GrammarBuilder(choices);
Grammar grammar = new Grammar(gb);
sre.LoadGrammar(grammar);
That is as far as I can get you. From docs it looks like you can define the pronunciations somehow. So perhaps that way you could have LHC map directly to a single word. Here are the docs on the grammar class - http://msdn.microsoft.com/en-us/library/system.speech.recognition.grammar.aspx
Small update - see example in their docs here http://msdn.microsoft.com/en-us/library/ms554228.aspx

Categories

Resources