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

model struggles with long objects #617

Closed
holger-prause opened this issue Aug 24, 2022 · 5 comments
Closed

model struggles with long objects #617

holger-prause opened this issue Aug 24, 2022 · 5 comments

Comments

@holger-prause
Copy link

holger-prause commented Aug 24, 2022

Hello,
I trained a custom model(full yolov7 model and also tiny) for ui detection and its working pretty ok.
However , i am facing the same problem as with yolov4 - long textinputs or comboboxes or menu items are not recongized at all - when i decrease the the dimensions its picked up pixel perfect.

Is yolov7 capable of picking up such long objects or is there a conceptional problem because of the usage of anchor boxes ?

There is a possibility these long object are underrepresented (actually they are) but i got the feeling this is more of a conceptional problem as this happens across multiple classes. Is there anything i can do about this?
Any comment on this would be highly welcome.

@holger-prause
Copy link
Author

As noone really comments on this - it may be a data problem.
I will synthesize a dataset containing those long / huge objects only and train on it to get some more insights.

@trungpham2606
Copy link

you can check this issue ultralytics/yolov5#5556 for more information @holger-prause
your problem can come from dataset or the model itself, so let make sure the data was loaded correctly first.

@holger-prause
Copy link
Author

Data is definitivly loaded correctly - but yes i have really many image with different aspect ratios - and they are very different from the coco dataset. I have / had the hope that the auto anchor box calculation should take care of this.

However - i am getting rid of many small objects(noise created by synthetic sampling images) right now so maybe this fixes this implicitly.

@holger-prause
Copy link
Author

holger-prause commented Nov 9, 2022

Ok the i solved the problem the following way:

Open the file ./utils/datasets.py and replace ar_thr=20 with ar_thr=100.
I picked ar_thr=100 as this is the value used in the yolov5 source code.

A quick look at my training output shows me 0.91 map where it previously was 0.1. I see a quite big fluctuation in the map but this could be related to other things as well. Its left to see how it performs in reality and after converting the model to onnx and also training on a real dataset where i also have very small objects in it. But small and long object were fine on yolov5 so i expect same or better results on yolov7. In general i am pretty happy with yolov7 as it seems to generalize better and the bounding box quality is also way better than on yolov5.

@trungpham2606
You sir - are my personal hero and i want to give you a big hug and a free beer.
It still puzzles me a bit how you found this relevant piece of information - i did a lot of googling / research on this.
Sadly i did drifted off and tried to solve this issue by adding anchor boxes to fit the long objects better instead of reading your comment/ the comment you linked correctly.

After reading another post - see #760 (comment) i concluded that adding more anchors to fit the object better would be the right thing to do.

If you ever need my help let me know - i wont forget and keep my word (i am serious). Thank you so much!

@yigitsik
Copy link

yigitsik commented Jan 3, 2024

@holger-prause Hello,

I am trying to train ui elements like you did. I changed ar_thr to 100 and added more anchors. But map scores got worse and they are unstable like this

img

My dataset consists of 17 classes of mostly wide ui elements and images are 3840x512. Used the following command with no augmentation. Other parameters were default.

!python train.py --batch 4 --epochs 60 --data t-1/data.yaml --weights 'yolov7_training.pt' --device 0 --img-size 3840 --rect --hyp data/hyp.scratch.custom.yaml

What might be the problem?

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

No branches or pull requests

3 participants