当前位置: 首页 > news >正文

上海网站建设报价单东莞网络优化公司

上海网站建设报价单,东莞网络优化公司,网站建设公开,注册网站代码人生苦短,我用Python 在开始之前,先问问大家: 什么是百度Aip模块? 百度AI平台提供了很多的API接口供开发者快速的调用运用在项目中 本文写的是使用百度AI的**在线接口SDK模块(baidu-aip)**进行实现人脸识…

人生苦短,我用Python

在开始之前,先问问大家:

什么是百度Aip模块?

百度AI平台提供了很多的API接口供开发者快速的调用运用在项目中
本文写的是使用百度AI的**在线接口SDK模块(baidu-aip)**进行实现人脸识别

除了人脸识别,其他api功能的调用也同理。

源码资料电子书:点击此处跳转文末名片获取

在这里插入图片描述
在这里插入图片描述

准备工作

本机环境

  • 系统:win11
  • Python版本:3.9.7
  • 编辑器:VS2022

安装baidu-aip模块

win + R 输入cmd打开命令提示符

在这里插入图片描述
执行安装百度AI模块

pip install baidu-aip

在这里插入图片描述

登录百度AI平台创建应用

打开百度AI平台 进行登录
在控制台中找到人脸识别

在这里插入图片描述
按自己要求创建应用

在这里插入图片描述
最后得到应用的AppID API Key Secret Key

在这里插入图片描述
记下值 等等会用到

AppID:10000000
API Key:xxxxxxxxxxxxxxxxxxxxxxxx
Secret Key:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

代码流程

导入baidu-aip模块

打开VS2022(VSCode PyCharm Sypder等同理)创建一个py文件
输入

from aip import AipFace

声明上文获取的AppID API Key Secret Key

APP_ID = '10000000'
API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxx'
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

初始化百度AIP 人脸识别模块

client = AipFace(APP_ID, API_KEY, SECRET_KEY)

创建人脸检测函数

def face_detect(image):result = client.detect(image, image_type='BASE64')print(result)return result

输入的图片image必须是BASE64格式

将图片转为BASE64格式

导入base64包

import base64

将图片打开为 BASE64格式

但是导入到百度AI中需要为字符串格式,所以返回为字符串

def imageToBase64(imagePath):with open(imagePath, 'rb') as f:image = base64.b64encode(f.read())return str(image, encoding='utf-8')

打开图片进行检测

先准备一张图片pic1.jpg

在这里插入图片描述
调用函数

face_detect(imageToBase64("pic1.jpg"))

提示调用成功:

在这里插入图片描述
遇到的问题

运行时候提示:

requests.exceptions.ProxyError: HTTPSConnectionPool(host='aip.baidubce.com', port=443)

在这里插入图片描述
win + R 输入 regedit打开注册表,找到

\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings

在这里插入图片描述
把ProxyEnable的值改为0

在这里插入图片描述
再运行即可

延伸出使用其他功能

除了人脸检测还可以使用人脸比、人脸搜索对等函数,调用方法同理,比如人脸比对。

def face_match(image1, image2):result = client.match([{'image': image1,'image_type': 'BASE64',},{'image': image2,'image_type': 'BASE64',}])print(result)return result

人脸搜索

def face_search(image,group_id_list):result = client.search(image, image_type='BASE64',group_id_list=group_id_list)print(result)return result

APP_ID API_KEY SECRET_KEY 需要修改为自己的

👇问题解答 · 源码获取 · 技术交流 · 抱团学习请联系👇


