flexible-yolov5 icon indicating copy to clipboard operation
flexible-yolov5 copied to clipboard

Using EfficientNet backbone leads to precision and recall equal to zero

Open farzadips opened this issue 1 year ago • 8 comments

Hello, I'm using your config for defect detection task, but precision and recall are zero after training around 100 epochs, also for predictions it can't detect any object, I tested the same dataset for yolov5 and it worked properly. is there sth wrong with my work? Thanks

farzadips avatar Aug 09 '22 09:08 farzadips

@farzadips did you set nc = (your dataset class number) in configs/model_efficienet.yaml?

Bobo-y avatar Aug 09 '22 09:08 Bobo-y

Thanks for quick reply, Yes, I've changed it, as you can see below, Capture

It's not just EfficientNet config but also I tried model_yolo.yaml and the same problem was consistent.

Any suggestion?

farzadips avatar Aug 09 '22 10:08 farzadips

@Bobo-y

farzadips avatar Aug 09 '22 11:08 farzadips

@Bobo-y I attached one more photo for more understanding of problem, Capture

farzadips avatar Aug 09 '22 11:08 farzadips

@farzadips hi, your nc=1? the nc in head should same as nc in data.yaml. Some people have encountered this problem before, and it is all caused by this

Bobo-y avatar Aug 09 '22 11:08 Bobo-y

@Bobo-y Thanks for reply, I already did this, But I think the problem is not that because I tried the train_demo.ipynb for person detection which had 1 class and everything went fine, When I change dataset to my own dataset again precision and recall stuck at 0, the task is a very small size defect detection. I tried it before with original YoloV5 and the results were fine. I think that the problem is for the size of annotations which is very small compared to the dataset you used.

What is your suggestion? Should I change sth like anchor size?

farzadips avatar Aug 11 '22 05:08 farzadips

@Bobo-y

farzadips avatar Aug 12 '22 08:08 farzadips

@farzadips can you share your dataset? According to the current description, I can't find the problem.

Bobo-y avatar Aug 12 '22 09:08 Bobo-y

Yes sure, can I send it via email? If yes please share with me your email or send an email to [email protected] .

farzadips avatar Aug 12 '22 09:08 farzadips

Yes sure, can I send it via email? If yes please share with me your email or send an email to [email protected] .

hello, because your dataset is too small, and no pretrained weights, so the net can't work, I also try another backbone, P, R are still 0. To verify this, you can use the U Yolo without using pretrained weights.

Bobo-y avatar Aug 15 '22 01:08 Bobo-y

Hello, I solved this problem using Imagenet pretrained weights with efficientnet and now the model is learning.

farzadips avatar Aug 21 '22 05:08 farzadips

@Bobo-y I had another question regarding using efficient backbone, if I have a pretrained model with torchvision.models.efficientnet_b0, is it possible to load those weights in this backbone?

farzadips avatar Aug 21 '22 05:08 farzadips

@farzadips I think you just need add pretrained=True in configs/model_efficientnet.yaml backbone: type: efficientnet version: b1 # b1 to b8 and l2 pretrained: True

Bobo-y avatar Aug 22 '22 01:08 Bobo-y

Problem solved, Thank you.

farzadips avatar Aug 26 '22 15:08 farzadips