Sun Bear

Easy Image Classification with TensorFlow

In this tutorial, we will train a simple classifier to classify image between sun bear and black dog. Open your Chrome browser and install Fatkun Batch Download Image. Google this keyword sun bear. Select Images and click Fatkun Batch Download Image icon on the right top. Select This tab and new windows will appear.

Fatkun Batch Download Image
Fatkun Batch Download Image

Unselect which images that not related to sun bear then click Save Image. Make sure minimum images that need to train is 75. Wait until all images finish the download. Copy all the images and place it into <your_working_space>tf_files > animals > images > sun bear. Repeat the same steps over and over again for these categories.

black dog

Download retrain script (https://raw.githubusercontent.com/datomnurdin/TensorFlow-CNN/master/retrain.py) to the current directory (<your_working_space>) . Go to the terminal/command line and cd to <your_working_space> directory. Run this command to retrain all the images. It takes around 30 minutes to finish.

python3 retrain.py 
--bottleneck_dir=tf_files/bottlenecks 
--model_dir=tf_files/inception 
--output_graph=tf_files/retrained_graph.pb 
--output_labels=tf_files/retrained_labels.txt 
--image_dir tf_files/animals/images

Predict the image using this script (https://raw.githubusercontent.com/datomnurdin/TensorFlow-CNN/master/detect.py) in the terminal/command line.

python3 detect.py 
--graph=tf_files/retrained_graph.pb 
--labels=tf_files/retrained_labels.txt 
--output_layer=final_result 
--image=test_image/sun_bear.jpeg 
--input_layer=Placeholder

Leave a Reply

Your email address will not be published. Required fields are marked *