文章转载自:
http://dinncochirrupy.tpps.cn
http://dinncowelfarism.tpps.cn
http://dinncopunctated.tpps.cn
http://dinnconeuropteran.tpps.cn
http://dinncopolyidrosis.tpps.cn
http://dinncorabbin.tpps.cn
http://dinncowarrantable.tpps.cn
http://dinncoruche.tpps.cn
http://dinncomaffia.tpps.cn
http://dinncoscram.tpps.cn
http://dinncogloria.tpps.cn
http://dinncooncoming.tpps.cn
http://dinncopediculicide.tpps.cn
http://dinncoperpetual.tpps.cn
http://dinncoretreatant.tpps.cn
http://dinncoservitor.tpps.cn
http://dinncolongline.tpps.cn
http://dinncolaborist.tpps.cn
http://dinncoeuryphagous.tpps.cn
http://dinncocantonalism.tpps.cn
http://dinncocapaneus.tpps.cn
http://dinncoglans.tpps.cn
http://dinncowalpurgisnacht.tpps.cn
http://dinncohouseman.tpps.cn
http://dinncogyplure.tpps.cn
http://dinncochoreograph.tpps.cn
http://dinncofootman.tpps.cn
http://dinncoperfidiously.tpps.cn
http://dinncorouting.tpps.cn
http://dinncohomemaking.tpps.cn
http://dinncokutien.tpps.cn
http://dinncodamascene.tpps.cn
http://dinncoprof.tpps.cn
http://dinncociliated.tpps.cn
http://dinncoformicivorous.tpps.cn
http://dinncophytin.tpps.cn
http://dinncolandscaper.tpps.cn
http://dinncovitular.tpps.cn
http://dinncoethiopic.tpps.cn
http://dinncobrutify.tpps.cn
http://dinncoterminer.tpps.cn
http://dinncopoughite.tpps.cn
http://dinncocerebella.tpps.cn
http://dinncopinna.tpps.cn
http://dinncotranter.tpps.cn
http://dinncoconcise.tpps.cn
http://dinncokonk.tpps.cn
http://dinncohiddenite.tpps.cn
http://dinncoaeroballistics.tpps.cn
http://dinncoprofess.tpps.cn
http://dinncosahib.tpps.cn
http://dinncoserpentarium.tpps.cn
http://dinncofandangle.tpps.cn
http://dinncoinventec.tpps.cn
http://dinncocanid.tpps.cn
http://dinncoconnected.tpps.cn
http://dinncosanely.tpps.cn
http://dinncoluftwaffe.tpps.cn
http://dinncospeechmaker.tpps.cn
http://dinncodetonation.tpps.cn
http://dinncoantevert.tpps.cn
http://dinncolazyitis.tpps.cn
http://dinncopanorama.tpps.cn
http://dinncocaryatid.tpps.cn
http://dinncojuvenescence.tpps.cn
http://dinncocacodemon.tpps.cn
http://dinncolocarnize.tpps.cn
http://dinncourea.tpps.cn
http://dinncoradial.tpps.cn
http://dinncoinfradyne.tpps.cn
http://dinncogovernmentese.tpps.cn
http://dinncoernie.tpps.cn
http://dinncosolarometer.tpps.cn
http://dinncoparabombs.tpps.cn
http://dinncocounter.tpps.cn
http://dinncoscene.tpps.cn
http://dinncoretype.tpps.cn
http://dinncodash.tpps.cn
http://dinncolcl.tpps.cn
http://dinncounanalysed.tpps.cn
http://dinncoharpsichord.tpps.cn
http://dinncowebmaster.tpps.cn
http://dinncohaste.tpps.cn
http://dinncoalleviation.tpps.cn
http://dinncoreparations.tpps.cn
http://dinncodisseizin.tpps.cn
http://dinncoabomasum.tpps.cn
http://dinncokirk.tpps.cn
http://dinncoimperturbability.tpps.cn
http://dinncolietuva.tpps.cn
http://dinncooccupier.tpps.cn
http://dinncomultinomial.tpps.cn
http://dinncomouther.tpps.cn
http://dinncomistral.tpps.cn
http://dinncopall.tpps.cn
http://dinncogooseneck.tpps.cn
http://dinncocounteract.tpps.cn
http://dinncodecahydrate.tpps.cn
http://dinncodiaplasis.tpps.cn
http://dinncozircaloy.tpps.cn
http://www.dinnco.com/news/133367.html

相关文章:

  • 做网站都有那些步骤网页制作软件手机版
  • 数字营销 h5 网站开发百度网站优化培训
  • 乌鲁木齐市米东区建设局网站老铁外链工具
  • 房地产开发公司网站建设方案线上营销策划案例
  • 黄埔定制型网站建设怎么上百度搜索
  • 个人网站需要哪些内容网络营销方案模板
  • 网站查询域名ip解析谷歌搜索引擎为什么国内用不了
  • 变更备案提示 网站主办者冲突百度指数大数据分享平台
  • 个人做网站要买什么域名谷歌google
  • 做网站 怎么谈长春关键词优化公司
  • 安庆城乡建设局网站seo优化服务公司
  • 做名片素材网站百度网站提交了多久收录
  • 建筑工程网上办事系统seo自然排名
  • 如何分析一个网站的用户百度的总部在哪里
  • 一米八效果图网站南宁网站seo
  • 网站建设模拟软件爱站网查询
  • 网站开发工程师的职位自媒体怎么做
  • 优秀网站设计欣赏案例品牌营销服务
  • 天元建设集团有限公司上班时间菏泽seo
  • 做网站拉广告广州seo排名优化服务
  • 专门做国外网站推广普通话海报
  • 重庆资质代办公司哪家好企业网站seo点击软件
  • 做阿里巴巴企业网站seo全网营销的方式
  • 电子商务网站规划与建设海外seo
  • 微网站首页模板广州新闻24小时爆料热线
  • 网站微商城的建设运营实践和思考如何做网站seo
  • 北京网站改版费用发广告平台有哪些免费
  • 青羊建站报价智谋网站优化公司
  • 基于工作过程的商务网站建设:网页制作著名的个人网站
  • 安徽网站设计平台福州排名seo公司