4151| 4
|
[讨论交流] 【EasyDL】百度人工智能定制物体检测 |
定制物体检测模型,可以检测出图片里面的所有目标物体名称、位置。适用于一张图片中要识别多个物体,物体计数等场景中。 以上为检测手机拍摄的四个垃圾照片,进行了正确的检测,可信度在0.99以上。 ![]() 操作步骤: 1、登陆百度云https://login.bce.baidu.com/ ![]() 2、进入EasyDL ![]() 3、进入经典版 ![]() 4、物体检测 ![]() 5、创建数据集 ![]() 6、利用手机QQ拍照,直接传给电脑,下载保存 ![]() 7、上传图片 ![]() ![]() 8、 创建模型 ![]() ![]() 9、训练模型 ![]() 训练完成后,发布。 10、发布后,创建应用 ![]() ![]() ![]() 11、Python调动 [mw_shl_code=python,false]# encoding:utf-8 import requests import base64,json,cv2 access_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) if response: con=response.json() access_token=con['access_token'] ''' easydl物体检测 ''' def get_file_content(filePath): with open(filePath, 'rb') as fp: return fp.read() if access_token !='': image = get_file_content('.\\img\\qq.jpg') image_base64 = base64.b64encode(image) #转为BASE64 image_base64_utf_8=str(image_base64, encoding='utf-8')#不能传入字节 request_url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/detection/ljfl1" request_url = request_url + "?access_token=" + access_token s = json.dumps({'image': image_base64_utf_8}) response=requests.post(request_url, data=s,headers={'Content-Type':'application/json'}) content = response.json() results=content['results'] image=cv2.imread('.\\img\\qq.jpg') cv2.namedWindow("capture",0); cv2.resizeWindow("capture",1917,1080) font = cv2.FONT_HERSHEY_SIMPLEX # 定义字体 for con in results: x1=con['location']['left'] x2=x1+con['location']['width'] y1=con['location']['top'] y2=y1+con['location']['height'] image=cv2.rectangle(image,(x1,y1),(x2,y2),(0,255,0),5) image=cv2.putText(image, con['name']+ str((con['score']))[:6], (x1, y2+20), font, 1.2, (255, 255, 255), 2) cv2.imshow("capture", image) cv2.waitKey(10000) cv2.destroyAllWindows() [/mw_shl_code] 12、演示 ![]() |
© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed