An open API service indexing awesome lists of open source software.

https://github.com/siddhi-io/siddhi-execution-tensorflow

Extension that adds support for inferences from pre-built TensorFlow SavedModels
https://github.com/siddhi-io/siddhi-execution-tensorflow

deep-learning deep-neural-network execution extension machine-learning ml neural-network siddhi tensorflow

Last synced: 12 months ago
JSON representation

Extension that adds support for inferences from pre-built TensorFlow SavedModels

Awesome Lists containing this project

README

          

Siddhi Execution TensorFlow
======================================

[![Jenkins Build Status](https://wso2.org/jenkins/job/siddhi/job/siddhi-execution-tensorflow/badge/icon)](https://wso2.org/jenkins/job/siddhi/job/siddhi-execution-tensorflow/)
[![GitHub Release](https://img.shields.io/github/release/siddhi-io/siddhi-execution-tensorflow.svg)](https://github.com/siddhi-io/siddhi-execution-tensorflow/releases)
[![GitHub Release Date](https://img.shields.io/github/release-date/siddhi-io/siddhi-execution-tensorflow.svg)](https://github.com/siddhi-io/siddhi-execution-tensorflow/releases)
[![GitHub Open Issues](https://img.shields.io/github/issues-raw/siddhi-io/siddhi-execution-tensorflow.svg)](https://github.com/siddhi-io/siddhi-execution-tensorflow/issues)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/siddhi-io/siddhi-execution-tensorflow.svg)](https://github.com/siddhi-io/siddhi-execution-tensorflow/commits/master)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

The **siddhi-execution-tensorflow extension** is a Siddhi extension that provides support for running pre-built TensorFlow models.

For information on Siddhi and it's features refer Siddhi Documentation.

## Download

* Versions 2.x and above with group id `io.siddhi.extension.*` from here.
* Versions 1.x and lower with group id `org.wso2.extension.siddhi.*` from here.

## Latest API Docs

Latest API Docs is 2.0.2.

## Features

* predict *(Stream Processor)*



Performs inferences (prediction) from an already built TensorFlow machine learning model. The types of models are unlimited (including image classifiers, deep learning models) as long as they satisfy the following conditions.
1. They are saved with the tag 'serve' in SavedModel format for more info see [here](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md).
2. Model is initially trained and ready for inferences
3. Inference logic is written and saved in the model
4. signature_def is properly included in the metaGraphDef (a protocol buffer file which has information about the graph) and the key for prediction signature def is 'serving-default'

Also the prerequisites for inference are as follows.
1. User knows the names of the input and output nodes
2. Has a preprocessed data set of Java primitive types or their multidimensional arrays

Since each input is directly used to create a Tensor they should be of compatible shape and data type with the model.
The information related to input and output nodes can be retrieved from saved model signature def.signature_def can be read by using the saved_model_cli commands found at [https://www.tensorflow.org/programmers_guide/saved_model](https://www.tensorflow.org/programmers_guide/saved_model).
signature_def can be read in Python as follows



with tf.Session() as sess:
md = tf.saved_model.loader.load(sess, ['serve'], export_dir)
sig = md.signature_def[tf.saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY]
print(sig)


Or you can read signature def from Java as follows,



final String DEFAULT_SERVING_SIGNATURE_DEF_KEY = "serving_default";
final SignatureDef sig =
MetaGraphDef.parseFrom(model.metaGraphDef())
.getSignatureDefOrThrow(DEFAULT_SERVING_SIGNATURE_DEF_KEY);


You will have to import the following in Java.
import org.tensorflow.framework.MetaGraphDef;
import org.tensorflow.framework.SignatureDef;


## Dependencies

There are no other dependencies needed for this extension.

## Installation

For installing this extension on various siddhi execution environments refer Siddhi documentation section on adding extensions.

## Support and Contribution

* We encourage users to ask questions and get support via StackOverflow, make sure to add the `siddhi` tag to the issue for better response.

* If you find any issues related to the extension please report them on the issue tracker.

* For production support and other contribution related information refer Siddhi Community documentation.