How to set and get confidence threshold from custom YOLOv5 model?
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(&quot;my_image.png&quot;)
labels, cord_thres = results.xyxyn[0][:, -1].numpy(), results.xyxyn[0][:, :-1].numpy()


It works for me:
model.conf = 0.25  # confidence threshold (0-1)
model.iou = 0.45  # NMS IoU threshold (0-1)  

More information:
https://github.com/ultralytics/yolov5/issues/36
