Garbage image classification using PyTorch transfer learning pretrained model Resnet152 with FastAPI for API based application. This model will classification 6 class: cardboard, glass, metal, paper, plastic, trash (other).
$ git clone https://github.com/hafidh561/Garbage-Image-Classification.git
# Python version 3.6
$ git clone https://github.com/nodefluxio/vortex.git
$ cd vortex/ && git checkout drop-enforce
$ pip install ./src/runtime[onnxruntime] && cd ../
$ pip install -r requirements.txt
$ python download_model.py
# Newest docker version
$ docker build -t hafidh561/garbage-image-classification:1.0 .
$ python app.py
$ docker run --rm -p <YOUR PORT>:6969 hafidh561/garbage-image-classification:1.0
# Example
$ docker run --rm -p 301:6969 hafidh561/garbage-image-classification:1.0
-
After you run app use python or docker, open your web browser and go to
http://localhost:<YOUR PORT | 6969>/docs
for looking some documentation. -
Now it's time to testing API, open your application for testing API. I'll use Postman for testing API.
-
Set up postman like this.
-
Press button "Select Files" to select image you want to classification.
-
Press "Send" button and waiting for response.
-
Now open response body and look object response member class and search for highest value.
{
"filename": "glass.jpg",
"contentype": "image/jpeg",
"class": "glass",
"confidence": "0.99995697"
}
If you want make your own deep learning for image classification? Give it a try in this Google Colab
© Developed by hafidh561 - Internship at Nodeflux