Help us understand the problem. What is going on with this article?

TensorFlow をインストールして、Pepper の画像を認識させてみた

More than 3 years have passed since last update.

はじめに

  • 先日、TensorFlow勉強会(2)に行ってきたのですが、画像認識の話のところで、Pepper はどう認識されるのだろう?と思い、試してみました。

インストール

TensorFlow のインストール

$ brew install bazel swig
$ sudo easy_install -U six
$ sudo easy_install -U numpy
$ sudo easy_install wheel
$ sudo easy_install ipython

$ git clone -b v0.6.0 --recurse-submodules https://github.com/tensorflow/tensorflow.git
$ cd tensorflow
$ ./configure
$ bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
$ sudo pip install /tmp/tensorflow_pkg/tensorflow-0.6.0-py2-none-any.whl

インストール後の動作確認

$ python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 12:54:16)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant("Hello, TensorFlow!")
>>> sess = tf.Session()
I tensorflow/core/common_runtime/local_device.cc:40] Local device intra op parallelism threads: 4
I tensorflow/core/common_runtime/direct_session.cc:58] Direct session inter op parallelism threads: 4
>>> print(sess.run(hello))
Hello, TensorFlow!

>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42

画像認識を試す

パンダ (サンプル)

$ python classify_image.py
I tensorflow/core/common_runtime/local_device.cc:40] Local device intra op parallelism threads: 4
I tensorflow/core/common_runtime/direct_session.cc:58] Direct session inter op parallelism threads: 4
giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca (score = 0.89233)
indri, indris, Indri indri, Indri brevicaudatus (score = 0.00859)
lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens (score = 0.00264)
custard apple (score = 0.00141)
earthstar (score = 0.00107)

Pepper その1

pepper1ss.jpg

$ python classify_image.py --image_file pepper1ss.jpg
soap dispenser (score = 0.26181)
sewing machine (score = 0.08305)
digital clock (score = 0.07441)
hand blower, blow dryer, blow drier, hair dryer, hair drier (score = 0.04593)
piggy bank, penny bank (score = 0.02755)

Pepper その2

pepper3s.jpg

$ python classify_image.py --image_file pepper3s.jpg
switch, electric switch, electrical switch (score = 0.51433)
soap dispenser (score = 0.11694)
stopwatch, stop watch (score = 0.11000)
hook, claw (score = 0.02720)
corkscrew, bottle screw (score = 0.01832)

Pepper その3

pepper4s.jpg

$ python classify_image.py --image_file pepper4s.jpg
soap dispenser (score = 0.13773)
mask (score = 0.13569)
joystick (score = 0.09575)
piggy bank, penny bank (score = 0.07548)
pencil sharpener (score = 0.02219)

Nao

nao1s.jpg

$ python classify_image.py --image_file nao1s.jpg
toyshop (score = 0.09573)
knee pad (score = 0.04186)
digital watch (score = 0.04072)
pill bottle (score = 0.03983)
soap dispenser (score = 0.02415)

Romeo

romeo2.jpg

$ python classify_image.py --image_file romeo2.jpg
breastplate, aegis, egis (score = 0.25803)
knee pad (score = 0.08682)
toyshop (score = 0.07168)
comic book (score = 0.06568)
cuirass (score = 0.04174)

Pepper その4

pepper-07s.jpg

$ python classify_image.py --image_file pepper-07s.jpg
bell pepper (score = 0.98801)
pencil sharpener (score = 0.00038)
cucumber, cuke (score = 0.00017)
stove (score = 0.00017)
Granny Smith (score = 0.00016)

これはすばらしい。

感想

  • ImageNet では分類されていないだろうから、変な答えが出ることを期待していたのだけど、あまり面白くはならなかったな。
  • まずはこれを学習させてみる、というのは手頃な課題になるか。
Suna
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away