PaddlePaddle(飛槳)一鍵部署face_landmark_localization模型
face_landmark_localization模型啓動
config.json
可以看到裏面包含兩個模型,face_landmark_localization deeplabv3p_xception65_humanseg
{
"modules_info": {
"face_landmark_localization": {
"init_args": {
"version": "1.0.2"
},
"predict_args": {
"batch_size": 1,
"use_gpu": false
}
},
"deeplabv3p_xception65_humanseg": {
"init_args": {
"version": "1.0.0"
},
"predict_args": {
"batch_size": 1,
"use_gpu": false
}
}
},
"port": 8866,
"use_multiprocess": false,
"workers": 2
}
一鍵部署服務啓動
hub serving start --config config.json
調用一鍵部署服務
url = "http://127.0.0.1:8866/predict/face_landmark_localization"
data = {'images': [cv2_to_base64(cv2.imread(source_img_path))]}
headers = {"Content-type": "application/json"}
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# 打印預測結果
result = r.json()["results"]
data = result[0]['data'][0]
face_landmark = np.array(data, dtype='int')
感言
debug一陣子,就明白了,知道接口什麼樣了。。。
有時候看文檔,不自己動手,是會有點問題。