4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

感情推定についてメモ

Posted at

感情推定技術についてのメモ。知り合いにヒアリングする前にちょっと検索してみた程度の情報。

User Localの感情推定使ってみた

UserLocalに顔のイメージを送ると、resultが返ってくる。
個人で遊ぶ分にはよさそう。推定アルゴやモデルを自分で作った後、ベンチマークとして比較する対象にはなるかも。

#!/usr/bin/env python
# coding: utf-8

# 依存ライブラリのインストールが必要です
# $ pip install requests

import requests
import json

image_path = '/path/to/image'
image =  open(image_path, 'rb').read()
url = "https://ai-api.userlocal.jp/face"
res = requests.post(url, files={"image_data": image})
data = json.loads(res.content)
result = data['result']
for r in result:
    print(f"""
    年齢: {r['age']}
    感情: {r['emotion']}
    性別: {r['gender']}
    顔の向き: {r['head_pose']}
    顔の位置: {r['location']}
    """)
      

↓こうなった↓

元画像 (実際はモザイク無しでやりました) 結果
image.png 年齢 : 37.19
感情 : happy
性別 : Male
顔の向き: {'pitch': -11.44, 'roll': -1.33, 'yaw': -23.23}
顔の位置: {'height': 151, 'width': 146, 'x1': 15, 'x2': 161, 'y1': 29, 'y2': 180}
image.png 年齢 : 19.83
感情 : surprise
性別 : Male
顔の向き: {'pitch': -3.04, 'roll': 7.61, 'yaw': -6.77}
顔の位置: {'height': 173, 'width': 134, 'x1': 16, 'x2': 150, 'y1': 7, 'y2': 180}

元画像の切り抜きはOpenCV顔検出の内容をもとに、Googleフォトの自分の画像から切り抜いて適当に持ってきた。
20代半ばから後半の人の写真だったが、推定された年齢はばらつきあり。その他、感情や顔の向き、位置についてはそれっぽい。

顔認識させて感情に合わせてリアクションさせたり、しゃべらせたりするBOT作ったりして遊べそう。怒りを検出したら「6秒我慢だ」ってGoogleHomeにしゃべらせるとか。

最近はもっと高精度でフリーの物もありそう。

情報メモ

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?