|
| 1 | + |
| 2 | +# ofxMSATensorFlow |
| 3 | +[OpenFrameworks](http://openframeworks.cc) addon for Google's graph based numerical computation, machine intelligence, deep learning library [TensorFlow](https://www.tensorflow.org). |
| 4 | + |
| 5 | +This update includes the newly released **TensorFlow r1.0**, and might have broken backwards compatibility. Sorry about that (tbh tensorflow has been breaking backwards compatibility with every update!). Hopefully from now on the API should be a bit more stable. |
| 6 | + |
| 7 | +Tested on **openFrameworks 0.9.8**. |
| 8 | + |
| 9 | +I provide precompiled libraries for **Linux** and **OSX**. For linux there are both **GPU** and **CPU**-only libs, OSX is **CPU**-only (I don't have a Mac with NVidia). I haven't touched Windows yet as building from sources is 'experimental' (and doing Linux and OSX was painful enough). |
| 10 | + |
| 11 | +You can find instructions and more information in the **[wiki](https://github.com/memo/ofxMSATensorFlow/wiki)**, particularly for **[Getting Started](https://github.com/memo/ofxMSATensorFlow/wiki/Getting-started)**. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +TensorFlow is written in C/C++ with python bindings, and most of the documentation and examples are for python. This addon wraps the C/C++ backend (and a little bit of the new C++ FrontEnd) with a number of examples. The basic idea is: |
| 16 | + |
| 17 | +1. Build graphs and/or train models in python, Java, C++ or any other language/platform with tensorflow bindings |
| 18 | +2. Save the graphs or trained models to binary files |
| 19 | +3. Load the graphs or trained models in openframeworks, feed them data, manipulate, get results, play, and connect them to the ofUniverse |
| 20 | + |
| 21 | +You could potentially do steps 1-2 in openframeworks as well, but the python API is a bit more user-friendly for building graphs and training. |
| 22 | + |
| 23 | +--- |
| 24 | +## Examples |
| 25 | +The examples are quite basic. They shouldn't be considered *tensorflow* examples or tutorials, but they mainly just demonstrate loading and manipulating of tensorflow models in openFrameworks. I really need to include more, but do checkout Parag's [tutorials](https://github.com/pkmital/tensorflow_tutorials) and [Kadenze course](https://www.kadenze.com/courses/creative-applications-of-deep-learning-with-tensorflow-iv/info) (both for tensorflow python). Building and training those models in python, and then playing with them in openframeworks should be relatively straight forward. |
| 26 | + |
| 27 | + |
| 28 | +### example-basic |
| 29 | +The hello world (no not MNIST, that comes next). Build a very simple graph in python that multiplies two numbers. Load the graph in openframeworks and hey presto. 100s of lines of code, just to build a simple multiplication function. |
| 30 | + |
| 31 | +### example-mnist |
| 32 | +MNIST clasffication with two different models - shallow and deep. Both models are built and trained in python (in bin/py folder). Loaded, manipulated and interacted with in openframeworks. Toggle between the two models with the 'm' key. |
| 33 | + |
| 34 | + |
| 35 | +**Single layer softmax regression:** Very simple multinomial logistic regression. Quick'n'easy but not very good. Trains in seconds. Accuracy on test set ~90%. |
| 36 | +Implementation of https://www.tensorflow.org/versions/0.6.0/tutorials/mnist/beginners/index.html |
| 37 | + |
| 38 | +**Deep(ish) Convolutional Neural Network:** Basic convolutional neural network. Very similar to LeNet. Conv layers, maxpools, RELU's etc. Slower and heavier than above, but much better. Trains in a few minutes (on CPU). Accuracy 99.2% |
| 39 | +Implementation of https://www.tensorflow.org/versions/0.6.0/tutorials/mnist/pros/index.html#build-a-multilayer-convolutional-network |
| 40 | + |
| 41 | + |
| 42 | +### example-inception3 |
| 43 | +openframeworks implementation for image recognition using Google's 'Inception-v3' architecture network, pre-trained on ImageNet. Background info at https://www.tensorflow.org/versions/0.6.0/tutorials/image_recognition/index.html |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +### example-build-graph |
| 48 | +Builds a simple flow graph in directly in openframeworks/C++ without using any python. (really not very exciting to look at. more of a syntax demo than anything). Based on https://www.tensorflow.org/api_guides/cc/guide |
| 49 | + |
| 50 | + |
| 51 | +### example-tests |
| 52 | +Just some unit tests. Very boring for most humans. Possibly exciting for computers (or humans that get excited at the thought of computers going wrong). |
| 53 | + |
0 commit comments