Giter Club home page Giter Club logo

multi-label-inception-net's Introduction

Multi-label-Inception-net

Modified retrain.py script to allow multi-label image classification using pretrained Inception net.

The label_image.py has also been slightly modified to write out the resulting class percentages into results.txt.

Detailed explanation of all the changes and reasons behind them: https://medium.com/@bartyrad/multi-label-image-classification-with-inception-net-cbb2ee538e30

Works on:

TensorFlow 1.8.0 - use branch master

or

TensorFlow 1.1.0 - use branch tensorflow_1.0 - thanks moh3th1

All the training images must be in JPEG format.

Usage

Update

This version has been update to solve possible problems with calculating evaluation accuracies.

Usage change: Put all the training images in one folder and create a file labels.txt inside project root containing all the possible labels.

Prepare training images

  1. Put all the training images into one folder inside images directory.

    The name of the folder does not matter. I use multi-label.

Prepare labels for each training image

  1. We need to prepare files with correct labels for each image. Name the files <image_file_name.jpg>.txt = if you have an image car.jpg the accompanying file will be car.jpg.txt.

    Put each true label on a new line inside the file, nothing else.

    Now copy all the created files into the image_labels_dir directory located in project root. You can change the path to this folder by editing global variable IMAGE_LABELS_DIR in retrain.py

  2. Create file labels.txt in project root and fill it with all the possible labels. Each label on a new line, nothing else. Just like an image_label file for an image that is in all the possible classes.

Retraining the model

Simply run the appropriate command from retrain.sh. Feel free to play with the parameters.

Disclaimer: If you try to retrain the model with just the single example image car.jpg, it is going to crash. Include at least 20 images in folder inside images directory.

Testing resulting model

Run: python label_image.py <image_name> from project root.

Visualize training progress

After the retraining is done you can view the logs by running:

tensorboard --logdir retrain_logs

and navigating to http://127.0.0.1:6006/ in your browser.

Additional info

If you want to try the original Inception net retraining, here is an excellent CodeLab: https://codelabs.developers.google.com/codelabs/tensorflow-for-poets

License

Apache License, Version 2.0

multi-label-inception-net's People

Contributors

bartyzalradek avatar eyaler avatar moustafa-elgammal 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.