I am trying to perform inference on my custom YOLOv5 model. The official documentation uses the default detect.py
script for inference.
Example: python detect.py --source data/images --weights yolov5s.pt --conf 0.25
I have written my own python script but I can neither set the confidence threshold during initialisation nor retrieve it from the predictions of the model. I am only able to get the labels and bounding box coordinates. Here is my code:
import torch
model = torch.hub.load('ultralytics/yolov5', 'custom', path_or_model='best.pt')
results = model("my_image.png")
labels, cord_thres = results.xyxyn[0][:, -1].numpy(), results.xyxyn[0][:, :-1].numpy()