Skip to content

Deep Learning Model Deployment with Django using TensorFlow Serving in conjunction with Docker to serve a REST API for inference.

Notifications You must be signed in to change notification settings

marwanmusa/Deploy-DeepLearningModels-with-Django

Repository files navigation

Deploy Deep Learning Model - CNN with Django

This Repository is a Model Deployment with Django using TensorFlow Serving in conjunction with Docker to serve a REST API for inference.

Research topic : Convolutional Neural network, Image Exploration, Image Preprocessing, TensorFlow, Model Optimization, Model Evaluation, Docker Deployment, Tensorflow Serving, Django Framework

Steps:

1. Making API model

After saving the model (we'll assume that we already have the model in a folder with its folder name is the model name), we will create an API using the following steps:

docker pull tensorflow/serving
docker run --rm -it -p 8500:8500 -p 8501:8501 -v "/path/to/model/traffic_classifier:/models/traffic_classifier"-e MODEL_NAME=traffic_classifier tensorflow/serving:latest

Notes:
/path/to/model/traffic_classifier is the path where we save the model. You can download my saved model and saved it in your PC/Notebook.

MODEL_NAME is our model name.

if it success, then it will writes "entering loop" on the terminal.

This is how our API will look like
http://localhost:8501/v1/models/traffic_classifier:predict

2. Changing STATICFILES_DIRS directory

Open "/trafficsign_classifier_web/settings.py" and edit the path to the project path on your PC/Notebook

STATICFILES_DIRS = [
    "/path/to/project_folder/static",
    "/path/to/project_folder"
]

3. Database setup

The app make use of at least one database table, though, so we need to create the tables in the database before we can use them. To do that, run the following command:

$ python manage.py migrate

4. Creating an Admin User

We’ll need to create a user who can login to the admin site. Run the following command:

$ python manage.py createsuperuser

Enter your desired username and press enter.

Username: admin

You will then be prompted for your desired email address:

Email address: admin@example.com

The final step is to enter your password. You will be asked to enter your password twice, the second time as a confirmation of the first.

Password: **********
Password (again): *********
Superuser created successfully.

5. Start the development server

$ python manage.py runserver

References

https://docs.djangoproject.com/en/4.1/
https://www.tensorflow.org/tfx/serving/docker

About

Deep Learning Model Deployment with Django using TensorFlow Serving in conjunction with Docker to serve a REST API for inference.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published