-
I recently came across yolov5 and thought it was very cool, naturally, I started experimenting with implementations, but when it came to a project where I needed the coordinates I could only get complicated numbers instead of pixel coordinates. here is what I got. tensor([[7.49630e+02, 4.29638e+01, 1.14836e+03, 7.08850e+02, 8.77349e-01, 0.00000e+00], I am using python for this and am wondering how I can change the first 4 numbers into pixel coordinates, or if there is another better way of doing this. Here is my code import torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
# Image
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg' # batched list of images
# Inference
results = model(img)
# Results
results.print()
results.show() # or .show()
# Data
print(results.xyxy[0]) # print img1 predictions (pixels)
# x1 y1 x2 y2 confidence class
# tensor([[7.50637e+02, 4.37279e+01, 1.15887e+03, 7.08682e+02, 8.18137e-01, 0.00000e+00],
# [9.33597e+01, 2.07387e+02, 1.04737e+03, 7.10224e+02, 5.78011e-01, 0.00000e+00],
# [4.24503e+02, 4.29092e+02, 5.16300e+02, 7.16425e+02, 5.68713e-01, 2.70000e+01]]) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I actually found this answer after searching for it for what seems like the 100'th time, so here it is. print(results.pandas().xyxy[0]) |
Beta Was this translation helpful? Give feedback.
I actually found this answer after searching for it for what seems like the 100'th time, so here it is.