Khoos phis tawj pom kev thev naus laus zis thev naus laus zis yog qhov tseem ceeb rau ntau daim ntawv thov. Peb siv nws hauv robotics, cov cuab yeej soj ntsuam, tsheb tsav tus kheej, thiab ntau qhov chaw. Yog li ntawd, peb nrhiav tau thiab paub txog tej yam hauv daim duab lossis yees duab.
Ib qho ntawm cov neeg paub zoo tshaj plaws Object identification algorithms yog YOLO (Koj Tsuas Saib Ib Leeg) teeb cov qauv. Cov qauv no yog tsim los ntawm Ultralytics LLC.
Qhov tseeb version ntawm no series yog YOLOv5. Thiab, nws yog qhov ceev tshaj plaws thiab meej tshaj plaws kev txheeb xyuas tus qauv ntawm kev ua lag luam. Tus qauv lub peev xwm los nthuav dav rau cov ntaub ntawv tshiab tau zoo heev. Tsis tas li ntawd, nws muaj ntau yam nta uas ua rau nws ua tau zoo dua li yav dhau los iterations.
YOLOv5 yog qhov zoo rau kev siv lub sijhawm tiag tiag vim nws tuaj yeem ua cov duab ntawm tus nqi txog li 1000 thav duab ib ob ntawm ib qho GPU.
Hauv tsab xov xwm no, peb yuav qhia YOLOv5 thiab mus hla cov ntsiab lus ntawm nws thaj chaw ntawm daim ntawv thov.
Journey of YOLO: Los ntawm YOLO rau YOLOv5
Joseph Redmon et al. Ameslikas tau qhia txog YOLO, ib txheej ntawm cov qauv kev txheeb xyuas cov khoom, hauv 2016. Tus qauv YOLO thawj zaug tuaj yeem txheeb xyuas cov khoom hauv lub sijhawm. Txawm li cas los xij, nws muaj qhov tseeb tsawg thaum piv rau lwm cov qauv thaum lub sijhawm ntawd.
Ntau qhov hloov kho tshiab ntawm YOLO tau tso tawm thoob plaws xyoo. Thiab thaum kawg, Ultralytics LLC tau tsim qhov tshiab tshaj plaws ntawm YOLO series, YOLOv5.
YOLOv5 yog qhov tseeb tshaj plaws thiab ceev tshaj plaws kev txheeb xyuas tus qauv tam sim no.
Tseem ceeb nta
Thauj tog rau nkoj
YOLOv5 kwv yees cov thawv khi rau cov khoom hauv ib daim duab uas siv lub thawv thauj tog rau nkoj. Tus qauv kwv yees qhov twg ntawm ntau lub thawv ua ntej uas muaj ntau qhov sib piv zoo tshaj plaws yog cov khoom hauv daim duab uas siv cov thawv thauj tog rau nkoj. Cov no yog cov thawv ua ntej.
Thiab, lawv pab YOLOv5 kom paub thiab pom cov khoom hauv daim duab nrog qhov tseeb.
Mosaic cov ntaub ntawv augmentation
Thaum kev cob qhia, YOLOv5 ntiav ib txoj hauv kev hu ua mosaic cov ntaub ntawv augmentation. Txhawm rau tsim cov duab kev cob qhia tshiab, peb cov qauv randomly sib txuas ua ke ntawm ntau daim duab. Raws li qhov tshwm sim, tus qauv ua kom muaj zog dua thiab vam khom. Li no, nws tau mus generalize rau cov ntaub ntawv tshiab thiab txo overfitting.
Ib qho Kev Qhia Tshwj Xeeb Pipeline
Ib tug tshwj xeeb kev cob qhia pipeline uas sib tov saib xyuas thiab tsis saib xyuas kev kawm yog siv.
Yog li, tus qauv kawm los ntawm ib qho qauv me me thiab siv cov tswv yim tsis muaj npe zoo. Qhov no txhawb cov qauv kev ua tau zoo thiab txhim kho nws lub peev xwm los nthuav dav rau cov khoom siv tshiab.
Cov txheej uas yog residual thiab tsis-residual
YOLOv5's architecture ua ke cov txheej txheem uas yog residual thiab non-residual. Los ntawm kev cia cov gradients ntws hla cov khaubncaws sab nraud povtseg, cov khaubncaws sab nraud povtseg pab tus qauv hauv kev kawm nyuaj. Tsis tas li ntawd, cov khaubncaws sab nraud povtseg uas tsis yog seem muab cov qauv nrog kev nkag siab ntau dua ntawm cov duab nkag. Yog li ntawd, YOLOv5 tuaj yeem ua haujlwm tau zoo dua thiab ua haujlwm tau zoo.
Yuav Siv YOLOv5
installation
YOLOv5 kev teeb tsa tuaj yeem ua tiav sai sai siv pip. Pip yog tus tswj hwm pob Python. Cov txheej txheem dav dav rau kev txhim kho YOLOv5 yog raws li hauv qab no:
1- Nruab PyTorch: Vim YOLOv5 yog raws li PyTorch lub moj khaum, koj yuav tsum xub nruab PyTorch.
pip install torch torchvision
2. Nruab CUDA: Koj yuav tsum nruab CUDA yog tias koj npaj siab yuav khiav YOLOv5 ntawm GPU.
3. Nruab YOLOv5: Tom qab teeb tsa PyTorch thiab CUDA, siv cov lus txib nram qab no los rub tawm YOLOv5.
pip install yolov5
4- Ua raws li kev teeb tsa ntawm YOLOv5, koj yuav tsum rub tawm qhov hnyav ua ntej kev cob qhia. Cov luj uas tau kawm ua ntej muaj nyob rau hauv Ultralytics GitHub repo.
Mus rau "qhov hnyav" ib feem ntawm lub vev xaib los ntawm scrolling. Koj tuaj yeem rub tawm qhov hnyav ua ntej kev cob qhia los ntawm cov npe koj tuaj yeem pom ntawm no.
5. Xaiv qhov hnyav uas twb tau kawm thiab zoo tshaj plaws rau koj cov ntaub ntawv siv. Cov ntaub ntawv los yog qhov tshwj xeeb YOLOv5 version uas qhov hnyav tau kawm yuav raug siv los nqaim cov npe.
6- Tom qab xaiv qhov hnyav, xaiv qhov hnyav los ntawm nias lub pob "Download" ib sab ntawm nws. Cov luj yuav muaj rau download li. pt cov ntaub ntawv.
7- Hloov qhov hnyav rub tawm mus rau hauv phau ntawv teev npe. Qhov no yog qhov uas koj tsab ntawv tshawb nrhiav yuav ua haujlwm.
8- Lub sijhawm no, koj tuaj yeem khiav cov khoom tshawb pom ntawm koj cov duab lossis cov yeeb yaj kiab siv qhov hnyav uas tau kawm ua ntej hauv koj tsab ntawv tshawb pom.
Npaj cov ntaub ntawv
Koj yuav tsum ua cov haujlwm hauv qab no kom tau txais cov ntaub ntawv npaj rau kev siv nrog YOLOv5:
1. Sau cov ntaub ntawv: Thawj kauj ruam yog sau cov duab lossis video ntaub ntawv koj xav tau nrhiav pom khoom. Cov khoom koj xav ntes yuav tsum muaj nyob rau hauv cov duab lossis yeeb yaj kiab.
2- Format cov ntaub ntawv: Koj tsuas yog import cov duab rau hauv koj tsab ntawv yog tias koj siv lawv. Koj yuav tsum tig ib daim vis dis aus rau hauv cov duab yog tias koj npaj yuav siv ib qho. Koj tuaj yeem rho tawm cov thav duab los ntawm cov yeeb yaj kiab uas siv lub tsev qiv ntawv zoo li OpenCV.
import cv2
img = cv2.imread('path/to/image')
Nrog lub tsev qiv ntawv OpenCV, koj tuaj yeem siv cov lus txib hauv qab no los tig ib qho yeeb yaj kiab rau hauv cov duab:
import cv2
cap = cv2.VideoCapture('path/to/video')
while True:
ret, frame = cap.read()
if not ret:
break
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
3. Sau cov ntaub ntawv: Koj yuav tsum sau cov ntaub ntawv yog tias koj siv koj cov ntaub ntawv. Kos lub thawv khi ib ncig ntawm cov khoom koj xav txheeb xyuas hauv txhua tus ncej ntawm ib daim duab. Nws yog cov txheej txheem ntawm kev sau cov ntaub ntawv. Koj tuaj yeem siv ntau yam cuab yeej los pab koj ua haujlwm no, suav nrog LabelImg thiab RectLabel.
4- Koj yuav tsum faib cov ntaub ntawv mus rau hauv kev cob qhia thiab kev sim cov txheej txheem tom qab koj tau tagged nws. Qhov no yog qhov tseem ceeb rau kev ntsuas seb koj tus qauv ua tau zoo npaum li cas.
5. Thaum kawg, tej zaum koj yuav tau ua cov ntaub ntawv ua ntej ua ntej kev cob qhia lossis kev sim. Qhov no tuaj yeem suav nrog kev ntsuas cov duab lossis cov yeeb yaj kiab, ua qauv rau cov txiaj ntsig pixel, lossis siv txoj hauv kev rau cov ntaub ntawv augmentation.
Tom qab ua tiav cov kauj ruam no, koj cov ntaub ntawv npaj txhij.
Khiav cov ntawv txheeb xyuas
Ntawm no yog ib qho piv txwv ntawm ib tsab ntawv tshawb nrhiav uas txheeb xyuas daim duab thiab pom cov khoom.
import yolov5
import cv2
# Pre-trained weights should be loaded.
weights = 'path/to/weights.pt'
# Set the detection confidence level
conf_thres = 0.5
# Set the Non-Maxima Suppression (NMS) threshold
nms_thres = 0.5
# Create the detector object
detector = yolov5.YOLOv5(weights, conf_thres, nms_thres)
# Load the image
img = cv2.imread('path/to/image')
# Perform object detection
detections = detector.detect(img)
# Print the detections
for x1, y1, x2, y2, conf, cls_conf, cls_pred in detections:
print("Object:", classes[int(cls_pred)])
print("Confidence:", conf)
print("Bounding box:", (x1, y1, x2, y2))
Tom qab ua
Kev txwv tsis pub tshaj yog ib qho ntawm cov txheej txheem tom qab ua tiav ntau zaus siv hauv kev tshawb nrhiav khoom (NMS). Peb siv NMS txhawm rau tshem tawm cov thawv sib tshooj rau tib yam khoom. Txhawm rau ua tiav NMS ntawm kev kuaj pom, peb tuaj yeem siv OpenCV lub tsev qiv ntawv cv2.dnn.NMSBoxes() txoj kev.
Nov yog ib qho piv txwv ntawm yuav ua li cas tom qab cov txheej txheem tshawb pom siv NMS.
import cv2
# Perform Non-Maxima Suppression (NMS)
indices = cv2.dnn.NMSBoxes(detections, trusts, conf_thres, nms_thres)
visualization
Nyob rau hauv cov ntaub ntawv ntawm kev pom, peb tuaj yeem rov siv lub tsev qiv ntawv zoo li OpenCV. Peb tuaj yeem tso saib cov thawv khij ib ncig ntawm cov khoom pom ntawm daim duab lossis yees duab. Txhawm rau kos duab lub thawv khi, siv cv2.rectangle() txoj kev. Nov yog yuav ua li cas saib cov kev kuaj pom ntawm daim duab qub:
npe cv2
# Draw the bounding boxes on the image
rau kuv hauv indices:
i = i[0]
x1, y1, x2, y2 = detections[i][0], detections[i][1], detections[i][2], detections[i][3]
cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 0), 2)
cv2.putText(img, classes[class_ids[i]], (x1, y1), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
# Show the image
cv2.imshow("Object Detection", img)
cv2
daim ntawv sau npe
YOLOv5 yog tus qauv kev txheeb xyuas cov khoom muaj zog. Yog li, peb tuaj yeem siv nws hauv ntau qhov xwm txheej tiag tiag. Ib qho ntawm cov kev siv tseem ceeb tshaj plaws yog nyob rau hauv lub tsheb tsav tus kheej. YOLOv5 tuaj yeem txheeb xyuas cov khoom hauv lub sijhawm tiag tiag xws li tsheb thiab teeb pom kev.
Hauv kev soj ntsuam, peb tuaj yeem siv YOLOv5 kom paub txog thiab taug qab cov khoom hauv cov kwj video nyob. Tsis tas li ntawd, YOLOv5 tuaj yeem yog ib qho khoom muaj nqis zoo hauv cov neeg hlau. Nws tuaj yeem pab cov neeg hlau ntes thiab nkag siab txog lawv qhov chaw nyob ib puag ncig. Qhov no tseem ceeb heev rau kev ua ub no xws li navigation thiab manipulation.
YOLOv5 kuj tseem tuaj yeem siv rau hauv txhua qhov kev lag luam uas yuav tsum tau tshawb pom cov khoom, xws li khw muag khoom, kev ua kis las, kev kho mob, thiab kev ruaj ntseg.
xaus
Thaum kawg, YOLOv5 yog qhov tsis ntev los no thiab sophisticated version ntawm YOLO tsev neeg ntawm nrhiav pom khoom Qauv
. Tsis tas li ntawd, nws yog qhov ncaj ncees hais tias nws yog qhov tseeb tshaj plaws cov khoom kuaj pom tus qauv muaj. Ua tsaug rau nws qhov raug siab thiab ceev, koj tuaj yeem xaiv nws yam xyuam xim rau koj qhov project nrhiav pom.
Resky Agus
Kuv ua thawj phau ntawv xov xwm txog kev tshawb nrhiav tsheb nrog yolov5 thiab lub vev xaib no pab kuv tshawb nrhiav cov ntaub ntawv hais txog qhov ntawd.
Kuv txaus siab heev txog AI.
yog tias koj tuaj yeem kuv muaj lus nug ntau txog AI tej zaum koj tuaj yeem pab kuv
Ua tsaug