Face++API调用

人脸检测API调用

python 复制代码
import requests
import json
#将自己的KEY和Secret进行替换
API_KEY='your_API_KET'  
API_SECRET='your_API_Secret'

# 人脸识别的URL
URL = 'https://api-cn.faceplusplus.com/facepp/v3/detect'

# 请求参数,需要什么参数传入什么参数
data = {"api_key":API_KEY, 
        "api_secret":API_SECRET, 
        "image_url":'https://ts1.cn.mm.bing.net/th?id=OIP-C.Lc7aekOkY0t0Fii9a_xzYwHaK3&w=115&h=150&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
        #期望返回的参数
        "return_attributes": "gender,age,smiling,beauty",
        #  return_landmark 不写默认是不返回检测点,1为返回83个人脸检测点,2为返回106个检测点       
        "return_landmark":1}
# 发送请求
response = requests.post(URL,data=data)
req_con = response
print(req_con)
req_con = response.json()
print(req_con)

运行结果截图:

人脸美颜API调用

python 复制代码
from PIL import Image
import base64
import io
import requests
import json

#将自己的KEY和Secret进行替换
API_KEY='your_API_KET'  
API_SECRET='your_API_Secret'

# 人脸美颜的URL
URL = 'https://api-cn.faceplusplus.com/facepp/v1/beautify'

# 请求参数,需要什么参数传入什么参数
data = {"api_key":API_KEY, 
        "api_secret":API_SECRET, 
        "image_url":'https://ts1.cn.mm.bing.net/th?id=OIP-C.Lc7aekOkY0t0Fii9a_xzYwHaK3&w=115&h=150&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
        "whitening":80,
        "smoothing":80
       }
# 发送请求
response = requests.post(URL,data=data)
req_con = response
print(req_con)
req_con = response.json()
print(req_con)
#获取美颜后的照片
base64_str=req_con['result']

image_data = base64.b64decode(base64_str)
image = Image.open(io.BytesIO(image_data))
image.save("output.jpg")

人脸对比

python 复制代码
import requests
import json

#将自己的KEY和Secret进行替换
API_KEY='your_API_KET'  
API_SECRET='your_API_Secret'

# 人脸对比的URL
URL = 'https://api-cn.faceplusplus.com/facepp/v3/compare'

# 请求参数,需要什么参数传入什么参数
data = {"api_key":API_KEY, 
        "api_secret":API_SECRET, 
        "image_url1":'https://ts1.cn.mm.bing.net/th?id=OIP-C.Lc7aekOkY0t0Fii9a_xzYwHaK3&w=115&h=150&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
        "image_url2":'https://ts1.cn.mm.bing.net/th/id/R-C.717bfafeb2991c64790c4e89bbea5bda?rik=QOqbwamEroQU9A&riu=http%3a%2f%2fa2.att.hudong.com%2f51%2f28%2f01300001066597135114289686481.jpg&ehk=Ku6dkcMh2Cg3oX0YFkXs7VBs2UA54B0DzFY0mqN117g%3d&risl=&pid=ImgRaw&r=0'
        
       }
# 发送请求
response = requests.post(URL,data=data)
req_con = response
print(req_con)
req_con = response.json()
print(req_con)
相关推荐
RainbowSea5 小时前
12. LangChain4j + 向量数据库操作详细说明
java·langchain·ai编程
RainbowSea5 小时前
11. LangChain4j + Tools(Function Calling)的使用详细说明
java·langchain·ai编程
考虑考虑9 小时前
Jpa使用union all
java·spring boot·后端
用户3721574261359 小时前
Java 实现 Excel 与 TXT 文本高效互转
java
RestCloud10 小时前
SQL Server到Hive:批处理ETL性能提升30%的实战经验
数据库·api
RestCloud10 小时前
为什么说零代码 ETL 是未来趋势?
数据库·api
浮游本尊11 小时前
Java学习第22天 - 云原生与容器化
java
ClouGence12 小时前
CloudCanal + Paimon + SelectDB 从 0 到 1 构建实时湖仓
数据库
渣哥12 小时前
原来 Java 里线程安全集合有这么多种
java
间彧12 小时前
Spring Boot集成Spring Security完整指南
java