TensorFlow를 설치하여 Pepper의 이미지를 인식했습니다.

소개


  • 요 전날, 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




    $ 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)
    
  • soap dispenser

  • Pepper 2




    $ 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)
    
  • electrical switch

  • Pepper 3




    $ 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)
    

    나오




    $ 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




    $ 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




    $ 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에서는 분류되어 있지 않기 때문에, 이상한 대답이 나올 것을 기대하고 있었지만, 그다지 재미있지 않았다.
  • 우선은 이것을 학습시켜 본다는 것은 적당한 과제가 되는가.
  • 좋은 웹페이지 즐겨찾기