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

How to fill the 'ANCHORS' in yolo.py? #23

Closed
brucelee78 opened this issue Nov 2, 2020 · 2 comments
Closed

How to fill the 'ANCHORS' in yolo.py? #23

brucelee78 opened this issue Nov 2, 2020 · 2 comments
Labels
question Further information is requested

Comments

@brucelee78
Copy link

Hello , thank you to open your code!
i want to use it detect the airplane which is used our own datasets, and need to change the anchors in darknet(YOLOv4) cfg file
so if I use your code ,how to fill the ANCHORS in yolo.py? Could you give a example to achieve it ?
because i don't understand that You need to mask out the anchors for each yolo layer using the indices in mask. For tiny and YOLOv3, the anchors are usually flipped. this sentence in README..md

for a instance , my anchors are 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
and how to fill the 'ANCHORS' in yolo.py?
Thank you very much!

@GeekAlexis
Copy link
Owner

GeekAlexis commented Nov 2, 2020

@brucelee78 Darknet uses a list of indices (mask) to define which anchors to use in each YOLO layer. For example, if the first YOLO layer has a mask of [0, 1, 2], then in your case the anchors would be [12, 16, 19, 36, 40, 28] for the first YOLO layer.

Repeat the above step for the second and third layers. Group anchors for all YOLO layers to get [[12, 16, 19, 36, 40, 28], [36, 75, 76, 55, 72, 146], [142, 110, 192, 243, 459, 401]]. For YOLOv4, the order of anchors should be the same in your cfg file because the masks are [0, 1, 2], [3, 4, 5], [6, 7, 8]. For YOLOv3, the masks are in the order of [6, 7, 8], [3, 4, 5], [0, 1, 2], which is in reverse.

@GeekAlexis GeekAlexis added the question Further information is requested label Nov 2, 2020
@brucelee78
Copy link
Author

@brucelee78 Darknet uses a list of indices (mask) to define which anchors to use in each YOLO layer. For example, if the first YOLO layer has a mask of [0, 1, 2], then in your case the anchors would be [12, 16, 19, 36, 40, 28] for the first YOLO layer.

Repeat the above step for the second and third layers. Group anchors for all YOLO layers to get [[12, 16, 19, 36, 40, 28], [36, 75, 76, 55, 72, 146], [142, 110, 192, 243, 459, 401]]. For YOLOv4, the order of anchors should be the same in your cfg file because the masks are [0, 1, 2], [3, 4, 5], [6, 7, 8]. For YOLOv3, the masks are in the order of [6, 7, 8], [3, 4, 5], [0, 1, 2], which is in reverse.

OK, I get it , Thank you for your detail reply!

@GeekAlexis GeekAlexis pinned this issue Jul 3, 2021
@GeekAlexis GeekAlexis changed the title Could you give a instance that how to fill the 'ANCHORS' in yolo.py? How to fill the 'ANCHORS' in yolo.py? Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants