Aliyun_人脸人体_人脸信息脱敏

import oss2
import json
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import requests
AccessKeyId="xxxx"
AccessKeySecret="xxxx"
auth = oss2.Auth(AccessKeyId, AccessKeySecret)
bucket = oss2.Bucket(auth, 'https://oss-cn-shanghai.aliyuncs.com', 'ocr-yjs')
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkcore.auth.credentials import StsTokenCredential
credentials = AccessKeyCredential(AccessKeyId, AccessKeySecret)
client = AcsClient(region_id='cn-shanghai', credential=credentials)
import seaborn as sns
"""
https://help.aliyun.com/document_detail/179240.html
人脸信息脱敏
人脸信息脱敏对输入图像中的人脸进行模糊处理,输出脱敏后的图像。
"""

from aliyunsdkfacebody.request.v20191230.BlurFaceRequest import BlurFaceRequest

request = BlurFaceRequest()
request.set_accept_format('json')

filepath="images/test2.jpg"
with open(filepath, 'rb') as fileobj:
    bucket.put_object(filepath, fileobj)
url="https://ocr-yjs.oss-cn-shanghai.aliyuncs.com/"+filepath
print(url)

request.set_ImageURL(url)




response = client.do_action_with_exception(request)
response=json.loads(str(response, encoding='utf-8'))
print(response)
ImageURL=response["Data"]["ImageURL"]
https://ocr-yjs.oss-cn-shanghai.aliyuncs.com/images/test2.jpg
{'RequestId': '473EFAA0-2875-54C9-B1FD-BF96DA6E8B58', 'Data': {'ImageURL': 'http://viapi-cn-shanghai-dha-segmenter.oss-cn-shanghai.aliyuncs.com/upload/result_FaceBlur/2021-8-21/invi_FaceBlur_016295088010112234263_OwwTIk.jpg?Expires=1629510601&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRpDvh1&Signature=iausdb0ZYBOhAOOtdUI3kh0GfkQ%3D'}}
"""
MakeupType	String	是	whole	
美妆类型,当前支持whole(整妆)。

ResourceType	String	是	0	
美妆使用的风格,具体包括:0(whole)、1(基础妆)、2(少女妆)、3(活力妆)、4(优雅妆)、5(魅惑妆)、6(梅子妆)。

Strength	Float	是	1	
美妆强度,取值范围0~1。
"""
'\nMakeupType\tString\t是\twhole\t\n美妆类型,当前支持whole(整妆)。\n\nResourceType\tString\t是\t0\t\n美妆使用的风格,具体包括:0(whole)、1(基础妆)、2(少女妆)、3(活力妆)、4(优雅妆)、5(魅惑妆)、6(梅子妆)。\n\nStrength\tFloat\t是\t1\t\n美妆强度,取值范围0~1。\n'
with open("images/人脸信息脱敏后.jpg",'wb') as file:
    file.write(requests.get(ImageURL).content)

你可能感兴趣的:(计算机视觉,人工智能,深度学习)