/openvino_restapi

This repository contains deep learning models optimized for inference using OpenVino and served as REST APIs using FastAPI

Primary LanguagePython

openvino and fastapi

This repository contains deep learning models optimized for inference using OpenVino and served as REST APIs using FastAPI

Steps to run the code and API

  1. Create a virtual environment
  • python -m venv <VENV_NAME>
  1. Update pip and Install requirements (install fastapi and uvicorn)
  • python pip install --upgrade
  • pip install requirements.txt
  1. Locate your .h5 model and run following command that will save your model as saved_model format for tensorflow
  • python h5_to_saved_model.py
  1. Convert saved_model to openvino mode.xml using following command
  • mo --saved_model_dir <SAVED_MODEL_DIRECTORY>
  • Example:
  • mo --saved_model_dir local/saved_model/
  1. Modify the bees_openvino_fastapi.py as per you requirements and run following command
  • uvicorn bees_openvino_fastapi:app --reload
  1. Open the link in the browser and start testing your API.

Todo

  • Work on optimization of open source off-the-shelf object detection models
  • Write a detailed tutorial

In Progress

  • Working on PyTorch and other popular frameworks model optimization.

Done ✓

  • Trained a Keras like model on Ants vs Bees (dataset available at this link)
  • Converted .h5 model to tensorflow saved_model
  • Optimzied model using OpenVino model optimizer to get model.xml
  • Developed a FastAPI for serving this model

References