- I want to pre-train a classification model on a large dataset.
- Use the above architecture as encoder for unet for semantic segmentation.
Hoping that pretraining on a large dataset for similar domain will give good result for the small dataset we have for semantic segmentation.
Are these any resources(blogs) that explain doing the above. Any form of help is appreciated.
Code:
…
classif_learner = cnn_learner(dls, resnet34, metrics=error_rate)
…
Use the above leaner in the unet_learner
segment_learner = unet_learner(dls, classif_learner.model)
I get the error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-34-bbbc33e9f96d> in <module>
----> 1 segment_learner = unet_learner(dls, classif_learner.model)
~/anaconda3/envs/fastai/lib/python3.6/site-packages/fastai/vision/learner.py in unet_learner(dls, arch, normalize, n_out, pretrained, config, loss_func, opt_func, lr, splitter, cbs, metrics, path, model_dir, wd, wd_bn_bias, train_bn, moms, **kwargs)
217 img_size = dls.one_batch()[0].shape[-2:]
218 assert img_size, "image size could not be inferred from data"
--> 219 model = create_unet_model(arch, n_out, img_size, pretrained=pretrained, **kwargs)
220
221 splitter=ifnone(splitter, meta['split'])
~/anaconda3/envs/fastai/lib/python3.6/site-packages/fastai/vision/learner.py in create_unet_model(arch, n_out, img_size, pretrained, cut, n_in, **kwargs)
192 "Create custom unet architecture"
193 meta = model_meta.get(arch, _default_meta)
--> 194 body = create_body(arch, n_in, pretrained, ifnone(cut, meta['cut']))
195 model = models.unet.DynamicUnet(body, n_out, img_size, **kwargs)
196 return model
~/anaconda3/envs/fastai/lib/python3.6/site-packages/fastai/vision/learner.py in create_body(arch, n_in, pretrained, cut)
63 def create_body(arch, n_in=3, pretrained=True, cut=None):
64 "Cut off the body of a typically pretrained `arch` as determined by `cut`"
---> 65 model = arch(pretrained=pretrained)
66 _update_first_layer(model, n_in, pretrained)
67 #cut = ifnone(cut, cnn_config(arch)['cut'])
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
725 result = self._slow_forward(*input, **kwargs)
726 else:
--> 727 result = self.forward(*input, **kwargs)
728 for hook in itertools.chain(
729 _global_forward_hooks.values(),
TypeError: forward() got an unexpected keyword argument 'pretrained'
Thank you