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
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:
- Install Docker (link to download : https://docs.docker.com/desktop/install/windows-install/)
- Install wsl2 (link to download : https://docs.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package)
- Run Docker
- Open terminal / cmd and type :
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
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"
]
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
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.
$ python manage.py runserver
https://docs.djangoproject.com/en/4.1/
https://www.tensorflow.org/tfx/serving/docker