EfficientDet pretrained arch transfer learning
See original GitHub issue📓 New <Tutorial/Example>
Request for an example
What is the task? Object detection using transfer learning for the whole architecture. Are there some defined methods to load fastai model and change its head to a different number of classes, similar to this?
I was able to run the Faster-RCNN example using this example trained on COCO dataset and evaluate its mAP.
The EfficientDet workflow seems not to be yet ready. Has there been some update on that?
I was able to create EfficientDet with pretrained encoder and train it myself on COCO. I’m now trying to do transfer learning for a different number of classes. Loading model through fastai, expectedly, throws an error:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-22-cf184f01fec3> in <module>
----> 1 learn.load('coco_local')
~/anaconda3/envs/icevision/lib/python3.8/site-packages/fastai/learner.py in load(self, file, with_opt, device, **kwargs)
293 if self.opt is None: self.create_opt()
294 file = join_path_file(file, self.path/self.model_dir, ext='.pth')
--> 295 load_model(file, self.model, self.opt, device=device, **kwargs)
296 return self
297
~/anaconda3/envs/icevision/lib/python3.8/site-packages/fastai/learner.py in load_model(file, model, opt, with_opt, device, strict)
47 hasopt = set(state)=={'model', 'opt'}
48 model_state = state['model'] if hasopt else state
---> 49 get_model(model).load_state_dict(model_state, strict=strict)
50 if hasopt and with_opt:
51 try: opt.load_state_dict(state['opt'])
~/anaconda3/envs/icevision/lib/python3.8/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
1049
1050 if len(error_msgs) > 0:
-> 1051 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
1052 self.__class__.__name__, "\n\t".join(error_msgs)))
1053 return _IncompatibleKeys(missing_keys, unexpected_keys)
RuntimeError: Error(s) in loading state_dict for DetBenchTrain:
size mismatch for model.class_net.predict.conv_pw.weight: copying a param with shape torch.Size([819, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([99, 64, 1, 1]).
size mismatch for model.class_net.predict.conv_pw.bias: copying a param with shape torch.Size([819]) from checkpoint, the shape in current model is torch.Size([99]).
Is this example for a specific model? EfficientDet
Is this example for a specific dataset? COCO transfer learning
Don’t remove Main issue for examples: #39
Issue Analytics
- State:
- Created 3 years ago
- Comments:22 (10 by maintainers)
Top GitHub Comments
COCOMetric gives correct results for validation with this change:
Amazing work @potipot, I was going to investigate this right now but you already solved it! hahahah
So, if I understood correctly, the error is on this line? Here we are setting the image size without padding, but instead we need to set the image size with padding? If so we just need to take the image size from the
images
tensorimages.shape[2:]