I'm using this code to load the yolov5 model model = torch.hub.load('ultralytics/yolov5', 'custom', 'C:\Object Detection\yolov5_object_detection\last.pt')
and how can I retrieve the confidence value after the model detected on an image?
Load the model, feed an image to it, loop through the predictions and extract their contents.
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
model.eval()
det = model(img) # feed image
for *xyxy, conf, cls in det: # loop through results and extract contents
print(*xyxy)
print(conf) # what you are looking for
print(cls)