TensorFlow 2 AI/ML library wrapper for openFrameworks

Overview

ofxTensorFlow2

ofxTensorFlow2 thumbnail

This is an openFrameworks addon for the TensorFlow 2 ML (Machine Learning) library. The code has been developed by the ZKM | Hertz-Lab as part of the project »The Intelligent Museum«.

Copyright (c) 2021 ZKM | Karlsruhe.

BSD Simplified License.

For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "LICENSE.txt," in this distribution.

Description

ofxTensorFlow2 is an openFrameworks addon for loading and running ML models trained with the TensorFlow 2 ML (Machine Learning) library:

TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML powered applications.

https://www.tensorflow.org

The addon utilizes the TensorFlow 2 C library wrapped by the open source cppflow 2 C++ interface:

Run TensorFlow models in c++ without Bazel, without TensorFlow installation and without compiling TensorFlow. Perform tensor manipulation, use eager execution and run saved models directly from C++.

https://github.com/serizba/cppflow/tree/cppflow2

Additional classes wrap the process of loading & running a model and utility functions are provided for conversion between common openFrameworks types (images, pixels, audio samples, etc) and TensorFlow2 tensors.

openFrameworks is a cross platform open source toolkit for creative coding in C++.

Quick Start

Minimal quick start for a Unix shell to clone cppflow, download pre-built TensorFlow 2 dynamic libraries and pre-trained example models, starting in the root openFrameworks folder:

cd addons
git clone [email protected]:Hertz-Lab/Research/intelligent-museum/ofxTensorFlow2.git
cd ofxTensorFlow2
git submodule update --init --recursive
./scripts/download_tensorflow.sh
./scripts/download_example_models.sh

For further information, please find detailed instructions below.

Note: The TensorFlow download script grabs the CPU-optimized build by default.

Requirements

  • openFrameworks
  • Operating systems:
    • Linux, 64-bit, x86
    • macOS 10.14 (Mojave) or higher, 64-bit, x86
    • Windows, 64-bit x86 (should work, not tested)

To use ofxTensorFlow2, first you need to download and install openFrameworks. The examples are developed against the latest release version of openFrameworks on http://openframeworks.cc/download.

OF github repository

Currently, ofxTensorFlow2 is being developed on Linux and macOS. Windows should work but has not yet been tested.

The main supported operating systems & architectures are those which have pre-built versions of libtensorflow available for download from the TensorFlow website. Other system configurations are possible but may require building and/or installing libtensorflow manually.

Installation and Build

Clone (or download and extract) this repository to the addon folder of openFrameworks. Replace OF_ROOT with the path to your openFrameworks installation

cd OF_ROOT/addons
git clone [email protected]:Hertz-Lab/Research/intelligent-museum/ofxTensorFlow2.git

Dependencies

  • TensorFlow 2
  • cppflow 2

Since TensorFlow does not ship a C++ Library we make use of cppflow2, which is a C++ wrapper around the TensorFlow 2 C API.

Pull cppflow to libs/cppflow and checkout cppflow2:

cd ofxTensorFlow2
git submodule update --init --recursive

Next, download the pre-built TensorFlow2 C library and extract the following folders to their destination:

include/ --> libs/tensorflow/include
lib/ --> libs/tensorflow/lib/[osx/linux64/msys2/vs]

To make this quick, you can use a script which automates the download:

./scripts/download_tensorflow.sh

When opting for GPU support set the TYPE script variable:

TYPE=gpu ./scripts/download_tensorflow.sh

See https://www.tensorflow.org/install/gpu for more information on GPU support for TensorFlow.

Ubuntu / Linux

To run applications using ofxTensorFlow2, the path to the addon's lib/tensorflow subfolder needs to be added to the LD_LIBRARY_PATH environment variable.

Temporary Lib Path Export

The path can be temporarily added via an export on the commandline (replace OF_ROOT with the path to your openFrameworks installation) before running the application:

export LD_LIBRARY_PATH=OF_ROOT/addons/ofxTensorFlow2/libs/tensorflow/lib/linux64/:$LD_LIBRARY_PATH
make run

This step can also be automated by additional makefile targets provided by the addon_targets.mk file. To use it, add the following to the end of the project's Makefile:

# ofxTensorFlow2
include $(OF_ROOT)/addons/ofxTensorFlow2/addon_targets.mk

This adds two additional targets, one for Debug and the other for Release, which run the application after exporting the LD_LIBRARY_PATH. For example, to run a debug version of the application:

make RunDebugTF2

Similarly, for release builds use:

make RunReleaseTF2

Permanent Lib Path Export

For a permanent "set and forget" solution, the export line can be added to the end of your shell's user startup script, ie. ~/.zshrc or /.bash_profile to add the path whenever a new shell session is opened. Once set, the manual export is no longer required when running an ofxTensorFlow2 application.

Using libtensorflow Installed to the System

To use libtensorflow installed to a system path, ie. by your system's package manager, the path(s) need to be added to the project header include and library search paths and the libraries need to be passed to the linker.

  1. If libtensorflow was downloaded to libs/tensorflow/, remove all files in this folder
  2. Edit addon_config.mk under the "linux64" build target: comment the "local path" sections
  3. If using the OF Project Generator, (re)regenerate project files for projects using the addon

Note: When using libtensorflow installed to the system, the LD_LIBRARY_PATH export is not needed.

macOS

The cppflow library requires C++14 which needs to be enabled when building on macOS.

libtensorflow is provided as pre-compiled dynamic libraries. On macOS these .dylib files need to be configured and copied into the build macOS .app. These steps are automated via the scripts/macos_install_libs.sh script and can be invoked when building, either by Xcode or the Makefiles.

Alternatively, you can use libtensorflow compiled and installed to the system, ie. /usr/local or /usr/opt. In this case, the dylibs do not need to be copied into the macOS .app, however the built app will not run on other computers without the same libraries installed to the same location.

Xcode build

Enable C++14 features by changing the CLANG_CXX_LANGUAGE_STANDARD define in OF_ROOT/libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig, for example:

CLANG_CXX_LANGUAGE_STANDARD[arch=x86_64] = c++14

After generating project files using the OF Project Generator, add the following to one of the Run Script build phases in the Xcode project to invoke the macos_install_libs.sh script:

  1. Select the project in the left-hand Xcode project tree
  2. Select the project build target under TARGETS
  3. Under the Build Phases tab, find the 2nd Run Script, and add the following before the final echo line:
$OF_PATH/addons/ofxTensorFlow2/scripts/macos_install_libs.sh "$TARGET_BUILD_DIR/$PRODUCT_NAME.app";

Makefile build

Enable C++14 features by changing -std=c++11 to -std=c++14 on line 142 in OF_ROOT/libs/openFrameworksCompiled/project/osx/config.osx.default.mk:

PLATFORM_CXXFLAGS += -std=c++14

When building an application using the makefiles, an additional step is required to install & configure the tensorflow2 dylibs into the project .app. This is partially automated by the scripts/macos_install_libs.sh script which is called from the addon_targets.mk file. To use it, add the following to the end of the project's Makefile:

# ofxTensorFlow2
include $(OF_ROOT)/addons/ofxTensorFlow2/addon_targets.mk

This adds two additional targets, one for Debug and the other for Release, which call the script to install the .dylibs. For example, to build a debug version of the application and install the libs, simply run:

make DebugTF2

Similarly, for release builds use:

make ReleaseTF2

This will also work when building the normal targets using two steps, for example:

make Debug
make DebugTF2

Using libtensorflow Installed to the System

To use libtensorflow installed to a system path, ie. from a package manager like Homebrew, the path(s) need to be added to the project header include and library search paths and the libraries need to be passed to the linker. The scripts/macos_install_libs.sh is not needed.

  1. If libtensorflow was downloaded to libs/tensorflow/, remove all files in this folder
  2. Edit addon_config.mk under the "osx" build target:
  • comment the "local path" sections and uncomment the "system path" sections
  • If needed, change the path for your system, ie. /usr/local to /usr/opt etc
  1. If using the OF Project Generator, (re)regenerate project files for projects using the addon

Running the Example Projects

The example projects are located in the example_XXXX directories.

Downloading Pre-Trained Models

Each example contains code to create a neural network and export it in the SavedModel format. Neural networks require training which may take hours or days in order to produce a satisfying output, therefore we provide pre-trained models which you can download as ZIP files, either from the release page on GitHub or from a public shared link here:

