• Stars
    star
    455
  • Rank 95,546 (Top 2 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C++ openframeworks addon and examples integrating Google's TensorFlow numerical computation and machine learning library

This addon is no longer maintained. For up-to-date openFrameworks x Tensorflow integration please see ZKM Center for Art & Media's addon https://github.com/zkmkarlsruhe/ofxTensorFlow2


ofxMSATensorFlow

OpenFrameworks addon for Google's graph based machine intelligence / deep learning library TensorFlow.

This update includes the newly released TensorFlow r1.1 and has been tested with openFrameworks 0.9.8.

I provide precompiled libraries for Linux and OSX (though OSX might lag a little bit behind as I don't have regular access). For linux there are both GPU and CPU-only libs, while OSX is CPU-only. I haven't touched Windows yet as building from sources is 'experimental' (and doing Linux and OSX was painful enough).

You can find instructions and more information in the wiki, particularly for Getting Started.


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:

  1. Build and train graphs (i.e. 'networks', 'models') mostly in python (possibly Java, C++ or any other language/platform with tensorflow bindings)
  2. Save the trained models to binary files
  3. Load the trained models in openframeworks, feed data, manipulate, get results, play, and connect to the ofUniverse

You could potentially do steps 1-2 in openframeworks as well, but the python API is more user-friendly for building graphs and training.


Examples

The examples are quite minimal and shouldn't be considered comprehensive tensorflow tutorials. They demonstrate loading and manipulating different types of tensorflow models in openFrameworks. E.g.

  • for the most basic example of loading a model, feeding it data and fetching the results (using just a low level C API), see example-basic
  • for a very simple barebones Image-to-Image example (loading a model, feeding it an image, and fetching an image using a higher level C++ API) see example-pix2pix-simple - This is probably the best minimal template for other examples
  • for more complex Image-to-Image examples (with Conditional Generative Adversarial Networks) see example-pix2pix or example-pix2pix-webcam
  • for style transfer see example-style-transfer
  • for image classification see example-mnist or example-inception3
  • for sequence generation of discrete data such as text (with stateful LSTM/RNN, where LSTM state is retrieved and passed back in at every time-step) see example-char-rnn
  • for sequence generation of continuous data such as handwriting (with Recurrent Mixture Density Networks) see example-handwriting-rnn
  • for image generation (with Conditional Generative Adversarial Networks) see example-pix2pix or example-pix2pix-webcam
  • for constructing graphs in C++ see example-build-graph

Potentially you could load any pretrained model in openframeworks and manipulate. E.g. checkout Parag's tutorials and Kadenze course. There's info in the wiki on how to do export and distribute models.


(Note: the animations below are animated-gifs, hence the low color count, dithering, and low framerate)

example-pix2pix-webcam

example-pix2pix-webcam_250x_short_800px_10fps

Same as pix2pix-example with the addition of live webcam input. See description of pix2pix-example for more info on pix2pix and the models I provide. I'm using a very simple and ghetto method of transforming the webcam input into the desired colour palette before feeding into the model. See the code for more info on this.


example-pix2pix

example-pix2pix_400x2x

pix2pix (Image-to-Image Translation with Conditional Adversarial Nets). An accessible explanation can be found here and here. The network basically learns to map from one image to another. E.g. in the example you draw in the left viewport, and it generates the image in the right viewport. I'm supplying three pretrained models from the original paper: cityscapes, building facades, and maps. And a model I trained on 150 art collections from around the world. Models are trained and saved in python with this code (which is based on this tensorflow implementation, which is based on the original torch implementation), and loaded in openframeworks for prediction.


example-pix2pix-simple

This is the simplest pix2pix example with no interaction. The purpose of this example is the show the most barebones way of using the msa::tf::SimpleModel API


example-style-transfer

Fast Style Transfer from Logan Engstrom. This realtime webcam openFrameworks example is by Ole Kristensen who also modified the python evaluate.py script to export a graph in protobuf format for use with the c++ TF implementation. Ole has a fork of Enstroms repo, that will do the ugly varhack tricks to restore the graph variables for you. Note that when you want to use your own models you have to evaluate (style) one image of the same resolution as the one you want to feed in your openFrameworks app. You do this for evaluate.py to export an of.pb file for you to load from your ofApp.

  @misc{engstrom2016faststyletransfer,
    author = {Logan Engstrom},
    title = {Fast Style Transfer},
    year = {2016},
    howpublished = {\url{https://github.com/lengstrom/fast-style-transfer/}},
    note = {commit xxxxxxx}
  }

example-handwriting-rnn

Generative handwriting with Long Short-Term Memory (LSTM) Recurrent Mixture Density Network (RMDN), ala Graves2013. Brilliant tutorial on inner workings here, which also provides the base for the training code (also see javscript port and tutorial here). Models are trained and saved in python with this code, and loaded in openframeworks for prediction. Given a sequence of points, the model predicts the position for the next point and pen-up probability. I'm supplying a model pretrained on the IAM online handwriting dataset. Note that this demo does not do handwriting synthesis, i.e. text to handwriting ala Graves' original demo. It just does asemic handwriting, producing squiggles that are statistically similar to the training data, e.g. same kinds of slants, curvatures, sharpnesses etc., but not nessecarily legible. There is an implementation (and great tutorial) of synthesis using attention here, which I am also currently converting to work in openframeworks. This attention-based synthesis implementation is also based on Graves2013, which I highly recommend to anyone really interested in understanding generative RNNs.


example-char-rnn

Generative character based Long Short-Term Memory (LSTM) Recurrent Neural Network (RNN) demo, ala Karpathy's char-rnn and Graves2013. Models are trained and saved in python with this code and loaded in openframeworks for prediction. I'm supplying a bunch of models (bible, cooking, erotic, linux, love songs, shakespeare, trump), and while the text is being generated character by character (at 60fps!) you can switch models in realtime mid-sentence or mid-word. (Drop more trained models into the folder and they'll be loaded too). Typing on the keyboard also primes the system, so it'll try and complete based on what you type. This is a simplified version of what I explain here, where models can be mixed as well. (Note, all models are trained really quickly with no hyperparameter search or cross validation, using default architecture of 2 layer LSTM of size 128 with no dropout or any other regularisation. So they're not great. A bit of hyperparameter tuning would give much better results - but note that would be done in python. The openframeworks code won't change at all, it'll just load the better model).


example-mnist

MNIST (digit) clasffication with two different models - shallow and deep. Both models are built and trained in python (py src in bin/py folder). Openframeworks loads the trained models, allows you to draw with your mouse, and tries to classify your drawing. Toggle between the two models with the 'm' key.

Single layer softmax regression: Very simple multinomial logistic regression. Quick'n'easy but not very good. Trains in seconds. Accuracy on test set ~90%. Implementation of https://www.tensorflow.org/versions/0.6.0/tutorials/mnist/beginners/index.html

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% Implementation of https://www.tensorflow.org/versions/0.6.0/tutorials/mnist/pros/index.html#build-a-multilayer-convolutional-network


example-inception3

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


example-tests

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).


example-basic

Simplest example possible. A very simple graph that multiples two numbers is built in python and saved. The openframeworks example loads the graph, and feeds it mouse coordinates. 100s of lines of code, just to build a simple multiplication function.


example-build-graph

Builds a simple graph from scratch directly in openframeworks using the C++ API without 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

More Repositories

1

eco-nft

A basic guide to ecofriendly CryptoArt (NFTs)
727
star
2

ai-resources

Selection of resources to learn Artificial Intelligence / Machine Learning / Statistical Inference / Deep Learning / Reinforcement Learning
620
star
3

webcam-pix2pix-tensorflow

Source code and pretrained model for running pix2pix in realtime on a webcam feed.
Python
350
star
4

ofxMSAFluid

C++ openFrameworks addon for solving and drawing 2D fluid systems based on Navier-Stokes equations and Jos Stam's paper "Real-Time Fluid Dynamics for Games"
C++
189
star
5

ofxMSAOpenCL

C++ openFrameworks addon for very simple to use wrapper for OpenCL. All underlying openCL objects are accessible to allow advanced features too if need be
C++
88
star
6

p5-MSAFluid

MSAFluid library for processing.
Processing
82
star
7

ofxKinect-demos

demos for ofxKinect (Kinect openFrameworks addons)
C++
82
star
8

ofxIlda

C++ openFrameworks addon for a device agnostic Ilda functionality to control galvo+mirror based laser projectors. See ofxEtherdream for integration with opensource ILDA laser DAC.
C++
73
star
9

ofxMSAmcts

A very simple C++ MCTS (Monte Carlo Tree Search) implementation with examples for openFrameworks
C++
61
star
10

ofxMSAPhysics

C++ openFrameworks addon for particle/constraint based physics library with springs, attractors and collision. It uses a very similar api to the traer.physics library for processing to make getting into it as easy as possible. All classes are template based with typedefs for physics in 2D or 3D - Potentially even more dimensions! Demo at www.memo.tv/msaphysics
C++
52
star
11

ofxEtherdream

C++ openFrameworks addon for interfacing with the Etherdream DAC
C
51
star
12

ofxMSAWord2Vec

openFrameworks addon to load and manage word2vec word embeddings, and supporting python code to train them
Python
42
star
13

ofxARDrone

C++ openFrameworks addon to interface with and control Parrot AR.Drone1 and 2.
C++
32
star
14

py-msa-kdenlive

Python script to load a Kdenlive (OSS NLE video editor) project file, and conform the edit on video or numpy arrays.
Python
30
star
15

ofxMSAInteractiveObject

C++ openFrameworks addon which wraps up some poco functionality to make flash-like objects which auto updates/draws and adds mouse methods like onRollOver, onPress, OnRollout? etc with bounds checking with easy to remember functions to register/un-register callbacks.
C++
28
star
16

ofxSimpleGuiToo

C++ openFrameworks addon for simple and very quick to setup GUI based on Todd Vanderlin's ofxSimpleGui. It uses a very similar (almost identical) API, but with a rewritten backend.
C++
25
star
17

petita-dumdum

I'm a Soundcloud bot. I like the abstract poetry of Petita Tatata, so I download and improvise music over them. I upload my improvisations to soundcloud. I'm still very young and just learning to play. But it's fun and I enjoy.
Max
23
star
18

of-Slitscan3D

volumetric slit-scan demo using Kinect. made with openFrameworks 0072 + ofxKinect
C
22
star
19

iSteveJobs

Feel free this to install this in all Apple Stores. (I'm sure it's legal, but don't quote me on that)
C
21
star
20

ofxMSAInterpolator

C++ openFrameworks addon with a set of template classes for doing various types of interpolations on data with any number of dimensions. You can feed the system an arbitrary number of data, then resample at any resolution, or ask for the value at any percentage along the data. Input data can be floats (for 1D splines, Vec2f (for 2D splines), Vec3f (for 3D splines), or even matrices, or custom data types (e.g. biped pose). Demo at www.memo.tv/msainterpolator
C
17
star
21

ofxMSACore

A very lightweight C++ wrapper which maps basic types to allow tight integration with openFrameworks (www.openframeworks.cc) and Cinder (www.libcinder.org) - or potentially any other C++ frameworks. Used by most of my other ofxMSAxxx addons.
C++
16
star
22

ofxMSAControlFreak

GUI agnostic parameter management system for openFrameworks
C++
15
star
23

VolumeRunner

C++
13
star
24

ofxMSAlibs

Collection of addons for openFrameworks
13
star
25

stayhomesavelives

JavaScript
11
star
26

max-skeletonML

Max
11
star
27

p5-Webcam-Piano-1.5

Processing demo to use the webcam to play a virtual piano. Adjustable gridsize, harmonics, scale etc.
Java
10
star
28

ofxMSAControlFreakGui

OpenGL Gui to display ofxMSAControlFreak parameters
C++
8
star
29

MSAQTPlayer

Native Cocoa fullscreen, multiple output Quicktime player with fast, greater-than-4096-pixels support.
Objective-C
7
star
30

ofxMSAPingPong

C++ openFrameworks addon to create a double buffer to be able to ping-pong back and forth. Templated class allows any data type to be ping-ponged (E.g. opengl texture, opencl image buffer, arbitrary data buffer etc).
C++
7
star
31

ofxMSABPMTapper

C++ openFrameworks addon to keep track of BPM (via tapping) and output helper tempos on the beat, double-tempo, half-tempo, on every bar etc.
C++
6
star
32

ofxARDroneOscBridge

C++
6
star
33

ofxMSATimer

C++ openFrameworks addon to keep track of ultra high resolution time on posix systems using mach_absolute_time (currently using host timing on windows and linux)
C++
6
star
34

AS3-SVGExport

Demo for drawing and exporting SVG from Flash. Doesn't support full SVG, only strokes, colors, thickness.
6
star
35

ainsanity-webextension

Cross-browser WebExtension to replace the terms Artificial Intelligence, Artificially Intelligent, AI etc. with Data-Driven Methods and DDM (and throws in a bar graph emoji for good measure)
JavaScript
6
star
36

AS3-Noise-Suite

A suite of AS3 classes for creating various noise functions, interpolations, fractal composition etc.
ActionScript
5
star
37

of-VertexArray-VBO-PointSprite-Demo

Demos usage of VertexArrays, VBOs, and Point Sprites for openFrameworks 006+. Mac xcode project provided, but should also work on win, linux, ios (if immediate mode code is removed)
C++
5
star
38

ofxMSAStereoSolver

C++ openFrameworks addon to calibrate, rectify and create disparity maps from two non-rectified and non-calibrated images (or image sequences). NOT TESTED WITH LATEST OPENFRAMEWORKS YET.
C++
5
star
39

Projector-Lag-Timer

Measures the lag in a video projector
C++
4
star
40

triggershift

http://www.triggershift.org/
Java
4
star
41

ciVSyncTestApp

Vsync / FPS test application for Cinder
C++
4
star
42

ofxMSACocoa

Native Cocoa Windowing addon for openFrameworks [OLD]
Objective-C++
4
star
43

OF-audioOverSerial

old school serial comms over audio (i.e. encode text or any binary data).
C++
4
star
44

MSAMultiVideoPlayer

a very simple cross platform application to position and play multiple videos anywhere on the screen (or multiple screens).
C++
4
star
45

ofxMSABumblebeeGrabber

C++ openFrameworks addon to capture stereo images from a PointGrey bumblebee using PTGrey SDKs. NOT TESTED WITH LATEST OPENFRAMEWORKS YET.
C++
3
star
46

pr_kinect2_tracker

C++
3
star
47

p5-Drippy

Drippy branchy particle system for processing. Underlying graphics engine for my Roots project.
Java
3
star
48

joanie_contour_tester

C++
3
star
49

ofxMSAMultiCam

Wrapper for managing multiple cameras (ofVideoGrabber or ofxMachineVision), and laying them out into an ofFbo for easy processing in a single go (e.g. on GPU).
C++
3
star
50

p5-bubbles

A simple bubbles particle system demo built with www.processing.org
Java
3
star
51

eyeo-workshop-2013-06-05

Support files for Eyeo Workshop 2013-06-05 "The black art of manipulating numbers. Essential applied maths for computational artists."
Processing
3
star
52

ofxMSAOrderedPointerMap

C++ template class (openFrameworks addon) to create an ordered named map of pointers (wraps std::vector and std::map)
C++
2
star
53

ofxProjectorBlendSimpleGui

Manages a ofxSimpleGuiToo for ofxProjectorBlend (requires my fork)
C++
2
star
54

ofxMSAMotionTracker

C++
2
star
55

ofxMSAOrderedMap

C++ template class (openFrameworks addon) to create an ordered named map (wraps std::map and std::vector)
C++
2
star
56

AS3-Flies3D

A custom 3D particle system and demo written in ActionScript 3.0 with no dependencies (using custom 3D engine) & demo simulating a swarm of flies.
ActionScript
2
star
57

ofxMSAVideoInput

Multi Video Input wrapper for openFrameworks
C++
2
star
58

Empathy_001

Video playback and data capture software for "Realism, abstraction and empathy in video game violence" study.
C++
2
star
59

NSArray-C-Array-performance-comparison

Tools (originally for iphone, would work on mac too) to compare performance of NSArray with C/C++ Array
Objective-C
2
star
60

ofxMSAVectorUtils

C++ templated generic vector<T> util functions for when you don't want to use a huge linalg lib. Only very basic vector functions implemented. For more complex stuff I suggest a dedicated library (like Eigen or Armadillo)
C++
2
star
61

AS3-Starry-Mouse

Springy, trippy, starry particle system using custom 3D particle system
ActionScript
2
star
62

ofxMSAControlFreakOsc

C++
1
star
63

Boss-Grinder

It puts the data in the grind (written for processing 1.5.1)
Java
1
star
64

msalibs_2000

MSA Libs circa 1999/2000
C++
1
star
65

msaOscML

1
star
66

ofSharedPtrExample

simple C++ openframeworks example demonstrating how to use (standard) shared pointers
C++
1
star
67

ofxMSAParamsCocoa

openFrameworks Cocoa Gui generator for MSAParams [OLD]
Objective-C++
1
star
68

ofxMSAPerlin

original (2002 improved) Perlin noise for openFrameworks
C++
1
star
69

resdelet-2011

All the letters on your screen pour down when you hit the DELETE key
1
star
70

MSAFreehander

C++
1
star
71

ofxMSAFluidGuiManager

GUI Manager for ofxMSAFluid
C++
1
star
72

ofxMSALividOhmRGB

A simple C++ class to manage and organize the midi config of a Livid Ohm64/RGB midi controller
Objective-C
1
star
73

AS2-Snow

A Snow particle system for ActionScript 2.0
ActionScript
1
star
74

ofxMSADirManager

Directory utils
C++
1
star
75

ofVSyncTestApp

Vsync / FPS test application for openFrameworks
C++
1
star
76

ofxMSAControlFreakImGui

Lightweight wrapper to display ofxMSAControlFreak parameters with ImGui
C++
1
star
77

HouseOfCardsDataConvertor

Utility to preprocess and convert the Radiohead "House of Cards" point cloud data from text to a binary grid for much faster streaming and persistence across frames
C++
1
star
78

ofxMSAObjCPointer

C++ openFrameworks addon to provide simple ObjectiveC style Smart Pointer functionality, which keeps reference count and frees memory when reference count is zero. This is accomplished by providing retain/release methods similar to Objective C. This is now probably superseded by built in shared pointers.
C++
1
star
79

p5-thom-yorke-face-puller

Processing demo to interact with the Radiohead "House of Cards" point cloud data with mouse, pulling, stretching, springs etc.
Java
1
star