[英]Print accuracy for YOLOv5 model?
我想打印我訓練過的 model 的准確度。我明白當我通過相機使用 model 時它只顯示盒子上的准確度,但我想看到我的整個 model 的准確度而不是我的單個實例圖片。
cap = cv2.VideoCapture(0)
# loop through labels
for label in labels:
print('Collecting images for {}'.format(label)) #so that we can see when transitioning through images
time.sleep(5) #sleep or wait for 5 seconds when transitioning between image for other class
# Loop through image range
for img_num in range(number_imgs):
print('Collecting images for {}, image number {}'.format(label, img_num))
# webcam feed
ret, frame = cap.read() # read the feed from the web cam and store it in given vars
# Naming image path
imgname = os.path.join(IMAGES_PATH, label+'.'+str(uuid.uuid1())+'.jpg')
#Writes out image to file
cv2.imwrite(imgname,frame)
# Render to screen
cv2.imshow('Image Collection', frame)
# 2 sec delay between diff captures
time.sleep(2)
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
!cd yolov5 && python train.py --img 320 --batch 16 --epochs 500 --data dataset.yml --weights yolov5s.pt
model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5/runs/train/exp/weights/last.pt', force_reload=True)
while cap.isOpened():
ret, frame = cap.read()
# Make detections
results = model(frame)
cv2.imshow('YOLO', np.squeeze(results.render()))
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
cv2.waitKey(1)
Yolov5 model 沒有像准確性這樣的特殊功能。 相反,您可以使用幀中檢測到的每個 object 的confidence
度。
您可以通過在命令行中傳遞--save-conf
來獲得
python3 detect.py --weights '' --source '' --save-conf
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.