https://cloud.zkm.de/index.php/s/gfWEjyEr9X4gyY6

To make this quick, a script is provided to download and install the models for each example (requires a Unix shell, curl, and unzip):

cd OF_ROOT/addons/ofxTensorFlow2
./scripts/download_example_models.sh

By default, the example applications try to load a SavedModel named "model" (or "models" depending on the example) located in example_XXXX/bin/data/. When downloading or training a model, please make sure the SavedModel is at this location and has the right name, otherwise update the model load path string.

Generating Project Files

Project files for the examples are not included so you will need to generate the project files for your operating system and development environment using the OF ProjectGenerator which is included with the openFrameworks distribution.

To (re)generate project files for an existing project:

  • Click the "Import" button in the ProjectGenerator
  • Navigate to the project's parent folder ie. "ofxTensorFlow2", select the base folder for the example project ie. "example_XXXX", and click the Open button
  • Click the "Update" button

If everything went Ok, you should now be able to open the generated project and build/run the example.

macOS

Open the Xcode project, select the "example_XXXX Debug" scheme, and hit "Run".

For a Makefile build, build and run an example on the terminal:

cd example_XXXX
make ReleaseTF2
make RunRelease

Linux

For a Makefile build, build and run an example on the terminal:

cd example_XXXX
make Release
make RunReleaseTF2

Create a New ofxTensorFlow2 Project

Simply select ofxTensorFlow2 from the available addons in the OF ProjectGenerator before generating a new project. Make sure that all dependencies are installed and downloaded beforehand, otherwise the PG may miss some paths.

Training Models

Note: GPU support recommended

Model Format

ofxTensorFlow2 works with the TensorFlow 2 SavedModel format.

When referring to the "SavedModel" we mean the parent folder of the exported neural network containing two subfolder assets and variables and a saved_model.pb file. Do not change anything inside this folder, however renaming the folder is permitted as long as you you change the file path used within the application to match.

Requirements

For building a dataset and training a model for use with the ofxTensorFlow2 addon, use Python 3. For ease of use with dependency handling, using virtual environments is recommended. One such tool for this is anaconda or the smaller miniconda.

Install anaconda or miniconda, then install the pip3 package manager using conda:

conda install pip3

Included Example Projects

For each example project, create a new virtual environment. We will use conda to do so:

cd example_XXXX/python
conda create -n myEnv python=3.7
conda activate myEnv

With our virtual environment set up and activated we need to install the required python packages. A common package manager is pip. For each example we've listed the required packages using pip3 freeze > requirements.txt. You can easily install them by running:

pip3 install -r requirements.txt

As the training procedure and the way of configuring it varies a lot between the examples, please refer to the README.md provided in the python folder. Some may require to simply edit a config script and run:

python3 main.py

Others may require to feed additional information to the main.py script.

Creating Your Own Project Models

If you want to create your own Deep Learning project, here are some tips to guide you along the way.

IDE

Get an IDE (Integrated Development Environment) aka fancy text editor for development. As you will be using Python, choose a specialized IDE, e.g. Spyder (included in Anaconda) or PyCharm. Make sure to set the virtual environment as the interpreter for this project. If you choose to create the virtual environment using conda you will find a subfolder envs in the installation folder of anaconda. This includes a folder for every virtual environment. Choose the right one and go to bin and select the binary python as interpreter. This way the IDE can run and debug your projects.

Python

Get familiar with Python. The official Python tutorial is a great place to start. Python has a lot of functions in its standard library, but there are a lot of other external packages to look out for:

  • NumPy (efficient math algorithms and data structures)
  • Matplotlib (plotting in the style of Matlab)
  • TensorFlow 2 (ML library)
Keras

Get familiar with Keras. Since TensorFlow 2, Keras is the high level front-end of TensorFlow. It greatly reduces the effort of accessing common data structures (like labeled pictures), defining a Neural Network architecture and observing the training process using callbacks. Besides that, you can always call TensorFlow's core functions such as data pipelines.

Project Structure

