• 基于Python的人脸动漫转换


      

      首先需要去百度申请你自己的接口。获取access_token;

      

     request_url = "https://aip.baidubce.com/rest/2.0/image-process/v1/selfie_anime"
    # 二进制方式打开图片文件
    #这里的image_src需要你自己去设置,后缀是输出图片的后缀名
    def changedongman(image_src,houzhui): f = open(image_src, 'rb') img = base64.b64encode(f.read()) params = {"image":img}
    access_token
    = '【自己申请的】' request_url = request_url + "?access_token=" + access_token headers = {'content-type': 'application/x-www-form-urlencoded'} response = requests.post(request_url, data=params, headers=headers) if response: data = response.json() # 保存识别后的图片 img_str = data['image'] img_data = base64.b64decode(img_str) t = time.time() currtime =str(round(t * 1000)) savePath = str("D:\StudyPython\code\DealWithPhoto\static\katongphoto\"+currtime+"."+houzhui) dataSavePath = str("../static/katongphoto/"+currtime+"."+houzhui) insert_image_sql = "insert into image(imagename,`path`,createtime) values(%s,%s,%s)" db.insertone(sql=insert_image_sql, param=('卡通', dataSavePath, get_local_time())) with open(savePath, 'wb') as f: f.write(img_data)
  • 相关阅读:
    二分搜素——(lower_bound and upper_bound)
    二分(搜索)查找
    算法复杂度中的O(logN)底数是多少
    hdu 1050 Moving Tables
    hdu 1010 Tempter of the Bone
    hud 3123 GCC
    “123”——> 123
    基本模运算
    101个MySQL的调节和优化的Tips
    一个最简单的图片缩略图
  • 原文地址:https://www.cnblogs.com/moxihuishou/p/14846088.html
Copyright © 2020-2023  润新知