-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get original pixel coordinates ? #2807
Comments
👋 Hello @haspberry, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com. RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
You can use the function scale_coords in utils.general that is in this repository Btw this is my code hope it can help to understand how to use it. Search for the name of the function with CTRL+F and you can find it and understand deeper
|
@haspberry yes you can use scale_coords() from within detect.py as @GiorgioSgl mentioned, or you can also use YOLOv5 PyTorch Hub models to return detections in xyxy native image space: import torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
# Images
dir = 'https://github.com/ultralytics/yolov5/raw/master/data/images/'
imgs = [dir + f for f in ('zidane.jpg', 'bus.jpg')] # batch of images
# Inference
results = model(imgs)
results.print() # or .show(), .save()
print(results.pandas().xyxy[0]) Downloading https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt to yolov5s.pt...
100%|██████████| 14.1M/14.1M [00:00<00:00, 22.7MB/s]
Adding autoShape...
YOLOv5 🚀 2021-4-15 torch 1.8.1 CPU
image 1/2: 720x1280 2 persons, 2 ties
image 2/2: 1080x810 4 persons, 1 bus
Speed: 710.2ms pre-process, 275.3ms inference, 1.5ms NMS per image at shape (2, 3, 640, 640)
xmin ymin xmax ymax confidence class name
0 749.472046 43.656982 1147.645874 704.565063 0.874176 0 person
1 433.666870 433.769470 517.574951 714.643982 0.688576 27 tie
2 115.053345 195.761230 1095.530273 708.221436 0.625422 0 person
3 986.198303 304.159058 1028.016602 420.192871 0.286980 27 tie See PyTorch Hub Tutorial for details: YOLOv5 Tutorials
|
@glenn-jocher @GiorgioSgl |
❔Question
I used the 'xywh2xyxy' function in 'general.py' to get the 'xyxy' value. I thought this was the original pixel coordinates. But it seemed to come out as the pixel coordinates coming out of each grid.
ex.
0: 384x640 2 persons, 1 backpack, 1 chair, 1 tv, 1 keyboard, Done. (1.326s)
[object num x y w h]
56 0.316146 0.593982 0.159375 0.410185
24 0.316406 0.59537 0.160938 0.405556
62 0.0744792 0.437963 0.0572917 0.116667
0 0.527083 0.417593 0.0666667 0.238889
66 0.815625 0.873148 0.365625 0.246296
0 0.442969 0.465741 0.139062 0.366667
[x y x y]
[[0.23645833134651184, 0.3888888955116272, 0.3958333432674408, 0.799074113368988], [0.23593750596046448, 0.39259257912635803, 0.3968749940395355, 0.7981481552124023], [0.04583333432674408,
0.37962961196899414, 0.10312500596046448, 0.4962962865829468], [0.4937500059604645, 0.29814815521240234, 0.5604166984558105, 0.5370370149612427], [0.6328125, 0.75, 0.9984375238418579, 0.9
962962865829468], [0.3734375238418579, 0.28240740299224854, 0.512499988079071, 0.6490740776062012]]
The above values look like coordinates for each grid. Is that right?
But I want to get the bounding box x1,y1,x2,y2 values at the original ('384x640') pixel.
The text was updated successfully, but these errors were encountered: