-
Notifications
You must be signed in to change notification settings - Fork 96
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 possibly are not in harmony with the annotations #8
Comments
Also I trained the model with new anchors and as we can predict, it reduced the accuracy (both IoU and recall). 1% reduction in IoU and 10% reduction in Recall. |
Hi @VanitarNordic , For example, Let me know if it doesn't improve your performance. |
Hello Jumabek, Actually I don't think it would solve the case, do you know why? Another unknown facts about YOLO is that is not clear to how fine-tune it. The provided |
Once your centroïds are computed, have you tried to compute the number of elements in each cluster ? it might be there is a collapse where all boxes fall into the same cluster, except a few of them. To compute the assignments, use the following code |
@christopher5106 |
yes |
It might be you have in your dataset a few anchors 'very different' and these atypic anchors can create their own cluster of 1 element... |
Not actually, my dataset is small and I can say I remember all of its images. All are square like annotations. Also I mentioned that training with these new anchors made the results worse, not better. That's the proof. |
I propose you run the assignment on the anchors you got and you'll tell me the number of elements per cluster. That will give me the only way to analyze the result of the clustering. |
The
|
right, and then compute the number of elements per cluster. |
one_hot = np.zeros ((N,k)) |
This is the whole output:
|
Sounds the clusters are well balanced. Now a new question arises: in annotation_dims, how have your values w,h been normalized ?If you normalize by dividing box_width by image_width and box_height by image_height, that won't work because your images are not all square. You need to normalize box_width and box_height by the same factor, for example np.max( image_height, image_width). |
yes my images are not square of course. they have different sizes like VOC. if that's the key, do YOLO authors have converted VOC annotations using a script, with your consideration? |
So, now you have your answer: since images are resized to 416x416 in some Yolo implementations without preserving the ratio, it is normal that you get some rectangles since squares become rectangles after the resize |
Are you sure about this? because you know keeping the ratio is in relation with width and height of the image, not a fixed number. if all images were square then width and height are equal. then we were dividing X and Y by the same number, but because width and height are not equal, then each coordinate must be divided by its own related number otherwise we have made the bounding box just smaller. Actually we are calculating the relation of a bounding box to the whole image, |
When you compute the new centroids in https://github.com/Jumabek/darknet_scripts/blob/master/gen_anchors.py#L98-L102 |
Yes, I think so. Then what's your point? You mean we should still divide the all absolute coordinates by a number such as |
Yes, you multiply them back by image_width or image_height depending it is width or height, and then devides by np.max( image_height, image_width) |
The images which are used to calculate the anchors here, are the same images which will be used to train and validate the network actually. So I think it should work by default, isn't it? |
It works by default. |
Alright, Thank you very much. I have nothing to say except than I must test this and I'll tell you the results. in the meantime, do you have any information about transfer learning the YOLO? Some people say that I should partial the VOC trained weight except than the last |
if you just re initialize the last layer weights, it is transfer learning |
Excuse me christopher. I still have a confusion with my friends. Forget about anchors. Just this question. How should the relative coordinates be calculated? |
If you want the ratio to be preserved, you divide the dimensions by np.max( image_height, image_width) or even you don't normalize them, you keep them in pixels but then you need to implement yolo the way it is written in my article then... |
The thing is I don't know which is the best to get a higher accuracy. What the original authors have used. They used your method or used ordinary division with width and height. This is the core calculation of what authors suggest to convert VOC
|
to my point of view, your clusters are well balanced, so that's ok |
I was just answering why you did not get square anchor boxes: this is due to the resize of the image to a square |
@christopher5106, thanks for helping out |
Your convert function is right, relative to what the yolo authors have done. |
Hello,
I have a dataset with 1 class which is apple. Apple is an object with almost square annotations, in whatever scales of the object.
But when I visualize the anchors, it shows some long rectangles, I mean their width and their heights are very different, except than the yellow one. is this correct?
The text was updated successfully, but these errors were encountered: