-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
Anchors #503
Comments
I have a similar problem when computing anchors using In particular, there is one line executed after computing anchors with I am currently using the modification from #462 . |
@maxjcohen @JiaLim98 anchors may be supplied in your model.yaml file as you have shown above. AutoAnchor runs before training to ensure your anchors are a good fit for your data. If they are not, then new anchors are computed and evolved and attached to your model automatically. No action is needed on your part. You can disable autoanchor with Strongly advise to git clone the latest repo (often), there have been many recent updates and bug fixes. |
@maxjcohen Thank you for the information |
@JiaLim98 your yaml is never modified. AutoAnchor will attach anchors automatically to your model.pt file (i.e. last.pt or best.pt). If AutoAnchor computes anchors it will be obvious, it displays them to you and even advises you to update your yaml if you'd like to reuse them in the future. |
@glenn-jocher I see. Which way do you advise to open the .pt files? |
You can visualize with Netron also. |
@glenn-jocher Thank you very much. Sorry for inconvenience caused as I'm new to object detection. |
@glenn-jocher Another question. I can't seem to find the best weights saved in the weights folder or the runs folder. I have tried both --nosave of value true and false. Can you point it out to me? |
@JiaLim98 don't use nosave. Just start from the colab notebook and follow the examples there. The code displays to you where your models are saved after training completes.
|
@glenn-jocher Yes, I know about the weights for last epoch. Previously, there is best and last weights right? Or is the last.pt shown here is the best weights? |
@JiaLim98 last.pt is the last weights. best.pt is the best weights. Just use the notebook and run the tutorial. |
Hi,I want to extract the anchors and use it in the future .According to your idea. you mean AutoAnchor will save anchors automatically to the best.pt file , I use netron to open best.pt file ,but i do not know where the anchors be saved ? just found Detect layer has some parameters , Could you tell me where the anchors be saved or how to extract the anchors ? Thanks ! |
@china56321 AutoAnchor displays the computed anchors on screen and advises you to update your yaml if you'd like to use them in the future. |
|
No. After that, it will say analyzing anchors... |
@china56321 it's very obvious, it prints everything out for you. |
OK, thank you! |
@china56321 right. Your anchors were analyzed against your dataset and a best possible recall was computed. This BPR is high enough not to warrant anchor recomputation. No new anchors were calculated for you. |
Dear @glenn-jocher , |
@edwardnguyen1705 anchors are never changed on a trained model. Also, you should train at the same size you intend to run inference at for best results. |
@glenn-jocher thank you for your information. |
@glenn-jocher Can you explain the evolution of anchors after kmean based anchor computation? |
@abhiagwl4262 a genetic evolution optimizer runs on the anchors following a kmeans scan. Fitness function is the same as the regression loss used in loss.py. Code is below. Lines 23 to 56 in 73a0669
|
Can somebody explain to me or point to me to a documents that explains what the lines anchors:
|
@Yashar78 depth and width multiple are YOLOv5 compound scaling constants inspired by EfficientDet: Anchors are model anchors, all YOLO models use these to normalize outputs. |
anchors:
How can I reproduce these anchors ? |
@abhiagwl4262 I'm sorry I don't understand the question. You can manually specify anchors in your model.yaml file: Lines 1 to 11 in 238583b
|
@glenn-jocher What I am trying to say is... we have algorithm that can generate custom anchors for any data. The anchors defined in yolov5/models/yolov5s.yaml are used for training on COCO data. Are the following anchors being calculated using the same algorithm?
|
@abhiagwl4262 hey buddy. I think these anchors are simply adopted from the original YOLOv3 anchors by Josheph Redmon at https://github.com/pjreddie/darknet, or if not then they are generated by YOLOv5 autoanchor. |
@glenn-jocher Yeah, They have been taken from YOLOv3 directly. The anchors being calculated by autoanchor algorithm are not matching with the once taken from YOLOv3. Didn't you guys think of using custom ones ? |
@abhiagwl4262 if the anchors are unmodified then auto-anchor has determined that they are suitable for training as-is. Our YOLOv5-P6 models use auto-anchor evolved anchors for example (for training at --img 1280): yolov5/models/hub/yolov5s6.yaml Lines 6 to 12 in 238583b
|
@glenn-jocher Btw, I did run training for multiple datasets and custom anchors always improve the results irrespective of the good BPR value from the anchors given for COCO. |
@abhiagwl4262 oh interesting, thanks for the feedback! It looks like autoanchor is working well for your use case then :) One trick to force autoanchor to create new anchors in all cases is to raise the BPR threshold from 0.98 to 1.0 here on L43 of autoanchor.py: Lines 40 to 44 in 1df8c6c
|
Hi Ultralytics,
First of all, thank you so much for the interesting work and sharing.
❔Question
I mainly have three questions to ask:
Size of anchors
![image](https://user-images.githubusercontent.com/66768413/88381093-4d326600-cdd8-11ea-8cd3-0f6ac2e28271.png)
May I know why the anchors are much bigger than the scale of the Feature Pyramid Network?
bpr of computed anchors
![image](https://user-images.githubusercontent.com/66768413/88381341-d184e900-cdd8-11ea-8ff4-af42b67d6c3a.png)
I wanted to know what my anchors are so I computed them using kmean_anchors in utils.py. May I know why both anchors can reach a bpr of 1.0000? This is because there are quite a big difference between them and I wanted to know whether the default anchors or kmean anchors works better for my data.
Source of anchors
Where does the model take anchors from? Is it from the configuration files shown above or they are calculated everytime? This is because from Q2 above, both anchors achieved bpr of 1. That makes me question does the model use that anchors.
Best regards,
JiaLim98
The text was updated successfully, but these errors were encountered: