Skip to content

Custom Image classification API built with TensorFlow and served with Flask

License

Notifications You must be signed in to change notification settings

siddheshgunjal/TF-Image-Classifier-API

Repository files navigation

Custom Image Classification API

This is a Custom Image Classification API built from scratch. The Custom Neural network is built with TensorFlow v1.

Don't forget to ⭐ this repo!

Table of Contents 📓

Installation ⬇️

  • Use this command to clone this repository: https://github.com/siddheshgunjal/TF-Image-Classifier-API.git
  • Create environment with your environ management tool, Virtualenv or Conda
  • Install packages with pip using pip install -r requirements.txt

Usage ⚙️

Download training images for your task

To download training images for your classes you can utilise the python script from this gist. Procedure to use it is as below:

  • Download chrome driver for your system from this link: chromedriver
  • Open python script and add path to chromedriver at line 11 or just uncomment the path for already included chromedriver for linux/windows.
  • Run scrapper with python img_scrapper.py in terminal.
  • Enter the search term (For example: Tiger)
  • Enter the number of images to download (For example: 50)
  • The script will then launch Google Chrome and start scrapping process. Wait till the scrapping process is complete.
  • You can find the all the scrapped images in ./Data/Train_data/search_term
  • You can download as many images as you want for as many classes.

Train Neural Network

  • Put all your training data with folder for each class in ./Data/Train_data/class_name
  • Start training with python train.py. Default epochs to train are set to 100. you can change it as per your need from line 48 in train.py
  • You can also visualize training progress with tensorboard using tensorboard --logdir Checkpoints/logs
  • After training finishes, you'll get 2 files
    • model.json: Neural Network architecture
    • weights.h5: Updated weights of neural network after training

Run Prediction from browser

1. Run application with Flask's in-built server:

Use python app.py in terminal. This will start our application at localhost:8188

OR

2. Run application with Gunicorn server:

Use gunicorn -b :8188 -c gunicorn.conf.py app:app in terminal. This will start our application at localhost:8188

Visit this URL in browser and you should see the message, Image Classification API is running. This verifies that our API is running at server side. Go to localhost:8188/classification for prediction task: classification page Drag your image in the drop zone or upload it and click Run Prediction, which will then run the prediction and show you the result with below screen: classification-result page classification-result page

Your Custom Image classification API is ready!

Deploy on AWS with Docker 🚀

Please Refer AWS docker setup guide to deploy this application on AWS EC2 instance with docker.

Support ✨

If you get stuck, we’re here to help. The following are the best ways to get assistance working through your issue:

  • Use our Github Issue Tracker for reporting bugs or requesting features. Contribution are the best way to keep this repo amazing 💪
  • If you want to contribute please refer Contributor's Guide for how to contribute in a helpful and collaborative way 😇

Author 😎

Siddhesh Gunjal

About

Custom Image classification API built with TensorFlow and served with Flask

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published