小游戲網(wǎng)站審核怎么做適合小學(xué)生摘抄的新聞2022年
《博主簡(jiǎn)介》
小伙伴們好,我是阿旭。專注于人工智能、AIGC、python、計(jì)算機(jī)視覺相關(guān)分享研究。
?更多學(xué)習(xí)資源,可關(guān)注公-仲-hao:【阿旭算法與機(jī)器學(xué)習(xí)】,共同學(xué)習(xí)交流~
👍感謝小伙伴們點(diǎn)贊、關(guān)注!
《------往期經(jīng)典推薦------》
一、AI應(yīng)用軟件開發(fā)實(shí)戰(zhàn)專欄【鏈接】
項(xiàng)目名稱 | 項(xiàng)目名稱 |
---|---|
1.【人臉識(shí)別與管理系統(tǒng)開發(fā)】 | 2.【車牌識(shí)別與自動(dòng)收費(fèi)管理系統(tǒng)開發(fā)】 |
3.【手勢(shì)識(shí)別系統(tǒng)開發(fā)】 | 4.【人臉面部活體檢測(cè)系統(tǒng)開發(fā)】 |
5.【圖片風(fēng)格快速遷移軟件開發(fā)】 | 6.【人臉表表情識(shí)別系統(tǒng)】 |
7.【YOLOv8多目標(biāo)識(shí)別與自動(dòng)標(biāo)注軟件開發(fā)】 | 8.【基于YOLOv8深度學(xué)習(xí)的行人跌倒檢測(cè)系統(tǒng)】 |
9.【基于YOLOv8深度學(xué)習(xí)的PCB板缺陷檢測(cè)系統(tǒng)】 | 10.【基于YOLOv8深度學(xué)習(xí)的生活垃圾分類目標(biāo)檢測(cè)系統(tǒng)】 |
11.【基于YOLOv8深度學(xué)習(xí)的安全帽目標(biāo)檢測(cè)系統(tǒng)】 | 12.【基于YOLOv8深度學(xué)習(xí)的120種犬類檢測(cè)與識(shí)別系統(tǒng)】 |
13.【基于YOLOv8深度學(xué)習(xí)的路面坑洞檢測(cè)系統(tǒng)】 | 14.【基于YOLOv8深度學(xué)習(xí)的火焰煙霧檢測(cè)系統(tǒng)】 |
15.【基于YOLOv8深度學(xué)習(xí)的鋼材表面缺陷檢測(cè)系統(tǒng)】 | 16.【基于YOLOv8深度學(xué)習(xí)的艦船目標(biāo)分類檢測(cè)系統(tǒng)】 |
17.【基于YOLOv8深度學(xué)習(xí)的西紅柿成熟度檢測(cè)系統(tǒng)】 | 18.【基于YOLOv8深度學(xué)習(xí)的血細(xì)胞檢測(cè)與計(jì)數(shù)系統(tǒng)】 |
19.【基于YOLOv8深度學(xué)習(xí)的吸煙/抽煙行為檢測(cè)系統(tǒng)】 | 20.【基于YOLOv8深度學(xué)習(xí)的水稻害蟲檢測(cè)與識(shí)別系統(tǒng)】 |
21.【基于YOLOv8深度學(xué)習(xí)的高精度車輛行人檢測(cè)與計(jì)數(shù)系統(tǒng)】 | 22.【基于YOLOv8深度學(xué)習(xí)的路面標(biāo)志線檢測(cè)與識(shí)別系統(tǒng)】 |
23.【基于YOLOv8深度學(xué)習(xí)的智能小麥害蟲檢測(cè)識(shí)別系統(tǒng)】 | 24.【基于YOLOv8深度學(xué)習(xí)的智能玉米害蟲檢測(cè)識(shí)別系統(tǒng)】 |
25.【基于YOLOv8深度學(xué)習(xí)的200種鳥類智能檢測(cè)與識(shí)別系統(tǒng)】 | 26.【基于YOLOv8深度學(xué)習(xí)的45種交通標(biāo)志智能檢測(cè)與識(shí)別系統(tǒng)】 |
27.【基于YOLOv8深度學(xué)習(xí)的人臉面部表情識(shí)別系統(tǒng)】 | 28.【基于YOLOv8深度學(xué)習(xí)的蘋果葉片病害智能診斷系統(tǒng)】 |
29.【基于YOLOv8深度學(xué)習(xí)的智能肺炎診斷系統(tǒng)】 | 30.【基于YOLOv8深度學(xué)習(xí)的葡萄簇目標(biāo)檢測(cè)系統(tǒng)】 |
31.【基于YOLOv8深度學(xué)習(xí)的100種中草藥智能識(shí)別系統(tǒng)】 | 32.【基于YOLOv8深度學(xué)習(xí)的102種花卉智能識(shí)別系統(tǒng)】 |
33.【基于YOLOv8深度學(xué)習(xí)的100種蝴蝶智能識(shí)別系統(tǒng)】 | 34.【基于YOLOv8深度學(xué)習(xí)的水稻葉片病害智能診斷系統(tǒng)】 |
35.【基于YOLOv8與ByteTrack的車輛行人多目標(biāo)檢測(cè)與追蹤系統(tǒng)】 | 36.【基于YOLOv8深度學(xué)習(xí)的智能草莓病害檢測(cè)與分割系統(tǒng)】 |
37.【基于YOLOv8深度學(xué)習(xí)的復(fù)雜場(chǎng)景下船舶目標(biāo)檢測(cè)系統(tǒng)】 | 38.【基于YOLOv8深度學(xué)習(xí)的農(nóng)作物幼苗與雜草檢測(cè)系統(tǒng)】 |
39.【基于YOLOv8深度學(xué)習(xí)的智能道路裂縫檢測(cè)與分析系統(tǒng)】 | 40.【基于YOLOv8深度學(xué)習(xí)的葡萄病害智能診斷與防治系統(tǒng)】 |
41.【基于YOLOv8深度學(xué)習(xí)的遙感地理空間物體檢測(cè)系統(tǒng)】 | 42.【基于YOLOv8深度學(xué)習(xí)的無人機(jī)視角地面物體檢測(cè)系統(tǒng)】 |
43.【基于YOLOv8深度學(xué)習(xí)的木薯病害智能診斷與防治系統(tǒng)】 | 44.【基于YOLOv8深度學(xué)習(xí)的野外火焰煙霧檢測(cè)系統(tǒng)】 |
45.【基于YOLOv8深度學(xué)習(xí)的腦腫瘤智能檢測(cè)系統(tǒng)】 | 46.【基于YOLOv8深度學(xué)習(xí)的玉米葉片病害智能診斷與防治系統(tǒng)】 |
47.【基于YOLOv8深度學(xué)習(xí)的橙子病害智能診斷與防治系統(tǒng)】 | 48.【車輛檢測(cè)追蹤與流量計(jì)數(shù)系統(tǒng)】 |
49.【行人檢測(cè)追蹤與雙向流量計(jì)數(shù)系統(tǒng)】 | 50.【基于YOLOv8深度學(xué)習(xí)的反光衣檢測(cè)與預(yù)警系統(tǒng)】 |
51.【危險(xiǎn)區(qū)域人員闖入檢測(cè)與報(bào)警系統(tǒng)】 | 52.【高密度人臉智能檢測(cè)與統(tǒng)計(jì)系統(tǒng)】 |
二、機(jī)器學(xué)習(xí)實(shí)戰(zhàn)專欄【鏈接】,已更新31期,歡迎關(guān)注,持續(xù)更新中~~
三、深度學(xué)習(xí)【Pytorch】專欄【鏈接】
四、【Stable Diffusion繪畫系列】專欄【鏈接】
五、YOLOv8改進(jìn)專欄【鏈接】,持續(xù)更新中~~
六、YOLO性能對(duì)比專欄【鏈接】,持續(xù)更新中~
《------正文------》
介紹
在之前的博客文章中,我們介紹了如何使用 YOLOv8 進(jìn)行對(duì)象檢測(cè)。這篇文章則主要介紹如何使用YOLOv9進(jìn)行圖像與視頻檢測(cè)
。
YOLOv9 與其前身一樣,專注于識(shí)別和精確定位圖像和視頻中的對(duì)象。自動(dòng)駕駛汽車、安全系統(tǒng)和高級(jí)圖像搜索等應(yīng)用在很大程度上依賴于此功能。YOLOv9 引入了比 YOLOv8 更令人印象深刻的創(chuàng)新點(diǎn)。
使用 YOLOv9 處理圖像和視頻
步驟 1:安裝必要的庫(kù)
pip install opencv-python ultralytics
第 2 步:導(dǎo)入庫(kù)
import cv2
from ultralytics import YOLO
第 3 步:選擇模型型號(hào)尺寸
model = YOLO("yolov9c.pt")
這里,我們選擇了 yolov9c.pt。大家可以選擇不同的模型尺寸進(jìn)行檢測(cè),并比較不同的型號(hào)并權(quán)衡它們各自的優(yōu)缺點(diǎn)。
第 4 步:編寫一個(gè)函數(shù)來預(yù)測(cè)和檢測(cè)圖像和視頻中的對(duì)象
def predict(chosen_model, img, classes=[], conf=0.5):if classes:results = chosen_model.predict(img, classes=classes, conf=conf)else:results = chosen_model.predict(img, conf=conf)return resultsdef predict_and_detect(chosen_model, img, classes=[], conf=0.5, rectangle_thickness=2, text_thickness=1):results = predict(chosen_model, img, classes, conf=conf)for result in results:for box in result.boxes:cv2.rectangle(img, (int(box.xyxy[0][0]), int(box.xyxy[0][1])),(int(box.xyxy[0][2]), int(box.xyxy[0][3])), (255, 0, 0), rectangle_thickness)cv2.putText(img, f"{result.names[int(box.cls[0])]}",(int(box.xyxy[0][0]), int(box.xyxy[0][1]) - 10),cv2.FONT_HERSHEY_PLAIN, 1, (255, 0, 0), text_thickness)return img, results
predict()
功能
此函數(shù)采用三個(gè)參數(shù):
chosen_model
:用于預(yù)測(cè)的訓(xùn)練模型img
:要進(jìn)行預(yù)測(cè)的圖像classes
:(可選)要將預(yù)測(cè)篩選到的類名列表conf
:(可選)要考慮的預(yù)測(cè)的最小置信度閾值
該函數(shù)首先檢查是否提供了 classes
參數(shù)。如果是,則使用 classes
參數(shù)調(diào)用該chosen_model.predict()
方法,該參數(shù)僅將預(yù)測(cè)篩選為這些類。否則,將調(diào)用該 chosen_model.predict()
方法時(shí)不帶 classes
參數(shù),該參數(shù)將返回所有預(yù)測(cè)。
該 conf
參數(shù)用于篩選出置信度分?jǐn)?shù)低于指定閾值的預(yù)測(cè)。這對(duì)于消除誤報(bào)很有用。
該函數(shù)返回預(yù)測(cè)結(jié)果列表,其中每個(gè)結(jié)果都包含以下信息:
name
:預(yù)測(cè)類的名稱conf
:預(yù)測(cè)的置信度分?jǐn)?shù)box
:預(yù)測(cè)對(duì)象的邊界框
predict_and_detect()
功能
此函數(shù)采用與 predict()
函數(shù)相同的參數(shù),但除了預(yù)測(cè)結(jié)果外,它還返回帶注釋的圖像。
該函數(shù)首先調(diào)用該 predict()
函數(shù)以獲取預(yù)測(cè)結(jié)果。然后,它循環(huán)訪問預(yù)測(cè)結(jié)果,并在每個(gè)預(yù)測(cè)對(duì)象周圍繪制一個(gè)邊界框。預(yù)測(cè)類的名稱也寫在邊界框上方。
該函數(shù)返回一個(gè)包含帶注釋的圖像和預(yù)測(cè)結(jié)果的元組。
以下是這兩個(gè)函數(shù)之間差異的摘要:
- 該
predict()
函數(shù)僅返回預(yù)測(cè)結(jié)果,而該predict_and_detect()
函數(shù)還返回帶注釋的圖像。 - 該
predict_and_detect()
函數(shù)是predict()
函數(shù)的包裝器,這意味著它在內(nèi)部調(diào)用函數(shù)predict()
。
第 5 步:使用 YOLOv9 檢測(cè)圖像
# read the image
image = cv2.imread("YourImagePath")
result_img, _ = predict_and_detect(model, image, classes=[], conf=0.5)
如果要檢測(cè)特定類,只需在類列表classes
中輸入對(duì)象的 ID 號(hào)即可。
第 6 步:保存并繪制結(jié)果圖像
cv2.imshow("Image", result_img)
cv2.imwrite("YourSavePath", result_img)
cv2.waitKey(0)
第 7 步:使用 YOLOv9 檢測(cè)視頻
video_path = r"YourVideoPath"
cap = cv2.VideoCapture(video_path)
while True:success, img = cap.read()if not success:breakresult_img, _ = predict_and_detect(model, img, classes=[], conf=0.5)cv2.imshow("Image", result_img)cv2.waitKey(1)
第 8 步:保存結(jié)果視頻
# 定義保存函數(shù)
def create_video_writer(video_cap, output_filename):# grab the width, height, and fps of the frames in the video stream.frame_width = int(video_cap.get(cv2.CAP_PROP_FRAME_WIDTH))frame_height = int(video_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))fps = int(video_cap.get(cv2.CAP_PROP_FPS))#初始化fourcc = cv2.VideoWriter_fourcc(*'MP4V')writer = cv2.VideoWriter(output_filename, fourcc, fps,(frame_width, frame_height))return writer
只需使用上面的函數(shù)和代碼即可
output_filename = "YourFilename"
writer = create_video_writer(cap, output_filename)video_path = r"YourVideoPath"
cap = cv2.VideoCapture(video_path)
while True:success, img = cap.read()if not success:breakresult_img, _ = predict_and_detect(model, img, classes=[], conf=0.5)writer.write(result_img)cv2.imshow("Image", result_img)cv2.waitKey(1)
writer.release()
結(jié)論
在本文中,我們學(xué)習(xí)了如何使用 YOLOv9 檢測(cè)圖像和視頻中的對(duì)象。如果您覺得此代碼有用,感謝點(diǎn)贊關(guān)注。
引用
YOLOv9論文:https://arxiv.org/abs/2402.13616
YOLOv9 源碼地址:https://github.com/WongKinYiu/yolov9
關(guān)注文末名片G-Z-H:【阿旭算法與機(jī)器學(xué)習(xí)】,發(fā)送【開源】可獲取更多學(xué)習(xí)資源
好了,這篇文章就介紹到這里,喜歡的小伙伴感謝給點(diǎn)個(gè)贊和關(guān)注,更多精彩內(nèi)容持續(xù)更新~~
關(guān)于本篇文章大家有任何建議或意見,歡迎在評(píng)論區(qū)留言交流!