图像技术-人像动漫化
借助百度AI,实现人像动漫化
官网:https://ai.baidu.com/tech/imageprocess/selfie_anime
import requests, base64import uuiddef get_acess_token():# client_id 为官网获取的AK, client_secret 为官网获取的SK,去 百度智能管理中心创建获取host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【官网获取的AK】&client_secret=【官网获取的SK】'response = requests.get(host)return response.json()['access_token']def make_picture(path):request_url = "https://aip.baidubce.com/rest/2.0/image-process/v1/selfie_anime"# 二进制方式打开图片文件f = open(path, 'rb')img = base64.b64encode(f.read())params = {"image": img}access_token = get_acess_token()request_url = request_url + "?access_token=" + access_tokenheaders = {'content-type': 'application/x-www-form-urlencoded'}response = requests.post(request_url, data=params, headers=headers)res = response.json()if res:f = open(str(uuid.uuid1()) + '.png', 'wb')after_img = res['image']after_img = base64.b64decode(after_img)f.write(after_img)f.close()print('------------已完成---------------------')if __name__ == '__main__':path=''make_picture(path)
「❤️ 感谢大家」
如果你觉得这篇内容对你挺有有帮助的话:
点赞支持下吧,让更多的人也能看到这篇内容(收藏不点赞,都是耍流氓 -_-) 欢迎在留言区与我分享你的想法,也欢迎你在留言区记录你的思考过程。 觉得不错的话,也可以阅读近期梳理的文章(感谢鼓励与支持🌹🌹🌹): 编程中的惰性思想 小程序云开发资源的管理 教你用python进行数字化妆,可爱至极 加速Python列表和字典,让你代码更加高效 汇总超全的Matplotlib可视化最有价值的 50 个图表(附完整 Python 源代码)(三) 汇总超全的Matplotlib可视化最有价值的 50 个图表(附完整 Python 源代码)(二) 汇总超全的Matplotlib可视化最有价值的 50 个图表(附完整 Python 源代码)(一) 教你用Python制作实现自定义字符大小的简易小说阅读器 「查缺补漏」巩固你对算法复杂度的理解 汇总了32个为开发者提供的免费工具 教你通过python利用近邻法实现图片缩小后变成另一张图(类似幻影坦克) 30 行代码实现蚂蚁森林自动收能量
老铁,三连支持一下,好吗?↓↓↓


点分享

点点赞

点在
评论

