我想打印出我受过训练的模型的准确性。我明白当我通过相机使用模型时,它只显示在盒子上的准确性,但我想看到我的整个模型的准确性,而不是我的图像的一个实例。
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.ptmodel = 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)发布于 2022-05-10 12:45:17
Yolov5模型没有像准确性这样的特殊特性。相反,您可以使用框架中检测到的每个对象的confidence。
在命令行中传递--save-conf和
python3 detect.py --weights '' --source '' --save-conf
https://stackoverflow.com/questions/72148513
复制相似问题