Image Recognition App is an image classification application using Django and PyTorch.
- OS: Windows10 Pro (It will probably also work with Linux, but has not been tested yet.)
- CPU only (not support GPU)
- Python 3.8
$ git clone https://github.com/noriho137/image-classifier.git
$ cd image-classifier/
$ python -m venv {venv_name}
$ {venv_name}/Scripts/activate.bat
({venv_name}) $ pip install -r requirements.txt
This application use pytorch pretrained model. For example, following models are available.
This model need class label definition imagenet_class_index.json
from
https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json .
Generate Django secret key by secrets.token_urlsafe
.
({venv_name})$ python -c "import secrets; print(secrets.token_urlsafe(38))"
Make .env
file at project root directory and define environment variables like following:
# Django settings
export DJANGO_SECRET_KEY={Django secret key generated above}
export DJANGO_DEBUG=True
# Classification model
export PRETRAINED_MODEL_NAME=vgg16
export PRETRAINED_MODEL_PATH=./pretrained/vgg16-397923af.pth
export CLASS_INDEX=./pretrained/imagenet_class_index.json
export MAX_RANK=5
({venv_name})$ python manage.py migrate
({venv_name})$ python manage.py runserver
Browse to http://127.0.0.1:8000/ .