Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

06.4 TensorFlow (Pre Trained)

Miguel Veloso edited this page Feb 13, 2019 · 3 revisions

Introduction

image

In this scenario you will learn how to use a Pre-Trained model, published at Inception5h (based on a Inception deep neural network architecture, and trained using the ImageNet dataset) in order to classify images. The microservice uses TensorFlowSharp library for loading and evaluating the model.

image

Step 1: Configure the environment variables to use the TensorFlow with pre-trained model execution

For running this scenario, since all the TensorFlow model execution is performed within a local custom container (no dependency with any PaaS/Cognitive service in Azure) you only need to update to update the .env file which is located at the root folder of the eShopOnContainersAI code repository specifying that you want eShopOnContainersAI to use this approach when running the "Product Search Image-Based".

Inside the '.env' file you should update the value of the key ESHOPAI_PRODUCTSEARCHIMAGEBASED_APPROACH; for this scenario, you just need to specify the value TensorFlowPreTrained.

Step 2: Run/test eShopOnContainersAI with a Product Search Image-Based based on the TensorFlow with pre-trained model execution

This execution model (microservice/container based on TensorFlowSharp), downloads the pre-trained TensorFlow model from Internet, so you will need Internet access from the Docker container. For this reason, the first time you use the service it will take a few seconds until finishes downloading the model file.

In order to see the "Product Search Image-Based" with the TensorFlow Pre Trained Model setup in action, run eShopOnContainersAI in the browser at http://localhost:5100.

Once you see the home page, click on the "Product Search Image-Based - Choose File" combo-option, as in the following image:

image

You will get a dialog window where you can select and upload any image/photo of a product you desire, so the system will identify what kind of thing is what you just uploaded and then it'll search for related products in the eShop.

image

Either double-click on the image or select your image and hit on the "Open" button. After selecting your image, then you need to click on the right button in order to actually start the search process, as shown in the following image:

image

At this point, you should get a list of related products in the catalog, as in the below screenshot.

image

Step 3: Explore the eShopOnContainersAI C# code running the pre-trained model with TensorFlowSharp and TensorFlow+Keras+Python for the deep-learning execution.

The microservice (ASP.NET Core Web API) implementing the code based on TensorFlowSharp is the one named AI.ProductSearchImageBased.TensorFlow.API, as in the following image from Visual Studio.

image

News

Setup

Scenarios

Clone this wiki locally