Matt Farley
Published © GPL3+

Use Artificial Intelligence to Detect Messy/Clean Rooms!

This project uses artificial intelligence (deep learning) to detect when rooms in the house are messy or clean (via cameras & TensorFlow).

BeginnerFull instructions provided1 hour5,443
Use Artificial Intelligence to Detect Messy/Clean Rooms!

Things used in this project

Hardware components

Camera (generic)
×1

Software apps and online services

TensorFlow
TensorFlow

Story

Read more

Code

Code snippet #5

Plain text
$ sudo apt install python-pip
$ pip install "tensorflow>=1.7.0" --user
$ pip install "tensorflow-hub" --user
$ mkdir ~/tensorflow
$ cd ~/tensorflow
$ curl -LO https://github.com/tensorflow/tensorflow/raw/master/tensorflow/examples/label_image/label_image.py
$ curl -LO https://github.com/tensorflow/hub/raw/r0.1/examples/image_retraining/retrain.py

Code snippet #6

Plain text
$ sudo apt install python-pip
$ pip install "tensorflow>=1.7.0" --user
$ pip install "tensorflow-hub" --user
$ mkdir ~/tensorflow
$ cd ~/tensorflow
$ curl -LO https://github.com/tensorflow/tensorflow/raw/master/tensorflow/examples/label_image/label_image.py
$ curl -LO https://github.com/tensorflow/hub/raw/r0.1/examples/image_retraining/retrain.py

Code snippet #7

Plain text
$ cd ~/tensorflow
$ python retrain.py \
    --image_dir /path/to/files/room \
    --output_graph=rooms.pb \
    --output_labels=rooms.txt
    --tfhub_module https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1

Code snippet #8

Plain text
$ cd ~/tensorflow
$ python retrain.py \
    --image_dir /path/to/files/room \
    --output_graph=rooms.pb \
    --output_labels=rooms.txt
    --tfhub_module https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1

Code snippet #9

Plain text
$ cd ~/tensorflow
$ python label_image.py \
    --graph=rooms.pb \
    --labels=rooms.txt \
    --input_layer=Placeholder \
    --output_layer=final_result \
    --image=/path/to/new_image.jpg

Code snippet #10

Plain text
$ cd ~/tensorflow
$ python label_image.py \
    --graph=rooms.pb \
    --labels=rooms.txt \
    --input_layer=Placeholder \
    --output_layer=final_result \
    --image=/path/to/new_image.jpg

Code snippet #13

Plain text
basketball 0.99071
soccerball 0.00595
baseball 0.00252
rugby_ball 0.00049
volleyball 0.00032

Code snippet #14

Plain text
basketball 0.99071
soccerball 0.00595
baseball 0.00252
rugby_ball 0.00049
volleyball 0.00032

Code snippet #15

Plain text
{ python label_image.py \
  --graph=$MODEL.pb \
  --labels=$MODEL.txt \
  --input_layer=Placeholder \
  --output_layer=final_result \
  --image=$TMP_IMAGE; } 2>&1 \
   | grep "clean" | cut -d ' ' -f2 | awk '{printf "%.0f\n", $1*100}'

Code snippet #16

Plain text
{ python label_image.py \
  --graph=$MODEL.pb \
  --labels=$MODEL.txt \
  --input_layer=Placeholder \
  --output_layer=final_result \
  --image=$TMP_IMAGE; } 2>&1 \
   | grep "clean" | cut -d ' ' -f2 | awk '{printf "%.0f\n", $1*100}'

Credits

Matt Farley

Matt Farley

2 projects • 46 followers
Learned to code before I could read and never stopped! (but I did learn to read)

Comments