Saturday, January 28, 2017

Bicycle Threat or Treat Image Classification Using TensorFlow and Inception


.996 Bike Threat

The result of my experiment #3 in Machine Learning (ML) using TensorFlow was, according to rule #1, success, because I had fun, learned something, and the code ran. Beyond that, I was surprised at how good the program was at classifying images as either "bicycle threat" or "bicycle treat".

.997 Bike Treat

I've been diving into ML for the past couple of weeks, so my experiments are getting easier to setup and run. For this one, I picked over 100 images from this blog that said "bicycle threat" to me, pictures of onrushing cars, crashes, construction, bad road conditions, etc, and another 100+ images that said "bicycle treat," like flowers, art, pretty girls on bikes, cups of coffee, and peaceful open roads, and put them into folders labelled appropriately. Then I downloaded sample python code for retraining Google's deep learning model, inception-v3 on my images, goofed around with it until it was running the way I wanted it to, and let her rip.

Inception v3 looks like this, I'm told

After retraining the deep learning model to grok bike threats and treats, I got to try it out on random images to see what it came up with. After I tried out the images above and got the categorization I hoped for, I was giddy with ML power! I started trying random pix from various search engine image searches, and overall was happy with the results. Lone bike riders almost always score as treats. Ditto open roads and pictures of trees. Head-on photos of cars, large groups of cars, and nasty traffic jams, almost always got classified >95% as bike threats. All examples of Robert Indiana's "LOVE" sculpture that I tried rated very high as bike treats. Coffee and hot dogs also are solidly in the treat category. Girls on bikes scored strongly and consistently as treats. Most lone guys on bikes did, too.

Not everything was a screaming success, however. I took some low-rez screen grabs from this post that has a clip I shot of one of my more threatening encounters on the road, imagining results that I might get if I had enough hardware and the right software running on the back of my bicycle to alert me of what was about to happen. 

The first one scored high as a .997 threat. The second one, taken just before the actual close pass, got a more ambiguous .69 threat rating. The third one, taken just moments before #2, got a much stronger .93 threat rating. When I do this again, I will think more about close passes and real traffic situations, which I had a limited supply of photos of for this first experiment.

What's next for OSGIML? More image classification, I bet. First, more playing around with this experiment, to see what else I can learn. 

Add to backlog: the follower-drone should provide data to enhance threat detection, and to attract to bicycle treats on or near the intended navigation route. 

.997 Bike Threat

.692 Bike Threat (doh!)

.93 Bike Threat (yay!)
    
ADDENDUM: Saturday afternoon shots

bikethreat (score = 0.96360)
bikethreat (score = 0.99636)
  
biketreat (score = 0.54084) (confusing shadow is confusing)


bikethreat (score = 0.91335)

No comments:

Post a Comment

Please feel free to comment here, almost anything goes, except for obvious spam or blatantly illegal or objectionable material. Spammers may be subject to public ridicule, scorn, or outright shaming, and the companies represented in spam shall earn disrepute and ire for each occurrence.