项目作者: hzitoun

项目描述 :
A REST API Serving a Tensorflow 2 keras deep learning model to classify image
高级语言: Python
项目地址: git://github.com/hzitoun/tensorflow-2-image-classification-rest-api.git
创建时间: 2019-03-11T16:19:40Z
项目社区:https://github.com/hzitoun/tensorflow-2-image-classification-rest-api

开源协议:MIT License

下载


Since Tensorflow 2 Alpha was annonced recently, I wanted to try it out by making a simple image classification model trained on fashion mnist data set using a 3 layers neural networks. The model is served as a Rest API.

Defined classes are ‘T-shirt/top’, ‘Trouser’, ‘Pullover’, ‘Dress’, ‘Coat’, ‘Sandal’, ‘Shirt’, ‘Sneaker’, ‘Bag’, ‘Ankle boot’.

Training set

keras.datasets.fashion_mnist

Libs

  • Tensorflow 2.0.0-alpha0
  • Keras
  • Python 3
  • skimage
  • Flask
  • Numpy

How to run?

1- Install the required libs (with conda install or pip install).

2- Run python train_and_export_model.py to train the deep neural networks and export to export it to fashion_mnist_classifier savedModel.

3- Run python app.py to start the server that runs the port 5000.

4- Send a POST query to the http://127.0.0.1/api/recognize_image with a body consisting of a JSON content:

  1. {
  2. "img_url" : "<IMG_TO_CLASSIFY_URL> (http://www.stickpng.com/assets/thumbs/580b57fbd9996e24bc43bef3.png)"
  3. }

And the Server should do the prediction and then respond with :

  1. {
  2. "data": {
  3. "confidence": "89%",
  4. "prediction": "Dress"
  5. },
  6. "isError": false,
  7. "message": "Success",
  8. "statusCode": 200
  9. }