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

What is the purpose of anchor_t? #1310

Closed
Uoops opened this issue Nov 6, 2020 · 9 comments
Closed

What is the purpose of anchor_t? #1310

Uoops opened this issue Nov 6, 2020 · 9 comments
Labels
question Further information is requested Stale

Comments

@Uoops
Copy link

Uoops commented Nov 6, 2020

❔Question

Thank you for sharing your work! It is the best YOLO related repo in python I have ever seen!

Can you explain what anchor_t means and what it does in the training process?

The reason is that I notice you use anchor_t instead of iou_t to generate the targets compared to your YOLOv3 work. I think iou_t is for the classification, can anchor_t does the same thing?
# Matches
r = t[:, :, 4:6] / anchors[:, None] # wh ratio
j = torch.max(r, 1. / r).max(2)[0] < model.hyp['anchor_t'] # compare
# j = wh_iou(anchors, t[:, 4:6]) > model.hyp['iou_t'] # iou(3,n)=wh_iou(anchors(3,2), gwh(n,2))
t = t[j] # filter

Additional context

The code above is copied from yolov5/utils/general.py line 565

@Uoops Uoops added the question Further information is requested label Nov 6, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2020

Hello @Uoops, 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 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.

@glenn-jocher
Copy link
Member

glenn-jocher commented Nov 6, 2020

@Uoops yes, we use anchor_t instead of iou_t in YOLOv5. These are both thresholds for deciding which labels to match to which anchors.

Using anchor_t now provides certainty that anchors are always capable of fitting a given label, and also allows you to program the range of the width-height outputs to most efficiently occupy the width-height space.

@GorillaSX
Copy link

hey @glenn-jocher , thanks for your answer for the purpose of anchor_t. But I kind of don't understand the logic and algorithm behind anchor_t, so would you mind give me a hint or share the algorithm name you're using here? I believe a good understanding of anchor_t, could help us to set right threshold here. I appreciate it.

@GorillaSX
Copy link

hey @glenn-jocher , I think I figured it out.

@glenn-jocher
Copy link
Member

@GorillaSX anchor_t is the anchor width and height multiple threshold used to select label-anchor matches when computing loss.

@GorillaSX
Copy link

hey @glenn-jocher thanks for your answer. I understood that. What confused me is those two lines code,

 r = t[:, :, 4:6] / anchors[:, None]  # wh ratio
 j = torch.max(r, 1. / r).max(2)[0] < model.hyp['anchor_t']  # compar

But I think I figured it out at this time, still thanks.

@glenn-jocher
Copy link
Member

j are target-anchor match candidates.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@lfydegithub
Copy link

lfydegithub commented Jan 11, 2021

@GorillaSX anchor_t is the anchor width and height multiple threshold used to select label-anchor matches when computing loss.

thank you for your reply, so how to get my dataset anchor_t threshold ? appreciate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

4 participants