I am trying to build a yolov5 object detection model using parts of a model car. I took 200 pictures of each part, annotated them and trained the model for 50 epochs. Now, the model does not recognize the parts well at all and I don’t know why.
What is curious is, that I trained on just 111 images less in total before and the model worked quite well then (except for one car part). What could I do to improve the results?
This is the code:
import torch
import cv2
import numpy as np
model = torch.hub.load('ultralytics_yolov5_master', 'custom', path='ultralytics_yolov5_master/runs/train/exp3/weights/best.pt', source='local', force_reload=True)
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, frame = cap.read()
results = model(frame)
cv2.imshow("YOLO", np.squeeze(results.render()))
if cv2.waitKey(10) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
These are some example training images: