/tensorflow-animals

TensorFlow-Based Image Classifier for Animal Recognition

Primary LanguagePythonMIT LicenseMIT

Animals Image Classifier

The repository is inspired by YouTube video Build a TensorFlow Image Classifier in 5 Min with CodeLab instructions.

Currently supports 4 type of animals: cat, dog, monkey, squirrel.

Run Docker container image (and link TensorFlow docker image to dataset folder)

When starting docker container on Mac, bind the volumn /tf_files:

$ docker run -it -v $HOME/tf_files:/tf_files gcr.io/tensorflow/tensorflow:latest-devel

Retrain the Model (Run TensorFlow training script)

Make sure the that the images has been labeled (categorized into different folders with the folder names as labels) Like the following:

tf_files
|--animals
    |--cat
    |--dog
    |--monkey
    |--squirrel

In docker container command line, in /tensorflow directory run the following command:

$ python tensorflow/examples/image_retraining/retrain.py \
--bottleneck_dir=/tf_files/bottlenecks \
--how_many_training_steps 500 \
--model_dir=/tf_files/inception \
--output_graph=/tf_files/retrained_graph.pb \
--output_labels=/tf_files/retrained_labels.txt \
--image_dir /tf_files/animals

Final Accuracy

final_accuracy.jpg

Test the Labelling

Put test images in /tf_files/test/ folder, then in docker command line, use the follow command:

$ python /tf_files/label_image.py /tf_files/test/basque-shepherd-dog.jpg

"basque-shepherd-dog.jpg" is the file name of image

Test Results

Test Image

basque-shepherd-dog.jpg

Screenshot of Result

Shepherd Dog Classification Result

Test Image

cat-and-dog.jpg

Screenshot of Result

Shepherd Dog Classification Result

Reference