Skip to content

Correctness of flip formula #248

Description

@ratthachat

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions