Close

Simple demo code for taking a photo with Raspberry Pi and classifying it using InceptionV3 graph

A project log for Elephant AI

a system to prevent human-elephant conflict by detecting elephants using machine vision, and warning humans and/or repelling elephants

neil-k-sheridanNeil K. Sheridan 10/28/2017 at 12:160 Comments

Here we can take an image with the Pi camera, and send it to label_image.py.  We went over using label_image.py in this log https://hackaday.io/project/20448-elephant-ai/log/69744-video-demo-of-elephant-detection-using-a-raspberry-pi . This will classify the image using InceptionV3 model graph and labels files. You can download a graph file for InceptionV3 here -> https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz

import time
import picamera
import os

camera = picamera.PiCamera()


print("Capture an image")
camera.start_preview()
time.sleep(1)
camera.capture('image1.jpg')
camera.stop_preview()
time.sleep(1)
print("Send it to label_image.py")
os.system('python label_image.py --image=image1.jpg --graph=inception_v3_2016_08_28_frozen.pb --labels=labels_incep.txt')
print("All done!")

Here I ran it whilst pointing the Pi camera at a a banana! And yes, as you can see, it was classified as a banana!

Our apple, however, resulted in some confusion!

Discussions