數(shù)據(jù)集地址
該圖像數(shù)據(jù)集是 通過一個(gè)特色的渠道獲取了數(shù)據(jù)集,然后一通處理以后得到的數(shù)據(jù),其中一張圖的一部分顯示如下(因?yàn)楸C埽骸?/p>
整個(gè)數(shù)據(jù)集有100張圖像,但是每張圖像上的對(duì)象實(shí)在太多了,每辦法,花了兩天的時(shí)候,標(biāo)注了其中65張圖像,60張作為訓(xùn)練集、5張做為測(cè)試集。算是完成了數(shù)據(jù)標(biāo)注工作。
模型訓(xùn)練
準(zhǔn)備好數(shù)據(jù)集以后,直接按下面的命令行運(yùn)行即可:
yolotrainmodel=yolov8s.ptdata=sperm_dataset.yamlepochs=50imgsz=1280batch=8
導(dǎo)出與測(cè)試
模型導(dǎo)出與測(cè)試
yolo export model=sperm50_640_best.pt format=onnx yolo predict model=sperm50_640_best.pt source=.sperm_test
部署推理
轉(zhuǎn)成ONNX格式文件以后,基于OpenVINO-Python部署推理,相關(guān)代碼如下
ie=Core() fordeviceinie.available_devices: print(device) #ReadIR model=ie.read_model(model="sperm_best.onnx") compiled_model=ie.compile_model(model=model,device_name="CPU") output_layer=compiled_model.output(0) frame=cv.imread("D:/1.jpg") bgr=format_yolov8(frame) img_h,img_w,img_c=bgr.shape start=time.time() image=cv.dnn.blobFromImage(bgr,1/255.0,(640,640),swapRB=True,crop=False) res=compiled_model([image])[output_layer]#1x84x8400 rows=np.squeeze(res,0).T class_ids=[] confidences=[] boxes=[] x_factor=img_w/640 y_factor=img_h/640 forrinrange(rows.shape[0]): row=rows[r] classes_scores=row[4:] _,_,_,max_indx=cv.minMaxLoc(classes_scores) class_id=max_indx[1] if(classes_scores[class_id]>.25): confidences.append(classes_scores[class_id]) class_ids.append(class_id) x,y,w,h=row[0].item(),row[1].item(),row[2].item(),row[3].item() left=int((x-0.5*w)*x_factor) top=int((y-0.5*h)*y_factor) width=int(w*x_factor) height=int(h*y_factor) box=np.array([left,top,width,height]) boxes.append(box) indexes=cv.dnn.NMSBoxes(boxes,confidences,0.25,0.45) forindexinindexes: box=boxes[index] color=colors[int(class_ids[index])%len(colors)] rr=int((box[2]+box[3])/4) cv.circle(frame,(box[0]+int(box[2]/2),box[1]+int(box[3]/2)),rr-4,color,2) cv.putText(frame,class_list[class_ids[index]],(box[0]+int(box[2]/2),box[1]+int(box[3]/2)), cv.FONT_HERSHEY_SIMPLEX,.5,(0,0,0)) cv.putText(frame,"gloomyfish@2024",(20,45),cv.FONT_HERSHEY_SIMPLEX,1,(0,0,255),2) cv.imshow("YOLOv8+OpenVINO2023SpermCount",frame) cv.waitKey(0) cv.destroyAllWindows()
審核編輯:劉清
-
python
+關(guān)注
關(guān)注
56文章
4811瀏覽量
85090 -
OpenVINO
+關(guān)注
關(guān)注
0文章
99瀏覽量
246
原文標(biāo)題:實(shí)戰(zhàn) | YOLOv8也能打小目標(biāo)檢測(cè)
文章出處:【微信號(hào):CVSCHOOL,微信公眾號(hào):OpenCV學(xué)堂】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
使用YOLOv8做目標(biāo)檢測(cè)和實(shí)例分割的演示
YOLOv8自定義數(shù)據(jù)集訓(xùn)練到模型部署推理簡析
TensorRT 8.6 C++開發(fā)環(huán)境配置與YOLOv8實(shí)例分割推理演示
![TensorRT 8.6 C++開發(fā)環(huán)境配置與<b class='flag-5'>YOLOv8</b>實(shí)例分割推理演示](https://file1.elecfans.com/web2/M00/82/3C/wKgaomRHQBuAbc9BAAA5BtJaaeQ655.png)
在AI愛克斯開發(fā)板上用OpenVINO?加速YOLOv8分類模型
![在AI愛克斯開發(fā)板上用OpenVINO?加速<b class='flag-5'>YOLOv8</b>分類模型](https://file1.elecfans.com/web2/M00/82/79/wKgZomRUfNiABd-qAAAT5AAjKtc607.png)
在AI愛克斯開發(fā)板上用OpenVINO?加速YOLOv8目標(biāo)檢測(cè)模型
![在AI愛克斯開發(fā)板上用OpenVINO?加速<b class='flag-5'>YOLOv8</b><b class='flag-5'>目標(biāo)</b><b class='flag-5'>檢測(cè)</b>模型](https://file1.elecfans.com/web2/M00/82/B1/wKgZomRdkeGAd8S2AAAm8DCq3H4572.png)
YOLOv8版本升級(jí)支持小目標(biāo)檢測(cè)與高分辨率圖像輸入
![<b class='flag-5'>YOLOv8</b>版本升級(jí)支持小<b class='flag-5'>目標(biāo)</b><b class='flag-5'>檢測(cè)</b>與高分辨率圖像輸入](https://file1.elecfans.com/web2/M00/82/CE/wKgZomRi9ZiAQ_8gAABAHdjYHvo467.png)
AI愛克斯開發(fā)板上使用OpenVINO加速YOLOv8目標(biāo)檢測(cè)模型
![AI愛克斯開發(fā)板上使用OpenVINO加速<b class='flag-5'>YOLOv8</b><b class='flag-5'>目標(biāo)</b><b class='flag-5'>檢測(cè)</b>模型](https://file1.elecfans.com/web2/M00/88/B7/wKgaomRwIXSAVKmcAAAm8DCq3H4143.png)
教你如何用兩行代碼搞定YOLOv8各種模型推理
![教你如何用兩行代碼搞定<b class='flag-5'>YOLOv8</b>各種模型推理](https://file1.elecfans.com/web2/M00/8A/05/wKgZomSOf3iAf_ATAABcweWVywE605.png)
目標(biāo)檢測(cè)算法再升級(jí)!YOLOv8保姆級(jí)教程一鍵體驗(yàn)
![<b class='flag-5'>目標(biāo)</b><b class='flag-5'>檢測(cè)</b>算法再升級(jí)!<b class='flag-5'>YOLOv8</b>保姆級(jí)教程一鍵體驗(yàn)](https://file.elecfans.com/web2/M00/94/58/poYBAGP9bdWAHk0WAAAx3R5lhzQ662.png)
三種主流模型部署框架YOLOv8推理演示
解鎖YOLOv8修改+注意力模塊訓(xùn)練與部署流程
![解鎖<b class='flag-5'>YOLOv8</b>修改+注意力模塊訓(xùn)練與部署流程](https://file1.elecfans.com/web2/M00/90/2C/wKgZomTV0kyAN5sVAAA-83oi1cg664.png)
如何修改YOLOv8的源碼
![如何修改<b class='flag-5'>YOLOv8</b>的源碼](https://file1.elecfans.com/web2/M00/A1/77/wKgZomT1O6yAV5T0AAA-83oi1cg976.png)
基于YOLOv8的自定義醫(yī)學(xué)圖像分割
![基于<b class='flag-5'>YOLOv8</b>的自定義醫(yī)學(xué)圖像分割](https://file1.elecfans.com/web2/M00/B6/E6/wKgaomWCWJiAM1oBAAARpnn1nSs514.jpg)
YOLOv8實(shí)現(xiàn)旋轉(zhuǎn)對(duì)象檢測(cè)
![<b class='flag-5'>YOLOv8</b>實(shí)現(xiàn)旋轉(zhuǎn)對(duì)象<b class='flag-5'>檢測(cè)</b>](https://file1.elecfans.com/web2/M00/BC/FC/wKgaomWfVjqAQnDnAABPfe5K8eA744.png)
YOLOv8中的損失函數(shù)解析
![<b class='flag-5'>YOLOv8</b>中的損失函數(shù)解析](https://file1.elecfans.com/web2/M00/0B/CA/wKgaomcp4mOAWXxdAAAAZMZaAdw759.png)
評(píng)論