週刊SleepNel新聞

SleepNel所属のぽうひろが日々の個人開発で気になったことを綴ります。

【GCP】CLOUD VISION APIで遊んでみた

こんにちは、ぽうひろです。
f:id:pouhiroshi:20160727174336p:plain

昨日のブログでCloud Natural Language APIでテキスト分析して遊んでみました。
sleepnel.hatenablog.com

今回はふと目に止まったCLOUD VISION APIで遊んでみようと思います。
cloud.google.com

Google Cloud Vision API は、強力な機械学習モデルの能力を活用することで、画像の内容を認識し理解できるアプリケーションの開発を可能にします。Cloud Vision API は、画像を数千のカテゴリ(たとえば、「ヨット」「ライオン」「エッフェル塔」など)にすばやく分類する機能や、画像に映る個々の物体や人物の顔を解析する機能、画像に含まれる活字体の文字を認識して読み取る OCR 機能などを提供します。 この Cloud Vision API により、アプリケーションで扱う多数の画像のタグ付け、不適切な画像の検出、画像の意味の分析に基づく新しいマーケティング手法への応用が可能です。画像はリクエストの中に含めてアップロードすることで分析し、また Google Cloud Storage 上の画像ストレージとの連携も可能です。

だそうです。

例によってAPI試せるのでやってみましょう。
f:id:pouhiroshi:20160727174610p:plain

試しにDodgeWarsのキャラ画像を認識させてみます。
f:id:pouhiroshi:20160727174724p:plain
ピエロ、とか出てきてほしかったんですが、そこまでは無理だったようです。。。w
illustrationとかclip artとLabel情報に出ていますね。イラストっていう認識をされているようです。
間違ってはいない。

[
  {
    "mid": "/m/03gq5hm",
    "description": "font",
    "score": 0.84652269
  },
  {
    "mid": "/m/01kr8f",
    "description": "illustration",
    "score": 0.68979561
  },
  {
    "mid": "/m/03g09t",
    "description": "clip art",
    "score": 0.59586734
  }
]

次にうちの末っ子(もうすぐ1歳)の写真をあげてみますw
f:id:pouhiroshi:20160727174920p:plain
なんかいろいろ出てきましたね・・!!
FACE情報

[
  {
    "boundingPoly": {
      "vertices": [
        {
          "y": 258
        },
        {
          "x": 894,
          "y": 258
        },
        {
          "x": 894,
          "y": 1295
        },
        {
          "y": 1295
        }
      ]
    },
    "fdBoundingPoly": {
      "vertices": [
        {
          "x": 48,
          "y": 515
        },
        {
          "x": 857,
          "y": 515
        },
        {
          "x": 857,
          "y": 1295
        },
        {
          "x": 48,
          "y": 1295
        }
      ]
    },
    "landmarks": [
      {
        "type": "LEFT_EYE",
        "position": {
          "x": 314.28384,
          "y": 788.8468,
          "z": -0.0059166546
        }
      },
      {
        "type": "RIGHT_EYE",
        "position": {
          "x": 619.61072,
          "y": 792.52539,
          "z": 93.52301
        }
      },
      {
        "type": "LEFT_OF_LEFT_EYEBROW",
        "position": {
          "x": 208.21742,
          "y": 698.67,
          "z": 3.91687
        }
      },
      {
        "type": "RIGHT_OF_LEFT_EYEBROW",
        "position": {
          "x": 421.52054,
          "y": 708.293,
          "z": -29.56905
        }
      },
      {
        "type": "LEFT_OF_RIGHT_EYEBROW",
        "position": {
          "x": 563.36108,
          "y": 721.98431,
          "z": 15.251351
        }
      },
      {
        "type": "RIGHT_OF_RIGHT_EYEBROW",
        "position": {
          "x": 711.57275,
          "y": 727.91571,
          "z": 154.6956
        }
      },
      {
        "type": "MIDPOINT_BETWEEN_EYES",
        "position": {
          "x": 491.2402,
          "y": 774.16809,
          "z": -14.780352
        }
      },
      {
        "type": "NOSE_TIP",
        "position": {
          "x": 508.22357,
          "y": 943.19672,
          "z": -108.5713
        }
      },
      {
        "type": "UPPER_LIP",
        "position": {
          "x": 484.1955,
          "y": 1068.3713,
          "z": -45.351719
        }
      },
      {
        "type": "LOWER_LIP",
        "position": {
          "x": 473.94003,
          "y": 1175.0566,
          "z": -28.399323
        }
      },
      {
        "type": "MOUTH_LEFT",
        "position": {
          "x": 349.90454,
          "y": 1113.4746,
          "z": -4.6009936
        }
      },
      {
        "type": "MOUTH_RIGHT",
        "position": {
          "x": 564.08331,
          "y": 1121.3193,
          "z": 65.4063
        }
      },
      {
        "type": "MOUTH_CENTER",
        "position": {
          "x": 476.62619,
          "y": 1118.8035,
          "z": -25.320593
        }
      },
      {
        "type": "NOSE_BOTTOM_RIGHT",
        "position": {
          "x": 558.87115,
          "y": 974.49622,
          "z": 29.82102
        }
      },
      {
        "type": "NOSE_BOTTOM_LEFT",
        "position": {
          "x": 397.32584,
          "y": 976.95081,
          "z": -21.705008
        }
      },
      {
        "type": "NOSE_BOTTOM_CENTER",
        "position": {
          "x": 487.02463,
          "y": 993.93097,
          "z": -43.478149
        }
      },
      {
        "type": "LEFT_EYE_TOP_BOUNDARY",
        "position": {
          "x": 327.85626,
          "y": 759.35986,
          "z": -17.517155
        }
      },
      {
        "type": "LEFT_EYE_RIGHT_CORNER",
        "position": {
          "x": 375.17612,
          "y": 794.08661,
          "z": 20.65461
        }
      },
      {
        "type": "LEFT_EYE_BOTTOM_BOUNDARY",
        "position": {
          "x": 311.2406,
          "y": 811.48352,
          "z": -2.3298914
        }
      },
      {
        "type": "LEFT_EYE_LEFT_CORNER",
        "position": {
          "x": 243.57178,
          "y": 778.18604,
          "z": 11.951305
        }
      },
      {
        "type": "LEFT_EYE_PUPIL",
        "position": {
          "x": 318.89737,
          "y": 780.96814,
          "z": -7.3270526
        }
      },
      {
        "type": "RIGHT_EYE_TOP_BOUNDARY",
        "position": {
          "x": 625.19751,
          "y": 773.99121,
          "z": 73.974518
        }
      },
      {
        "type": "RIGHT_EYE_RIGHT_CORNER",
        "position": {
          "x": 672.71094,
          "y": 797.2027,
          "z": 140.00291
        }
      },
      {
        "type": "RIGHT_EYE_BOTTOM_BOUNDARY",
        "position": {
          "x": 625.14435,
          "y": 818.0564,
          "z": 90.418045
        }
      },
      {
        "type": "RIGHT_EYE_LEFT_CORNER",
        "position": {
          "x": 570.04742,
          "y": 798.66461,
          "z": 77.657234
        }
      },
      {
        "type": "RIGHT_EYE_PUPIL",
        "position": {
          "x": 623.7821,
          "y": 795.80316,
          "z": 86.298439
        }
      },
      {
        "type": "LEFT_EYEBROW_UPPER_MIDPOINT",
        "position": {
          "x": 323.34277,
          "y": 667.1438,
          "z": -31.980959
        }
      },
      {
        "type": "RIGHT_EYEBROW_UPPER_MIDPOINT",
        "position": {
          "x": 645.37909,
          "y": 683.51624,
          "z": 67.07476
        }
      },
      {
        "type": "LEFT_EAR_TRAGION",
        "position": {
          "x": 13.681578,
          "y": 936.37805,
          "z": 303.45032
        }
      },
      {
        "type": "RIGHT_EAR_TRAGION",
        "position": {
          "x": 688.24921,
          "y": 969.60583,
          "z": 511.02182
        }
      },
      {
        "type": "FOREHEAD_GLABELLA",
        "position": {
          "x": 494.04657,
          "y": 707.70215,
          "z": -18.365887
        }
      },
      {
        "type": "CHIN_GNATHION",
        "position": {
          "x": 455.87216,
          "y": 1315.4849,
          "z": 7.2876577
        }
      },
      {
        "type": "CHIN_LEFT_GONION",
        "position": {
          "x": 76.758453,
          "y": 1132.1384,
          "z": 183.73344
        }
      },
      {
        "type": "CHIN_RIGHT_GONION",
        "position": {
          "x": 685.78955,
          "y": 1162.2795,
          "z": 371.23984
        }
      }
    ],
    "rollAngle": 2.0301774,
    "panAngle": 17.108698,
    "tiltAngle": 2.614301,
    "detectionConfidence": 0.88455212,
    "landmarkingConfidence": 0.73992616,
    "joyLikelihood": "VERY_UNLIKELY",
    "sorrowLikelihood": "VERY_UNLIKELY",
    "angerLikelihood": "VERY_UNLIKELY",
    "surpriseLikelihood": "VERY_UNLIKELY",
    "underExposedLikelihood": "VERY_UNLIKELY",
    "blurredLikelihood": "VERY_UNLIKELY",
    "headwearLikelihood": "VERY_UNLIKELY"
  }
]

目、まつげ、眉毛の位置なんかも認識しているっぽい!!!

Label情報

[
  {
    "mid": "/m/0ytgt",
    "description": "child",
    "score": 0.96999037
  },
  {
    "mid": "/m/03q69",
    "description": "hair",
    "score": 0.954033
  },
  {
    "mid": "/m/01g317",
    "description": "person",
    "score": 0.95113987
  },
  {
    "mid": "/m/0ds4x",
    "description": "hairstyle",
    "score": 0.922476
  },
  {
    "mid": "/m/0k0pj",
    "description": "nose",
    "score": 0.90501469
  },
  {
    "mid": "/m/01k74n",
    "description": "facial expression",
    "score": 0.874115
  },
  {
    "mid": "/m/01bgsw",
    "description": "toddler",
    "score": 0.8307305
  },
  {
    "mid": "/m/025kyy",
    "description": "forehead",
    "score": 0.82941687
  },
  {
    "mid": "/m/0jnvp",
    "description": "infant",
    "score": 0.78591734
  },
  {
    "mid": "/m/05zppz",
    "description": "male",
    "score": 0.7806254
  },
  {
    "mid": "/m/01bl7v",
    "description": "boy",
    "score": 0.75746793
  },
  {
    "mid": "/m/09g5pq",
    "description": "people",
    "score": 0.69341111
  },
  {
    "mid": "/m/04hgtk",
    "description": "head",
    "score": 0.6769352
  },
  {
    "mid": "/m/02tjx",
    "description": "emotion",
    "score": 0.66221946
  },
  {
    "mid": "/m/0gjxqj",
    "description": "bangs",
    "score": 0.64250284
  },
  {
    "mid": "/m/0138tl",
    "description": "toy",
    "score": 0.58303756
  },
  {
    "mid": "/m/03_03q",
    "description": "bowl cut",
    "score": 0.54545456
  },
  {
    "mid": "/m/039xj_",
    "description": "ear",
    "score": 0.50769472
  }
]

ラベル情報は、boyとかchildとか、面白いのでbowl cut(髪型かな?)なんかも出ている!すごい!

SafeSearch

{
  "adult": "VERY_UNLIKELY",
  "spoof": "UNLIKELY",
  "medical": "VERY_UNLIKELY",
  "violence": "UNLIKELY"
}

SafeSearchはアダルト コンテンツから暴力コンテンツまで各種の不適切なコンテンツの検知が可能とのことです。
便利な世の中ですねぇ。。。。いろいろ自動化で使える場面がありそうですね。


今日はCLOUD VISION APIをご紹介しました。

それではまた!!