rwightman / efficientdet-pytorch

A PyTorch impl of EfficientDet faithful to the original Google impl w/ ported weights
Apache License 2.0
1.58k stars 293 forks source link

Eff det weightsn not Loaded instead backboneweights loaded #221

Closed jaideep11061982 closed 3 years ago

jaideep11061982 commented 3 years ago

Describe the bug A clear and concise description of what the bug is. When i call the Effdet class with pretrained_backbone=True , code is loading the pretrained weights of corresponding efficientnet imagenet model but not effdet weights.Below is message i get for pretrained =True Downloading: "https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b4_aa-818f208c.pth" to /root/.cache/torch/hub/checkpoints/tf_efficientnet_b4_aa-818f208c.pth


**To Reproduce**
Steps to reproduce the behavior:
def get_net():
    config = get_efficientdet_config('tf_efficientdet_d4_ap')
    config['num_classes'] = 4
    config['image_size'] = (512,512)
    net = EfficientDet(config, pretrained_backbone=True)
    #checkpoint = torch.load('../input/efficientdet-model/eff_det_models/tf_efficientdet_d5-ef44aea8.pth')
    #torch.load('../input/wheat-effdet5-fold0-best-checkpoint/fold0-best.bin')
    #('../input/efficientdet-model/eff_det_models/tf_efficientdet_d6-51cb0132.pth')
    #('../input/efficientdet-model/eff_det_models/tf_efficientdet_d5-ef44aea8.pth') #d3-d7 ('efficientdet_model' folder) 
    #net.load_state_dict(checkpoint)
    print(config.num_classes )
    net.class_net = HeadNet(config, num_outputs=config.num_classes 
                            #norm_kwargs=dict(eps=.001, momentum=.01)
                           )
    return DetBenchTrain(net, config)

1. 2.

Expected behavior A clear and concise description of what you expected to happen. it should load the weights as per the url given in https://github.com/rwightman/efficientdet-pytorch/blob/abba1d5a3611471ac88d49a473f993f72f9e1aba/effdet/config/model_config.py Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

rwightman commented 3 years ago

@jaideep11061982 use the model factory or at least copy what it's doing, pretrained_backbone is to load the pretrained backbone weights, not the pretrained dection model weights

https://github.com/rwightman/efficientdet-pytorch/blob/master/effdet/factory.py#L17-L54

jaideep11061982 commented 3 years ago

sure thanks i figured it out. I use this . it works net=create_model_from_config(config,pretrained=True,bench_task='train',bench_labeler=True)

Gopi-Durgaprasad commented 3 years ago

sure thanks i figured it out. I use this . it works net=create_model_from_config(config,pretrained=True,bench_task='train',bench_labeler=True)

What are the inputs