zylo117 / Yet-Another-EfficientDet-Pytorch

The pytorch re-implement of the official efficientdet with SOTA performance in real time and pretrained weights.
GNU Lesser General Public License v3.0
5.21k stars 1.27k forks source link

Train with pretrained weights question #366

Open wumy27 opened 4 years ago

wumy27 commented 4 years ago

I have transformed the custom dataset to coco2017 form and use your pre-trained model d2 to train my model.. But run like this:

image

My training code: python train.py -c 2 -p coco2017 --batch_size 8 --lr 1e-5 --num_epochs 10 --load_weights /weights/efficientdet-d2.pth

My training process: image

When i train with adding the parameter --head_only True , the test result like this: image

Can any one give me some help?

zylo117 commented 4 years ago

the objects are too small, you should try larger network or smaller anchors to fit you gt boxes

wumy27 commented 4 years ago

the objects are too small, you should try larger network or smaller anchors to fit you gt boxes

Thanks for your reply. I will use smaller anchors and see if it can help.

oukohou commented 4 years ago

@wumy27 same problem when using --head_only True, what's the result after you using smaller anchors?

zylo117 commented 4 years ago

It has nothing to do with head_only, you should try more suitable anchors or larger network/ larger image size

oukohou commented 4 years ago

@zylo117 after seeing other similar issues, maybe the problem lies on the category id? my categories are like following:

"categories": [
    {
      "id": 2,
      "supercategory": "none",
      "name": "car"
    },
    {
      "id": 1,
      "supercategory": "none",
      "name": "bicycle"
    },
    {
      "id": 5,
      "supercategory": "none",
      "name": "tricycle"
    },
    {
      "id": 3,
      "supercategory": "none",
      "name": "truck"
    },
    {
      "id": 6,
      "supercategory": "none",
      "name": "electrocycle"
    },
    {
      "id": 4,
      "supercategory": "none",
      "name": "crowd"
    },
    {
      "id": 0,
      "supercategory": "none",
      "name": "motorcycle"
    }

which starts from 0, while you said category id starts from 1
I think this caused my model to predict really bad?

For your information: after I set debug option to True, the output images are all whole blue after 17epochs, like following: image

zylo117 commented 4 years ago

it has to start from 1. And if the pictures are all green, it's probably under fitting. you can visualize the loss graph on tensorboard to get more infomation.

oukohou commented 4 years ago

@zylo117 yeah,thanks, I'll change the category id. And as the regression loss is far smaller than cls loss, I manually add weights to regression loss, which is : loss = cls_loss + reg_loss*4000
do you consider it reasonable?

zylo117 commented 4 years ago

You are welcome to try and feel free to share the result. Reg loss is much lower than cls loss becasue regression is much easier to train than classification.

dthaicuong commented 3 years ago

it has to start from 1. And if the pictures are all green, it's probably under fitting. you can visualize the loss graph on tensorboard to get more infomation.

I tried few times without category_id starting from 1. My cat_id starts from 0 and it works pretty good. @oukohou: I met blue images as well. It's from ori_imgs somehow. But I just extract ROIS after invert_affine and plot them onto img = cv2.imread()

zylo117 commented 3 years ago

@dthaicuong did you modify the code to adapt to cat_id starting from 0? I've been training well with cat id starting from 1 for months.

dthaicuong commented 3 years ago

did you modify the code to adapt to cat_id starting from 0? I've been training well with cat id starting from 1 for months.

@zylo117 I did not change anything from your repo. For few first tries, I forgot "background" class as usual COCO but results are pretty good (or caused by low diversity in my dataset)