yolov5 icon indicating copy to clipboard operation
yolov5 copied to clipboard

The center of annotated bound box change position

Open frabob2017 opened this issue 2 years ago • 10 comments

Search before asking

  • [X] I have searched the YOLOv5 issues and discussions and found no similar questions.

Question

I found that annotation position is not what I expect.

For example, This data is image 601_151, its coordinate system is [0 0.40795277343749997 0.37763712890625 0.0997937890625 0.0438759765625]. The coordinate system I use is left top is 0,0 ; right bottom is 1,1;

601_151

This is the correct bounding box. I use python to read coordinate information and overlap it to image confirm its correction position.

But after I upload data to YoloV5, its label image created by YoloV5 (left side ) vs I use python to overlap bounding box (right side, correct position )

comparison

601_151.txt

any clues?

import PIL import matplotlib.pyplot as plt import matplotlib.patches as patches

fig, axs = plt.subplots(nrows, ncols, figsize=(24,15)) axs = axs.flatten()

ds = PIL.Image.open('601_151.jpg') axs[0].imshow(ds, cmap="bone") axs[0].axis("off")

normalized_cordinate = [0.40795277343749997, 0.37763712890625, 0.0997937890625, 0.0438759765625] x = 512normalized_cordinate[0] y = 512normalized_cordinate[1] width = 512normalized_cordinate[2] height = 512normalized_cordinate[3]

rect = patches.Rectangle((x, y), width, height, fill=False, edgecolor="red", linewidth=1.0) axs[0].add_patch(rect)

Additional

No response

frabob2017 avatar Sep 14 '22 02:09 frabob2017

👋 Hello @frabob2017, 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://ultralytics.com or email [email protected].

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If 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), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.

github-actions[bot] avatar Sep 14 '22 02:09 github-actions[bot]

But after I upload data to YoloV5, its label image created by YoloV5 (left side )

By this, do you mean the train_batch_01, 02, 03.jpgs created when training is started?

MartinPedersenpp avatar Sep 14 '22 06:09 MartinPedersenpp

Hello Martin,

Yes, it is the val_batch1_labels.jpg, val_batch2_labels.jpg; val_batch3_labels.jpg. It is the labels program read from the ground truth labels. The position of bounding box shift. Frank

frabob2017 avatar Sep 14 '22 18:09 frabob2017

image

I just tried drawing the bounding box from your coordinates and it looks correct to me, are you sure you are using yolo annotations? class x center y center width height

MartinPedersenpp avatar Sep 14 '22 20:09 MartinPedersenpp

Hello Martin,

Thank you for your testing. You see, right side one is correct. It covers the fracture area. The left side one is NOT correct. I used Yolo format. [class x y width height] format. Radiologists I worked with draw ROI in CSV format. I convert their coordinate system to Yolo format. I tested it using Python. The position is correct. But I run in YoloV5, it is not correct, shifting a little bit.

I find the same issue when I upload the data to RoboFlow. Do you need the data, I can send you sample data for your testing.

Thank you.

frabob2017 avatar Sep 14 '22 20:09 frabob2017

Radiologist coordinate system is not normalized. What I did is normalized them. The image size is 512, 512; what I did is just normalized by 512.

frabob2017 avatar Sep 14 '22 20:09 frabob2017

Hello Martin,

Thank you for your testing. You see, right side one is correct. It covers the fracture area. The left side one is NOT correct. I used Yolo format. [class x y width height] format. Radiologists I worked with draw ROI in CSV format. I convert their coordinate system to Yolo format. I tested it using Python. The position is correct. But I run in YoloV5, it is not correct, shifting a little bit.

I find the same issue when I upload the data to RoboFlow. Do you need the data, I can send you sample data for your testing.

Thank you.

The one on the left is the one I drew from the coordinates you provided, so again, I think that your annotation might be wrong. Perhaps it is class x1 y1 width height where it should be class center_x center_y width height.

MartinPedersenpp avatar Sep 15 '22 06:09 MartinPedersenpp

Hello Martin, Thank you so much for help. I double check again PIL.rectangle(x,y), x,y is left bottom corner. I make a mistake and think it is center point. Thank you so much. It is also a great learning course for me.

frabob2017 avatar Sep 15 '22 14:09 frabob2017

👍🏼 glad to be of help. Please don't forget to mark the issue as solved if your problem has been solved.

MartinPedersenpp avatar Sep 15 '22 14:09 MartinPedersenpp

this problem is solved. thank you so much.

frabob2017 avatar Sep 17 '22 17:09 frabob2017

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

  • Wiki – https://github.com/ultralytics/yolov5/wiki
  • Tutorials – https://docs.ultralytics.com/yolov5
  • Docs – https://docs.ultralytics.com

Access additional Ultralytics ⚡ resources:

  • Ultralytics HUB – https://ultralytics.com/hub
  • Vision API – https://ultralytics.com/yolov5
  • About Us – https://ultralytics.com/about
  • Join Our Team – https://ultralytics.com/work
  • Contact Us – https://ultralytics.com/contact

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

github-actions[bot] avatar Oct 18 '22 00:10 github-actions[bot]

@frabob2017 you're welcome! If you have any more questions or need further assistance, feel free to ask. Happy coding!

glenn-jocher avatar Nov 15 '23 17:11 glenn-jocher