wimlds-trojmiasto/detect-waste

Waste detection model loading error

jwson97 opened this issue · 1 comments

Dear wimlds,
First of all, thanks for the great works,

I trained EfficientNet model for waste detection with "tf_efficientdet_d2" (multiclass training)

But when i evaluate the model with demo.py, An error occurred during the model loading.

The error is as below,

$> python3 demo.py --save ./results/image.png --checkpoint /home/jupyter/detect-waste/efficientdet/output/train/20220415-025926-tf_efficientdet_d2/checkpoint-0.pth.tar

Traceback (most recent call last):
File "demo.py", line 268, in
main(args)
File "demo.py", line 235, in main
model = set_model("tf_efficientdet_d2", num_classes, args.checkpoint, args.device)
File "demo.py", line 221, in set_model
checkpoint_path=checkpoint_path
File "/home/jupyter/detect-waste/efficientdet/effdet/factory.py", line 14, in create_model
checkpoint_path=checkpoint_path, checkpoint_ema=checkpoint_ema, **kwargs)
File "/home/jupyter/detect-waste/efficientdet/effdet/factory.py", line 47, in create_model_from_config
load_checkpoint(model, checkpoint_path, use_ema=checkpoint_ema)
File "/opt/conda/lib/python3.7/site-packages/timm/models/helpers.py", line 64, in load_checkpoint
model.load_state_dict(state_dict, strict=strict)
File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1498, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for EfficientDet:
size mismatch for class_net.predict.conv_pw.weight: copying a param with shape torch.Size([63, 112, 1, 1]) from checkpoint, the shape in current model is torch.Size([9, 112, 1, 1]).
size mismatch for class_net.predict.conv_pw.bias: copying a param with shape torch.Size([63]) from checkpoint, the shape in current model is torch.Size([9]).

Can you give some advices to solve this error.

Thanks.
Jong Wuk Son

It was a multiclasses vs. singleclass problem. now it's solved I'll close this issue... Thanks for your great works