/inception-resnet-flask-demo

Simple (and unsafe) TensorFlow Inception-ResnetV2 Demo with Flask

Primary LanguagePythonApache License 2.0Apache-2.0

Pretrained Inception-ResNet Demo with Flask

Quick note

This demo is not supposed to represent a production-ready server. It is not secure for the web, and is not setup to be responsive (server-client responses and model evaluation run in the same thread instead of asyncronously). Rather, this is a quick demonstration of how to utilize a pretrained Inception-ResNet model and quickly put together a prototype with it.

Dependencies

Run it!

  1. Make sure you have the above dependencies installed (pip install ...)
  2. Clone the repo, move into the directory, and execute run_server.sh:
$ git clone https://github.com/samjabrahams/inception-resnet-flask-demo.git
$ cd inception-resnet-flask-demo
$ ./run_server.sh

About the files

run_server.sh

  • The main file, runs the preprocessing of files and then launches the Flask server
  • You must run this script from its directory, not from a parent or child directory. ie. this:
$ ./run_server.sh

not:

$ ../run_server.sh

or:

$ inception-resnet-flask-demo/run_server.sh

Pre-processing files

resnet_export.py

  • Downloads Inception-ResNet model and checkpoint files and converts them into a frozen and optimized protobuf file in serving/static

labels/merge.py

  • Creates descriptions.txt, which is a line separated file that provides text descriptions of the outputs of the pretrained Inception-ResNet modeel. The first line corresponds to the output at index 0, the second line corresponds to the output at index 1 etc.

Flask Server files

serving/serving.py

  • Starts up the Flask server and TensorFlow model Session
  • Contains route functions for the server

serving/model.py

  • Functions and singleton Session class for the Inception-ResNet Model
  • Singleton is used to preserve optimizations and prevent users from reloading the model from memory

serving/templates/layout.html and serving/templates/predict.html

  • Jinja2 template files for the basic client interface.

TensorFlow files.

The TENSORFLOW_LICENSE applies to the following files:

inception_resnet_v2.py

  • Constructs the Inception ResNet V2 model
  • From the [TensorFlow Models repository](https://github .com/tensorflow/models/blob/master/slim/nets/inception_resnet_v2.py)

inception_preprocessing.py

freeze_graph.py

optimize_for_inference.py

optimize_for_inference_lib.py