Coder Social home page Coder Social logo

cscn89 / multilabel-classification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thatbrguy/multilabel-classification

0.0 1.0 0.0 1.02 MB

Repository containing code for the blog post titled "How To Easily Classify Food Using Deep Learning and Tensorflow"

Home Page: https://medium.com/nanonets/how-to-easily-classify-food-using-deep-learning-and-tensorflow-cbe9b1dc302c?source=friends_link&sk=b0ea286936a8be368b329ab5429857cf

Python 100.00%

multilabel-classification's Introduction

Multilabel-Classification

Repository containing Keras code for the blog post titled "How to Perform Multi Label Classification using Deep Learning". You can checkout the blog post here.

Multi Label Classification Samples

Using Keras

This section lists out the steps involved in training a Keras model (with TensorFlow backend) for Multi Label Classification.

Method 1: Google Colab

  • You can explore this notebook on Colab to directly experiment with training the models.

Method 2: Local Setup

Follow these steps to train and use a model for Multilabel Classification. You can also directly use a sample trained model (mobilenet.h5) without training, which can be downloaded from here (skip to Step 4 in that case).

Step 1: Clone the Repo

git clone https://github.com/thatbrguy/Multilabel-Classification.git
cd Multilabel-Classification

Step 2: Download the Dataset

  • Download data.tar.gz and place it in the current directory.
  • Extract the dataset using tar -xzvf data.tar.gz
  • Move the contents of ./data/keras/ to the current directory by using mv ./data/keras/* ./

Step 3: Train the Model

  • Run train.py --model ResNet50 to train the model.
  • The --model argument can take one among ResNet50, MobileNet, DenseNet121 or Xception.

Step 4: Inference

  • Run predict.py --image PATH_TO_FILE --saved_model PATH_TO_h5 to obtain a prediction once the model is trained.
  • PATH_TO_FILE refers to the path of the image.
  • PATH_TO_h5 refers to the path of the h5 file.

Using Nanonets

This section lists out the steps involved in training a Nanonets model for Multi Label Classification.

Step 1: Clone the Repo

git clone https://github.com/thatbrguy/Multilabel-Classification.git
cd Multilabel-Classification/nanonets

Step 2: Get your free API Key

Get your free API Key from http://app.nanonets.com/user/api_key

Step 3: Set the API key as an Environment Variable

export NANONETS_API_KEY=YOUR_API_KEY_GOES_HERE

Step 4: Create a New Model

python ./code/create_model.py

_Note: This generates a MODEL_ID that you need for the next step

Step 5: Add Model Id as Environment Variable

export NANONETS_MODEL_ID=YOUR_MODEL_ID

_Note: you will get YOUR_MODEL_ID from the previous step

Step 6: Upload the Training Data

  • Download data.tar.gz and place it in the current directory.
  • Extract the dataset using tar -xzvf data.tar.gz
  • Move the contents of ./data/nanonets/ to the current directory by using mv ./data/nanonets/* ./
  • Run python ./code/upload_training.py to upload the data.

Step 7: Train Model

Once the Images have been uploaded, begin training the Model

python ./code/train_model.py

Step 8: Get Model State

The model takes ~2 hours to train. You will get an email once the model is trained. In the meanwhile you check the state of the model

python ./code/model_state.py

Step 9: Make Prediction

Once the model is trained. You can make predictions using the model

python ./code/prediction.py PATH_TO_YOUR_IMAGE.jpg

Sample Usage:

python ./code/prediction.py ./multilabel_data/ImageSets/2_my_caesar_salad_hostedLargeUrl.jpg

References

  1. Recipes5k
  2. Nanonets

multilabel-classification's People

Contributors

thatbrguy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.