Skip to content
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

Correctness of flip formula #248

Closed
ratthachat opened this issue Jun 30, 2020 · 2 comments · Fixed by #3882
Closed

Correctness of flip formula #248

ratthachat opened this issue Jun 30, 2020 · 2 comments · Fixed by #3882

Comments

@ratthachat
Copy link

ratthachat commented Jun 30, 2020

First of all thanks so much for making this Yolo V5! It's now the best model in Kaggle Wheat detection : https://www.kaggle.com/c/global-wheat-detection

Trying to modify TTA, I found you use the following lr-flip formula for bbox :

In models/yolo.py
y[1][..., 0] = img_size[1] - y[1][..., 0] # flip lr ---- Equation (1)

I have checked on Yolo V3 and it's the same, so I am sure the formula is correct.

However, in my understanding we should change both xmin and xmax for lr-flip but the formula above only change xmin.
For examples, the famous albumentations formula is :

https://github.com/albumentations-team/albumentations/blob/master/albumentations/augmentations/functional.py
In def bbox_hflip
new_xmin, new_ymin, new_xmax, new_ymax = 1 - x_max, y_min, 1 - x_min, y_max

Or explained intuitively here : https://blog.paperspace.com/data-augmentation-for-bounding-boxes/

So my question is how can the above equation (1) is correct ??
It should be

y[1][..., 2] = img_size[1] - y[1][..., 0] # flip lr new xmax
y[1][..., 0] = img_size[1] - y[1][..., 2] # flip lr new xmin

EDIT : I got it. Yolo use xcenter, ycenter, w, h, so it explains Equation (1) . Close the issue.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 30, 2020

Hello @ratthachat, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

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 model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

@ratthachat ratthachat changed the title About flip formula Correctness of flip formula Jun 30, 2020
@glenn-jocher
Copy link
Member

Yes, xywh format.

@glenn-jocher glenn-jocher linked a pull request Jul 4, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants