https://github.com/nature1995/image-classifiers-on-django-with-restapi-v2
A Keras deep learning image classifiers on Django server with REST API | Django 图片识别平台V2
https://github.com/nature1995/image-classifiers-on-django-with-restapi-v2
classifier-model django machine-learning web-application
Last synced: 3 months ago
JSON representation
A Keras deep learning image classifiers on Django server with REST API | Django 图片识别平台V2
- Host: GitHub
- URL: https://github.com/nature1995/image-classifiers-on-django-with-restapi-v2
- Owner: nature1995
- License: mit
- Created: 2019-11-24T00:03:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-04T20:11:00.000Z (over 5 years ago)
- Last Synced: 2025-01-30T10:14:55.724Z (8 months ago)
- Topics: classifier-model, django, machine-learning, web-application
- Language: Python
- Homepage:
- Size: 604 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Image-classifiers-on-Django-with-RESTAPI-V2
[]()
[]()
[]()
[]()## Table of Contents
- [Introduction](#introduction)
- [Description](#description)
- [Features](#features)
- [Architecture](#architecture)
- [Usage](#usage)
- [Results](#results)
- [Issue](#issue)
- [Others](#others)
- [License](#license)## Introduction
A Keras deep learning image classifiers on Django server with REST API. It can help you quickly deploy and apply ML models.## Description
Machine Learning (ML) models are typically trained and test on benchmark data sets. However, such data sets may not represent the data in real applications. These ML models should be updated after tested on real data sets. Deployment of the models after each update may be time consuming. Therefore, automated deployment is needed to save time and effort. In this proposal, we describe our solution to integrate trained ML models into any application of interest. We use Django web-based platform to build REST API for model deployment. Jenkins is used for continuous integration and automated deployment of ML models into Django servers.## Features
- [x] Add Account management funtion
- [x] Add Login & Signup
- [x] Add Django Rest Framework
- [x] Optimize front-end interface, adapt to mobile and PC interface
- [x] Design front-end and back-end interactive interfaces
- [x] Add feature: Image classify using following model:
- [x] ResNet50
- [x] Xception
- [x] MobileNet, MobileNetV2
- [x] InceptionV3, InceptionResNetV2
- [x] DenseNet121, DenseNet169, DenseNet201
- [x] VGG16, VGG19
- [x] NASNetMobile, NASNetLarge
- [x] Run each part of functions seperately in local and cloud server
- [x] Run all the functions in local server and cloud server
- [x] Design and using machine learning CI/CD Tools such as Git, Jenkins, Nginx, uwgsi for deployment.## Architecture
![]()
## Usage
I assume you already have your own local virtual environment.
```
git clone https://github.com/nature1995/image-classify-django-server.git
```
```
pip install -r requirements.txt
python manage.py makemigrations # Option
python manage.py migrate # Option
python manage.py collectstatic # Option
python manage.py runserver 0.0.0.0:8000
```
Access the web page though this link: http://127.0.0.1:8000/If you would like to use the [previous version](https://github.com/nature1995/AI-Image-classifiers-on-Django-with-RESTAPI). Here is the link.
### Docker
You can use `dockerfile` to build this project easily.
```sh
# Follow any instruction to install the docker-ce, docker for OS X or PC in your device
docker build -t ai_image_classifiers .
docker run -it --rm -p 8000:8000 --name ai_image_classifiers_app ai_image_classifiers:latest
```## Results
Name | Input Size| API address
--------- | ----------| ----------------------------------------------------
ResNet50 | 224x224 | http://127.0.0.1:8000/predict/api/
Xception | 299x299 | http://127.0.0.1:8000/predict_Xception/api/
MobileNet | 224x224 | http://127.0.0.1:8000/predict_MobileNet/api/
MobileNetV2 | 224x224 | http://127.0.0.1:8000/predict_MobileNetV2/api/
InceptionV3 | 299x299 | http://127.0.0.1:8000/predict_InceptionV3/api/
InceptionResNetV2 | 224x224 | http://127.0.0.1:8000/predict_InceptionResNetV2/api/
DenseNet121 | 224x224 | http://127.0.0.1:8000/predict_DenseNet121/api/
DenseNet169 | 224x224 | http://127.0.0.1:8000/predict_DenseNet169/api/
DenseNet201 | 224x224 | http://127.0.0.1:8000/predict_DenseNet201/api/
VGG16 | 224x224 | http://127.0.0.1:8000/predict_VGG16/api/
VGG19 | 224x224 | http://127.0.0.1:8000/predict_VGG19/api/
NASNetLarge | 331x331 | http://127.0.0.1:8000/predict_NASNetLarge/api/
NASNetMobile | 224x224 | http://127.0.0.1:8000/predict_NASNetMobile/api/#### Input
Parameter | Type | Description
--------- | ------------------------------ | -----------------------------------------------------------------------------------
image | file | Image file that you want to classify.
top | text
(optional, default=6) | Return top-k categories of the results. Must me string in integer format.Note: You can not send a very large size image.
#### Result
Parameter | Type | Description
------------ | ------------------- | --------------------------------------------
success | bool | Whether classification was sucessfuly or not
predictions | label, float | pair of label and it's probability#### Accuracy for individual models
Model | Accuracy | Top-6 Accuracy
------------------ | ------------ | --------------------
Xception | 0.780 | 0.955
VGG16 | 0.722 | 0.914
VGG19 | 0.723 | 0.910
ResNet50 | 0.748 | 0.931
InceptionV3 | 0.789 | 0.948
InceptionResNetV2 | 0.813 | 0.963
MobileNet | 0.714 | 0.904
MobileNetV2 | 0.723 | 0.912
DenseNet121 | 0.761 | 0.934
DenseNet169 | 0.772 | 0.952
DenseNet201 | 0.783 | 0.945
NASNetMobile | 0.752 | 0.920
NASNetLarge | 0.837 | 0.959#### Example
Using [Postman](https://www.getpostman.com/downloads/) to test the API:
POST http://127.0.0.1:8000/predict/api/**Result**
```
{
"success": true,
"predictions": [
{
"label": "red_fox",
"probability": 0.8969062566757202
},
{
"label": "kit_fox",
"probability": 0.08841043710708618
},
{
"label": "grey_fox",
"probability": 0.012036639265716076
},
{
"label": "Arctic_fox",
"probability": 0.0022438077721744776
},
{
"label": "coyote",
"probability": 0.0002566342300269753
},
{
"label": "white_wolf",
"probability": 0.00005685776341124438
}
]
}
```## Compatibility
Support to Django>=2.1.5 or Django==3.0.0 and Python 3.5, 3.6, 3.7.## Issue
If you have questions or issues, please feel free to tell us.## Contribution
Welcome to make pull request. If you have a related project/component/tool, add it with a pull request to add it!## Others
**Admin Account**
```
python manage.py createsuperuserusername: ranxiaolang
email: YOUR EMAIL
password: ranxiaolang
```
Access the web page though this link: http://127.0.0.1:8000/admin## Contributors
[@nature1995](http://ranxiaolang.com)
## License
[MIT](LICENSE) ©