Face++の感情推定APIを使いたい
MegviiのFace++を使い、ディレクトリ内の画像を読み込み感情推定のプログラムを書きたいです。
公式ページからgithubへ飛びダウンロードして使おうとしましたが、画像内から顔を検知するものしかなく
顔検知のプログラムに感情推定の結果も出力させるプログラムに変えたいと考えています。
# coding: utf-8
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
import requests
from config import API_KEY, API_SECRET, DETECT_PATH ,ANALYZE_PATH
from example.common import get_input_file_path
return_landmark = 0
return_attributes = None
#calculate_all = 0
face_rectangle = ''
beauty_score_min = 0
beauty_score_max = 100
def call_api():
    data = {
        'api_key': API_KEY,
        'api_secret': API_SECRET,
        'return_gesture': return_landmark,
        'return_attributes': return_attributes,
        #'calculate_all': calculate_all,
        'beauty_score_min': beauty_score_min,
        'beauty_score_max': beauty_score_max
    }
    if face_rectangle:
        data.update({'face_rectangle': face_rectangle})
    input_file = get_input_file_path(os.path.abspath(os.path.dirname(__file__)), 'input')
    if not input_file:
        print('请将input.png/input.jpg文件放在detect目录下')
        return
    files = {
        'image_file': open(input_file, 'rb').read()
    }
    resp = requests.post(DETECT_PATH, data=data, files=files).json()
    files2 = {
        'image_file': open(input_file, 'rb').read()
    }
    resp2 = requests.post(ANALYZE_PATH, data=data, files=files2).json()
    print(resp)
    print(resp2)
if __name__ == "__main__":
    call_api()
具体的にはコード内のfiles2やresp2の箇所を追加しました。
しかし、
{'request_id': '******************', 'time_used': 33, 'faces': [{'face_token': '****************', 'face_rectangle': {'top': 189, 'left': 100, 'width': 255, 'height': 255}}], 'image_id': '*******************:==', 'face_num': 1}
{'time_used': 21, 'error_message': 'VOID_REQUEST', 'request_id': '***********************:'}
というエラーが出てきてしまいます。
公式にはこのerror_message': 'VOID_REQUESTは
400    VOID_REQUEST Face analyze operation cannot be performed, when return_landmark=0, and return_attributes=none 
とあり、画像の顔を検知できていないのが原因なのかなと思ったのですが、画像もしっかりと指定しているつもりです。ネットにも解決法が乗っておらず詰まっています。
何か解決方法があれば教えていただきたいです。。
