retrain.py script to allow multi-label image classification using pretrained Inception net.
label_image.py has also been slightly modified to write out the resulting class percentages into
Detailed explanation of all the changes and reasons behind them: https://medium.com/@bartyrad/multi-label-image-classification-with-inception-net-cbb2ee538e30
TensorFlow 1.8.0 - use branch
All the training images must be in JPEG format.
This version has been update to solve possible problems with calculating evaluation accuracies.
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
Put all the training images into one folder inside
The name of the folder does not matter. I use
Prepare labels for each training image
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.jpgthe accompanying file will be
Put each true label on a new line inside the file, nothing else.
Now copy all the created files into the
image_labels_dirdirectory located in project root. You can change the path to this folder by editing global variable IMAGE_LABELS_DIR in
labels.txtin project root and fill it with all the possible labels. Each label on a new line, nothing else. Just like an
image_labelfile for an image that is in all the possible classes.
Retraining the model
Simply run the appropriate command from
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
Testing resulting model
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.
If you want to try the original Inception net retraining, here is an excellent CodeLab: https://codelabs.developers.google.com/codelabs/tensorflow-for-poets
Apache License, Version 2.0