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

Chapter 5 method xyxyh2xywh #5

Open
wvalcke opened this issue Aug 7, 2020 · 3 comments
Open

Chapter 5 method xyxyh2xywh #5

wvalcke opened this issue Aug 7, 2020 · 3 comments

Comments

@wvalcke
Copy link

wvalcke commented Aug 7, 2020

In the implementation :

  def xyxyh2xywh(xyxy, image_size=416):
      xywh = torch.zeros(xyxy.shape[0],6)
      xywh[:,2] = (xyxy[:, 0] + xyxy[:, 2]) / 2./img_size
      xywh[:,3] = (xyxy[:, 1] + xyxy[:, 3]) / 2./img_size
      xywh[:,5] = (xyxy[:, 2] - xyxy[:, 0])/img_size 
      xywh[:,4] = (xyxy[:, 3] - xyxy[:, 1])/img_size
      xywh[:,1]= xyxy[:,6]    
      return xywh

i think that it should be

  def xyxyh2xywh(xyxy, image_size=416):
      xywh = torch.zeros(xyxy.shape[0],6)
      xywh[:,2] = (xyxy[:, 0] + xyxy[:, 2]) / 2./img_size
      xywh[:,3] = (xyxy[:, 1] + xyxy[:, 3]) / 2./img_size
      xywh[:,4] = (xyxy[:, 2] - xyxy[:, 0])/img_size 
      xywh[:,5] = (xyxy[:, 3] - xyxy[:, 1])/img_size
      xywh[:,1]= xyxy[:,6]    
      return xywh
@mave5
Copy link
Collaborator

mave5 commented Aug 14, 2020

Thanks @wvalcke for reporting this bug. You are correct.

@bgpantojar
Copy link

@wvalcke what is exactly the difference between the two functions you are showing. For me they are exactly the same, aren't they?

@mralamdari
Copy link

The Difference is in replacing places of 4 and 5
So in other words, Turn These:

xywh[:,5] = (xyxy[:, 2] - xyxy[:, 0])/img_size
xywh[:,4] = (xyxy[:, 3] - xyxy[:, 1])/img_size

To These:
xywh[:,4] = (xyxy[:, 2] - xyxy[:, 0])/img_size
xywh[:,5] = (xyxy[:, 3] - xyxy[:, 1])/img_size

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

No branches or pull requests

4 participants