/Deep-Model-Transfer-Deployment

methods to deploy the tf image classification model

Primary LanguagePython

Deep-Model-Transfer-Deployment

Documentation Documentation Documentation

After comparing the accuracy and speed of several models, I finally select Inception-v3 to deploy my 102 classes flower classification project which was trained on Oxford-102 flower dataset. The final model file in this folder which include the freezed pb file.

Other project including πŸ•ŠοΈBird-200, πŸš—Car-196, 🐢Dog-120, 🐢🐱Pet-37 described in Deep-Model-Transfer will be enclosed in the future.

Environment

  • GTX 1080
  • CUDA 10.1
  • CuDNN 7.6.5
  • TensorFlow 1.5.0+/2.0.0+

Prepare

  • For TensorFlow 2.0.0+

nothing to change

  • For TensorFlow 1.5.0+

comment import tensorflow.compat.v1 as tf

uncomment import tensorflow as tf

same as server_html.py/server_api.py

Through HTML

Command

# create folder to store images uploaded
>>> mkdir /tem/upload
>>> python3 -u server_html.py \
    --model_name=./all_102_inception_v3/all_102_inception_v3_named_freeze.pb \
    --label_file=./all_102_inception_v3/all_102_inception_v3_named_freeze.label \
    --upload_folder=/tmp/upload

How open http://<your_ip>:5001/ upload image get result

Through API

Command

# create folder to store images uploaded
>>> mkdir /tem/upload
>>> python3 -u server_api.py \
    --model_name=./all_102_inception_v3/all_102_inception_v3_named_freeze.pb \
    --label_file=./all_102_inception_v3/all_102_inception_v3_named_freeze.label \
    --upload_folder=/tmp/upload

Definition

If upload image URL path:

  • POST /FROMURL

If upload image file:

  • POST /FROMFILE

Arguments

If upload image URL path:

  • "file":string .jpg image URL path

If upload image file:

  • "file":binary .jpg image binary file

Response

  • 200 OK on success
{
    "data": {
        "Top 1 name": "ηŽ‰ε…°θŠ±",
        "Top 1 score": "100.00%",
        "Top 2 name": "θ‹•θŠ±",
        "Top 2 score": "0.00%",
        "Top 3 name": "ζ— θŒŽιΎ™θƒ†θŠ±",
        "Top 3 score": "0.00%",
        "Top 4 name": "ηŽ‹ε±±ιΎ™ηœΌθŠ±",
        "Top 4 score": "0.00%",
        "Top 5 name": "ηŽ«η‘°θŠ±",
        "Top 5 score": "0.00%"
    }
}

How