python呼叫百度人臉識別 來一次顏值評分

2021-10-23 01:59:33 字數 1915 閱讀 8803

找到換取token的**,將其寫出函式形式

def

gettoken()

: host =

''response = requests.get(host)

if response:

return response.json()[

'access_token'

]

主體呼叫函式:

import requests

'''人臉檢測與屬性分析

'''request_url =

""params =

""access_token =

'[呼叫鑑權介面獲取的token]'

request_url = request_url +

"?access_token="

+ access_token

headers =

response = requests.post(request_url, data=params, headers=headers)

if response:

print

(response.json(

))

這是官方源**,稍作修改讓他可以顯示我當前打分的**成績就夠了,其他的引數暫時不需要

,**的質量清晰度,人物角度都影響評分標準

import requests

import base64

import matplotlib.pyplot as plt # plt 用於顯示

import matplotlib.image as mpimg # mpimg 用於讀取

'''換取token

'''def

gettoken()

: host =

''response = requests.get(host)

if response:

return response.json()[

'access_token'

]'''

人臉檢測與屬性分析

'''def

getscore

(url)

: f=

open

(url,

'rb'

)#二進位制讀寫,轉換base64

base64_data = base64.b64encode(f.read())

request_url =

""params =

request_url = request_url +

"?access_token="

+ gettoken(

) headers =

response = requests.post(request_url, data=params, headers=headers)

if response:

print

("經過ai大資料評分您的顏值分數為:"

,response.json()[

'result'][

'face_list'][

0]['beauty'])

print()

lena = mpimg.imread(url)

plt.imshow(lena)

plt.axis(

'off'

) plt.show(

)

偷偷的來為身邊的人打一次分吧~

當然,分值僅供參考,切勿用於攀比,我們每個人都是獨一無二的。

30歲之前的相貌是父母給的,30歲之後的相貌則是自己養的

腹有詩書氣自華

百度人臉識別C 對接

一 註冊 id 及上載sdk 二 json openssl curl c 11 這個可以從伺服器的winc 的sdk包裡找 也可以自己找相應原始碼編譯 錯誤 c4996 fopen this function or variable may be unsafe.consider using fope...

百度人臉識別 返回json 資料提取

我們直奔主題 下面為得到的人臉檢測的乙個資料樣例 result face probability 1,angle face probability 1,angle face probability 0.8695431948,angle 從上面可以看出 此資料結構有4層 root層 result層 f...

百度人臉識別搜尋是怎麼實現的

如何通過一張,找到另一張?比方,一張可能既包括風景又包括人,使用者想要尋找的是類似風景 類似布局結構的還是類似的人?具體演算法作為商業機密,難以對外界披露。不過資料顯示,目前人臉識別演算法中lbp是比較流行的一種特徵提取方式,即通過畫素周邊8個臨近畫素的灰度值和中心灰度值比較,得到乙個八位編碼,然後...