TensorFlow Adapter Sample

Introduction

This topic describes how to run the sample application for the TIBCO StreamBase® Operator For TensorFlow Model Evaluator, and illustrates how to use the TensorFlow adapter to feed in data, compute the TensorFlow model, and output the desired results.

The tensorflow.sbapp sample demonstrates a simple process of multiplying an input value by 2 and 3 with the provided model example.

The other sample, imageClassification.sbapp, demonstrates a complete process of image processing with TensorFlow. The input will be an image, and the output will showing the highest probabilities of the image file.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top-level menu, select File>Import Samples and Community Content.

  • Enter tensor to narrow the list of options.

  • Select TensorFlow from the StreamBase Standard Adapters category.

  • Click Import Now.

StreamBase Studio creates a single project for the TensorFlow adapter samples in your current Studio workspace.

Running the TensorFlow Sample in StreamBase Studio

Run this sample in Studio as follows:

  1. In the Project Explorer view, open the sample you just loaded.

    If you see red marks on a project folder, wait a moment for the project to load its features.

    If the red marks do not resolve themselves after a minute, select the project, right-click, and select Maven>Update Project from the context menu.

  2. Open the src/main/eventflow/packageName folder.

  3. Double-click to open the tensorflow.sbapp application, then click the Run button. This opens the SB Test/Debug perspective and starts the application.

  4. In the Manual Input view, select the Input input stream.

  5. Enter float in the dataType field, and one double-type value in the value field. Leave the shape field blank.

  6. Click Send Data.

  7. Observe your message emitted in the Output Streams view.

  8. When done, press F9 or click the Stop Running Application button.

Running the imageClassification Sample in StreamBase Studio

Run this sample in Studio as follows:

  1. In the Project Explorer view, open the sample you just loaded.

    If you see red marks on a project folder, wait a moment for the project to load its features.

    If the red marks do not resolve themselves after a minute, select the project, right-click, and select Maven>Update Project from the context menu.

  2. Download the needed model for image classification model: Go to http://public.tibco.com/pub/tibco_oss/streaming-tensorflow-sample/graph.pb, download this graph.pb file. Copy to your sample's imageClassification folder in the src/main/resources folder.

  3. Open the src/main/eventflow/packageName folder.

  4. Double-click to open the imageClassification.sbapp application, then click the Run button. This opens the SB Test/Debug perspective and starts the application.

  5. Observe your message emitted in the Output Streams view.

  6. In the Manual Input view, select the ImageFile input stream; try with input image path, for example: imageClassification/porcupine.jpg.

  7. When done, press F9 or click the Stop Running Application button.

Sample Location

When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:

studio-workspace/sample_adapter_embedded_tensorflow

See Default Installation Directories for the default location of studio-workspace on your system.