首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >YOLOv5模型的打印精度?

YOLOv5模型的打印精度?
EN

Stack Overflow用户
提问于 2022-05-07 00:17:21
回答 1查看 1.3K关注 0票数 0

我想打印出我受过训练的模型的准确性。我明白当我通过相机使用模型时,它只显示在盒子上的准确性,但我想看到我的整个模型的准确性,而不是我的图像的一个实例。

代码语言:javascript
复制
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()
代码语言:javascript
复制
!cd yolov5 && python train.py --img 320 --batch 16 --epochs 500 --data dataset.yml --weights yolov5s.pt
代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2022-05-10 12:45:17

Yolov5模型没有像准确性这样的特殊特性。相反,您可以使用框架中检测到的每个对象的confidence

在命令行中传递--save-conf

python3 detect.py --weights '' --source '' --save-conf

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72148513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档