Get some structure for your project. Your project could look a little bit like this:

  • data: stores scripts to download and maybe process some data
  • src: contains Python code for the model, preprocessing and train, test and eval procedures
  • main.py: often serves as a front to call the train, eval or test scripts
  • config.py: stores high level parameters such as learning rate, batch size, etc. Edit this file for different experiments. Formats other than .py are fine too, but it's very easy to integrate. It's a good choice to save this file along with trained models.
  • requirements.txt: contains required packages
Machine Learning

Get familiar with Machine Learning concepts. There is plenty of free information out there! Here is a list of material to look into:

  • Coursera: founded by ML expert Andrew Ng, lists free online courses for a lot of fields (including Python and Machine Learning)
  • Deeplearning.ai: a website dedicated to Deep Learning - also founded by Andrew Ng
  • Deep Learning book: a free website accompanying the book "Deep Learning" by Ian Goodfellow (known for GANs)
  • Stanford CS231: YouTube playlist of Stanford's Computer Vision course CS231
  • Machine Learning Mastery: a popular blog about practical ML techniques. It focuses on the ease of use
TensorFlow

Get familiar with TensorFlow's Tutorials. Besides learning how to write TensorFlow code, the tutorials will teach you ML concepts like overfitting and underfitting.

Datasets

Get to know common datasets. A great place to start is Kaggle. Here you can find thousands of datasets and accompanying code (in form of Python notebooks that run in your browser).

Inspiration

Get inspired and take the risk of making errors! We can not help you with the latter but check out this repo for some inspiration.

Developing

You can help develop ofxTensorFlow2 on GitHub: https://github.com/zkmkalrsruhe/ofxTensorFlow2

Create an account, clone or fork the repo, then request a push/merge.

If you find any bugs or suggestions please log them to GitHub as well.

Known Issues

dyld: Library not loaded: @rpath/libtensorflow.2.dylib

On macOS, the libtensorflow dynamic libraries (dylibs) need to be copied into the .app bundle. This error indicates the library loader cannot find the dylibs when the app starts and the build process is missing a step. Please check the "macOS" subsection under the "Installation & Build" section.

EXC_BAD_INSTRUCTION Crash on macOS

The pre-built libtensorflow downloaded to libs/tensorflow comes with AVX (Advanced Vector Extensions) enabled which is an extension to the Intel x86 instruction set for fast vector math. CPUs older than circa 2013 may not support this and the application will simply crash with error such as:

in libtensorflow_framework.2.dylib
...
EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

This problem may also be seen when using libtensorflow installed via Homebrew.

The only solution is to build libtensorflow from source with AVX disabled use a machine with a newer CPU. To check if your CPU supports AVX use:

# print all CPU features
sysctl -a | grep cpu.feat

# prints only if CPU supports AVX
sysctl -a | grep cpu.feat | grep AVX

Systems confirmed: Mac Pro (Mid 2012)

Symbol not found: ____chkstk_darwin

The pre-built libtensorflow dynamic libraries downloaded from the TensorFlow website require a minimum of macOS 10.14. On macOS 10.13 or lower, the project may build but will fail on run with a runtime loader error:

dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin
  Referenced from: /Users/na/of_v0.11.0_osx_release/addons/ofxTensorFlow2/example_basics/bin/example_basics.app/Contents/MacOS/./../Frameworks/libtensorflow.2.dylib (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib

The only solutions are:

  1. upgrade to macOS 10.14 or newer (easier)
  2. use libtensorflow compiled for your system:
  • installed to system via a package manager, ie. Homebrew or Macports (harder)
  • or, build libtensorflow manually (probably hardest)

The Intelligent Museum

An artistic-curatorial field of experimentation for deep learning and visitor participation

The ZKM | Center for Art and Media and the Deutsches Museum Nuremberg cooperate with the goal of implementing an AI-supported exhibition. Together with researchers and international artists, new AI-based works of art will be realized during the next four years (2020-2023). They will be embedded in the AI-supported exhibition in both houses. The Project „The Intelligent Museum“ is funded by the Digital Culture Programme of the Kulturstiftung des Bundes (German Federal Cultural Foundation).

As part of the project, digital curating will be critically examined using various approaches of digital art. Experimenting with new digital aesthetics and forms of expression enables new museum experiences and thus new ways of museum communication and visitor participation. The museum is transformed to a place of experience and critical exchange.

Logo

Comments
  • how to interpret output

    how to interpret output

    Hello!!

    Im playing with this to help me to understand how tensorflow c pi works.

    I have a centernet model that has one input and 4 outputs

    The given SavedModel SignatureDef contains the following input(s):
      inputs['input_tensor'] tensor_info:
          dtype: DT_UINT8
          shape: (1, -1, -1, 3)
          name: serving_default_input_tensor:0
    The given SavedModel SignatureDef contains the following output(s):
      outputs['detection_boxes'] tensor_info:
          dtype: DT_FLOAT
          shape: (1, 100, 4)
          name: StatefulPartitionedCall:0
      outputs['detection_classes'] tensor_info:
          dtype: DT_FLOAT
          shape: (1, 100)
          name: StatefulPartitionedCall:1
      outputs['detection_scores'] tensor_info:
          dtype: DT_FLOAT
          shape: (1, 100)
          name: StatefulPartitionedCall:2
      outputs['num_detections'] tensor_info:
          dtype: DT_FLOAT
          shape: (1)
          name: StatefulPartitionedCall:3
    Method name is: tensorflow/serving/predict
    

    I load the model and set input and output names

        model.load("model");
    
    
        vector<string> inputs{"serving_default_input_tensor:0"};
        vector<string> outputs{"StatefulPartitionedCall:0",
                                "StatefulPartitionedCall:1",
                                "StatefulPartitionedCall:2",
                                "StatefulPartitionedCall:3"};
    
        model.setup(inputs,outputs);
    

    Add one dimension to input to follow model requeriments

        input = cppflow::expand_dims(input, 0);
        auto output = model.runModel(input);
    

    And now how i acces to the output data? I tried this but dont work, i expected that the return of runModel was a vector of vectors.... i tried reading the cppflow doc but no luck

        auto detection_boxes = output[0];
        auto detection_classes = output[1];
        auto detection_scores = output[2];
        auto num_detections = output[3];
    

    Thanks!

    opened by natxopedreira 40
  • RobustVideoMatting

    RobustVideoMatting

    Hello

    I moved/ported/coded/play or whatever is called correctly this repo https://github.com/PeterL1n/RobustVideoMatting to use it with you addon.

    Is supercool, is interesting to add to examples? It has multiple inputs/outputs and use initial recurrent states.

    Screenshot-2021-09-21-14-53-26

    opened by natxopedreira 21
  • [Suggestion] add support to use frozen graph

    [Suggestion] add support to use frozen graph

    Hello!!

    What do you think to add support to use frozen graph? That way you can use a pb created in tf1, so is more compatible.... i'm doing that and works ok. Old cppflow had that option

    feature 
    opened by natxopedreira 17
  • Error compiling: No member named 'exchange' in namespace 'std'

    Error compiling: No member named 'exchange' in namespace 'std'

    I'm trying to compile in MacOsX example_basic, but I'm having this error: No member named 'exchange' in namespace 'std', in context.h line 78.

    inline context::context(context&& ctx) noexcept : tfe_context(std::exchange(ctx.tfe_context, nullptr)) { } inline context& context::operator=(context&& ctx) noexcept { tfe_context = std::exchange(ctx.tfe_context, tfe_context); return *this; }

    I might be missing a step of the installation?

    opened by Dazzid 14
  • arbitrary-image-stylization-v1-256

    arbitrary-image-stylization-v1-256

    I try to run the arbitrary-image-stylization-v1-256 model: https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2 I can load the model without any errors, but it chrashes if I try to run the model (without an error message). This is how I try to run it:

    	if(!model.load("magenta")) {
    		std::exit(EXIT_FAILURE);
    	}
    
    	model.setup({ {"serving_default_placeholder:0"} ,{"serving_default_placeholder_1:0"} }, { {"StatefulPartitionedCall:0"} });
    
    	auto input_1 = cppflow::decode_jpeg(cppflow::read_file(std::string(ofToDataPath("example_1.jpg"))));
    	input_1 = cppflow::cast(input_1, TF_UINT8, TF_FLOAT);
    	input_1 = cppflow::expand_dims(input_1, 0);
    	auto input_2 = cppflow::decode_jpeg(cppflow::read_file(std::string(ofToDataPath("example_2.jpg"))));
    	input_2 = cppflow::cast(input_2, TF_UINT8, TF_FLOAT);
    	input_2 = cppflow::expand_dims(input_2, 0);
    	std::vector<cppflow::tensor> vectorOfInputTensors = {
    	 input_1, input_2
    	};
    	auto output = model.runModel(vectorOfInputTensors);
    

    Any idea what I am doing wrong (or if the model runs at all with ofxTensorflow2)? Thank you.

    opened by Jonathhhan 13
  • How to use other existing model ?

    How to use other existing model ?

    Thank you so so much for making this. It hopefully removes the need for use JS to run a lot of the models and send their info to OF over OSC. As the awesome Lingdong had done here: https://github.com/LingDong-/PoseOSC

    Do you have advice on how to make other models like PoseNet or the mediapipe handpose from tensorflow.js work with your addon ?

    Again, thanks so much for making this. Stephan.

    opened by stephanschulz 11
  • question, tf version

    question, tf version

    Hello

    Thanks for that addon, i want to move some python code i had to c++ in oF but i need to get a new machine. Seems like now is very hard to find a 2080 so i must go for 3080 but this last one seems to work only with cuda 11 and tf > 2.4

    Have you tested this addon with that config?

    Thank you!!

    opened by natxopedreira 7
  • "Undefined symbols for architecture arm64: "_TF_NewSessionOptions", referenced from:" on macOS ?

    Hi. Thanks for make this addon available to us.

    I am on macOS 10.15.7, OF 0.11.2m Xcode 12.4

    I followed the macOS install steps and get a bunch of compile errors related to arm64

    Would you know why? Should I rather try OF 0.11.0 ? Should I be on a more recent macOS?

    Undefined symbols for architecture arm64:
      "_TF_NewSessionOptions", referenced from:
          cppflow::model::model(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in ofxTF2Model.o
      "_TF_NewBufferFromString", referenced from:
          cppflow::model::model(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in ofxTF2Model.o
      "_TF_NewGraph", referenced from:
          cppflow::model::model(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in ofxTF2Model.o
      "_TF_DeleteSessionOptions", referenced from:
          cppflow::model::model(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in ofxTF2Model.o
      "_TF_GraphNextOperation", referenced from:
          cppflow::model::get_operations() const in ofxTF2Model.o
      "_TF_GraphGetTensorNumDims", referenced from:
          cppflow::model::get_operation_shape(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in ofxTF2Model.o
      "_TF_OperationName", referenced from:
          cppflow::model::get_operations() const in ofxTF2Model.o
      "_TF_GraphOperationByName", referenced from:
          cppflow::model::operator()(std::__1::vector<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cppflow::tensor>, std::__1::allocator<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cppflow::tensor> > >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >) in ofxTF2Model.o
          cppflow::model::get_operation_shape(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in ofxTF2Model.o
      "_TF_SessionRun", referenced from:
    
    Screen Shot 2022-01-17 at 2 10 11 PM Screen Shot 2022-01-17 at 2 09 50 PM Screen Shot 2022-01-17 at 2 09 27 PM
    opened by stephanschulz 6
  • trained model different format?

    trained model different format?

    I managed to train a model for pix2pix, however the output files are looking different than the included edge2shoe example. 2022-06-19 22_49_18-C__Users_plesk_Documents_coding_of_v0 11 2_vs2017_release_addons_ofxTensorFlow2_ I don't have assetsand variablesfolder and no .pb file. I would appreciate some more guidance for how to format my trained model so I can use it with the example.

    opened by paul-ferragut 5
  • Visual Studio install

    Visual Studio install

    I added this to the readme:

    ### Windows / Visual Studio 2022
    
    1. Install CUDA 11.7
    2. Install CUDNN 8.4.1.50
    3. Put the files from C:\Program Files\NVIDIA GPU Computing Toolkit\CUDNN\v8.4.1.50\bin and zlibwapi.dll from http://www.winimage.com/zLibDll/zlib123dllx64.zip into C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin
    4. Put https://github.com/serizba/cppflow into ofxTensorFlow2\libs\cppflow
    5. Put libtensorflow-gpu-windows-x86_64-2.8.0 from https://www.tensorflow.org/install/lang_c into ofxTensorFlow2\libs\tensorflow
    6. Create the folder ofxTensorFlow2\libs\tensorflow\lib\vs and put the content from ofxTensorFlow2\libs\tensorflow\lib (2 files) there.
    7. Run ofxTensorFlow2\scripts\download_example_models.sh
    

    Installed it a second time to confirm that it works for me. Not sure if this is the right format, just wanted to share it because its working for me.

    opened by Jonathhhan 5
  • example for single pose lightning model use

    example for single pose lightning model use

    As mentioned here I noticed that the current movenet example does not work well when a person is close to the camera. So, I made this example using the single pose lighting model.

    https://github.com/zkmkarlsruhe/ofxTensorFlow2/pull/11#issuecomment-1020602085

    I don't do PRs very often and hope it did not make any mistakes.

    feature 
    opened by stephanschulz 5
  • Stable diffusion or other text-to-image networks?

    Stable diffusion or other text-to-image networks?

    I wonder if it is possible to implement stable diffusion or any other text-to-image network (dall-e for example). https://github.com/CompVis/stable-diffusion I guess, the complicated part is the pre-/postprocessing and converting the model to a saved_model... Any hints are very welcome...

    opened by Jonathhhan 1
  • music generation example

    music generation example

    i tried to use this model for music generation: https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/audio/music_generation.ipynb#scrollTo=1mil8ZyJNe1w

    its very rough yet, and not sure if everything works as expected. maybe you can find something wrong... especially my replacement for tf.random.categorical(pitch_logits, num_samples=1) could be wrong. the model is very small, so it is included in the example... https://github.com/Jonathhhan/ofxTensorFlow2/tree/music_generation_example/example_music_generation

    opened by Jonathhhan 6
  • Chatbot example :)

    Chatbot example :)

    This was the most difficult for me to understand. But now it works quite well, I guess: https://github.com/Jonathhhan/ofxTensorFlow2/tree/example_chatbot/example_chatbot https://forum.openframeworks.cc/t/ofxtensorflow2-chatbot-almost-solved/40090/9

    opened by Jonathhhan 0
  • example_video_and_image_colorization

    example_video_and_image_colorization

    This was not easy for me (to find and understand a pretrained colorization model). With this pretrained model I got it working (had to convert it to a saved model): https://github.com/EnigmAI/Artistia/blob/main/ImageColorization/trained_models_v2/U-Net-epoch-100-loss-0.006095.hdf5 It tried it with this model before, but it seems they use two models together (do not really understand it yet): https://github.com/pvitoria/ChromaGAN

    I converted the model like this (with Python):

    from tensorflow.keras.models import Model, load_model
    model = load_model(MODEL_FULLPATH)
    model.save(MODEL_FULLPATH_MINUS_EXTENSION)
    

    Anyway, here is the example: https://github.com/Jonathhhan/ofxTensorFlow2/tree/example_video_and_image_colorization/example_video_and_image_colorization

    opened by Jonathhhan 7
  • word2vec / universal sentence encoder example?

    word2vec / universal sentence encoder example?

    I wonder if somebody use a word2vec model with ofxTensorflow2? I found a model and tried to use it, but without success: https://tfhub.dev/google/Wiki-words-250-with-normalization/2 For now I use ofxWord2vec https://github.com/perevalovds/ofxWord2Vec for finding subtitle similarities (with a pretrained model) and I would like to do that with ofxTensorflow2 too... https://github.com/Jonathhhan/ofEmscriptenExamples/tree/main/montageautomat_threaded_2

    opened by Jonathhhan 8
  • Verify setup & build on Windows

    Verify setup & build on Windows

    This addon was initially developed on Linux and macOS, but has not been tested on Windows. The layout, scripting, and project support files are set up, more or less, but we haven't been able to verify yet.

    If you are a Windows developer, please let us know if this addon is working as expected in:

    • [ ] Visual Studio, 64-bit
    • [ ] Msys2, 64-bit
    help wanted 
    opened by danomatika 31
Owner
Center for Art and Media Karlsruhe
Center for Art and Media Karlsruhe
📝 Wrapper library for text generation / language models at char and word level with RNN in TensorFlow

tensorlm Generate Shakespeare poems with 4 lines of code. Installation tensorlm is written in / for Python 3.4+ and TensorFlow 1.1+ pip3 install tenso

Kilian Batzner 63 May 22, 2021
TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

null 2.6k Jan 4, 2023
Fast image augmentation library and easy to use wrapper around other libraries. Documentation: https://albumentations.ai/docs/ Paper about library: https://www.mdpi.com/2078-2489/11/2/125

Albumentations Albumentations is a Python library for image augmentation. Image augmentation is used in deep learning and computer vision tasks to inc

null 11.4k Jan 9, 2023
Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy.

Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy. Now with tensorflow 1.0 support. Evaluation usa

Marcel R. 349 Aug 6, 2022
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Peter Lin 6.5k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting (RVM) English | 中文 Official repository for the paper Robust High-Resolution Video Matting with Temporal Guidance. RVM is specific

flow-dev 2 Aug 21, 2022
Deep learning library featuring a higher-level API for TensorFlow.

TFLearn: Deep learning library featuring a higher-level API for TensorFlow. TFlearn is a modular and transparent deep learning library built on top of

TFLearn 9.6k Jan 2, 2023
Deep learning library featuring a higher-level API for TensorFlow.

TFLearn: Deep learning library featuring a higher-level API for TensorFlow. TFlearn is a modular and transparent deep learning library built on top of

TFLearn 9.5k Feb 12, 2021
TensorFlow-based neural network library

Sonnet Documentation | Examples Sonnet is a library built on top of TensorFlow 2 designed to provide simple, composable abstractions for machine learn

DeepMind 9.5k Jan 7, 2023
NeuPy is a Tensorflow based python library for prototyping and building neural networks

NeuPy v0.8.2 NeuPy is a python library for prototyping and building neural networks. NeuPy uses Tensorflow as a computational backend for deep learnin

Yurii Shevchuk 729 Jan 3, 2023
QKeras: a quantization deep learning library for Tensorflow Keras

QKeras github.com/google/qkeras QKeras 0.8 highlights: Automatic quantization using QKeras; Stochastic behavior (including stochastic rouding) is disa

Google 437 Jan 3, 2023
DeepLab2: A TensorFlow Library for Deep Labeling

DeepLab2 is a TensorFlow library for deep labeling, aiming to provide a unified and state-of-the-art TensorFlow codebase for dense pixel labeling tasks.

Google Research 845 Jan 4, 2023
RetinaFace: Deep Face Detection Library in TensorFlow for Python

RetinaFace is a deep learning based cutting-edge facial detector for Python coming with facial landmarks.

Sefik Ilkin Serengil 512 Dec 29, 2022
Tensorforce: a TensorFlow library for applied reinforcement learning

Tensorforce: a TensorFlow library for applied reinforcement learning Introduction Tensorforce is an open-source deep reinforcement learning framework,

Tensorforce 3.2k Jan 2, 2023
A Tensorflow based library for Time Series Modelling with Gaussian Processes

Markovflow Documentation | Tutorials | API reference | Slack What does Markovflow do? Markovflow is a Python library for time-series analysis via prob

Secondmind Labs 24 Dec 12, 2022
Transformers4Rec is a flexible and efficient library for sequential and session-based recommendation, available for both PyTorch and Tensorflow.

Transformers4Rec is a flexible and efficient library for sequential and session-based recommendation, available for both PyTorch and Tensorflow.

null 730 Jan 9, 2023
Simple helper library to convert a collection of numpy data to tfrecord, and build a tensorflow dataset from the tfrecord.

numpy2tfrecord Simple helper library to convert a collection of numpy data to tfrecord, and build a tensorflow dataset from the tfrecord. Installation

Ryo Yonetani 2 Jan 16, 2022
lightweight python wrapper for vowpal wabbit

vowpal_porpoise Lightweight python wrapper for vowpal_wabbit. Why: Scalable, blazingly fast machine learning. Install Install vowpal_wabbit. Clone and

Joseph Reisinger 163 Nov 24, 2022
A Python wrapper for Google Tesseract

Python Tesseract Python-tesseract is an optical character recognition (OCR) tool for python. That is, it will recognize and "read" the text embedded i

Matthias A Lee 4.6k Jan 5, 2023