IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    A trick for using YOLOv5

    RobinDong发表于 2022-09-30 04:32:28
    love 0

    To detect birds and squirrels, we created a dataset to train the YOLOv5 model. After a week’s training with:

    python3 -u train.py --data coco.yaml --cfg yolov5s.yaml --weights '' --batch-size 28 --workers 1

    The model could recognize birds and squirrels properly except only for this image:

    Why does the model recognize the right-side significant squirrel as a bird? Even though I tried a bigger model, the result was the same…

    Only after researching the parameters of the function model() of YOLOv5, I found out we can use a different image size: 960 for detecting.

    import inspect
    import torch
    import cv2
    
    model = torch.hub.load('.', 'custom', path='last.pt', source='local')
    #model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
    model.eval()
    
    image = cv2.imread(img)
    results = model(img, size=960)
    results.show()
    

    The result is below for model(img, size=960)

    Hmm, seems the single-stage YOLOv5 model is nearsighted, just like me…



沪ICP备19023445号-2号
友情链接