To detect birds and squirrels, we created a dataset to train the YOLOv5 model. After a week’s training with:
Shell
x
1
1
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.
Python
1
12
12
1
import inspect
2
import torch
3
import cv2
4
5
model = torch.hub.load('.', 'custom', path='last.pt', source='local')
6
#model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
7
model.eval()
8
9
image = cv2.imread(img)
10
results = model(img, size=960)
11
results.show()
12
The result is below for model(img, size=960)

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