I just download the pre-trained model and try to predict. But this model detect too many boxes and wrong objects.
from ultralytics import YOLO
import cv2
from PIL import Image
model = YOLO("yolov5nu.pt")
model.info()
im1 = Image.open("images/giraffe.jpg")
results = model.predict(source=im1, save=True, save_txt=True)
cv2.imshow("YOLOv5 Detection", results[0].plot())
cv2.waitKey(0)
cv2.destroyAllWindows()
This is my code, it is very simple.
enter image description here
This is original image
enter image description here
This is result image
Log:
77 persons, 6 motorcycles, 4 buss, 1 truck, 14 traffic lights, 64 fire hydrants, 3 stop signs, 11 parking meters, 7 handbags, 3 snowboards, 20 sports balls, 7 baseball bats, 62 bottles, 3 spoons, 1 hot dog, 1 mouse, 1 remote, 2 vases, 2 hair driers, 11 toothbrushs, 481.0ms
Speed: 5.0ms preprocess, 481.0ms inference, 3.0ms postprocess per image at shape (1, 3, 640, 640)
What happened? The result is really weired. Do I need to re-train this model?
Yiming Li is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.