Hi All,
In Fastai V1, we were able to use cadene models with cnn_learner. Does the current version support those models ?
I am trying to use xception Architecture:
Code: import pretrainedmodels as ptm model = create_cnn_model(ptm.xception, 1, None,True) # Copied from docs
I am getting the following error trace:
KeyError Traceback (most recent call last)
<ipython-input-23-0dafcba3f64b> in <module>
6
7
----> 8 model = create_cnn_model(ptm.xception, 1, None, pretrained=True)
9 # learn = cnn_learner(dls, model, metrics=accuracy)
~/fastai2/fastai2/vision/learner.py in create_cnn_model(arch, n_out, cut, pretrained, n_in, init, custom_head, concat_pool, **kwargs)
99 concat_pool=True, **kwargs):
100 "Create custom convnet architecture using `arch`, `n_in` and `n_out`"
--> 101 body = create_body(arch, n_in, pretrained, cut)
102 if custom_head is None:
103 nf = num_features_model(nn.Sequential(*body.children())) * (2 if concat_pool else 1)
~/fastai2/fastai2/vision/learner.py in create_body(arch, n_in, pretrained, cut)
64 def create_body(arch, n_in=3, pretrained=True, cut=None):
65 "Cut off the body of a typically pretrained `arch` as determined by `cut`"
---> 66 model = arch(pretrained=pretrained)
67 _update_first_layer(model, n_in, pretrained)
68 #cut = ifnone(cut, cnn_config(arch)['cut'])
~/miniconda3/envs/fastai2/lib/python3.7/site-packages/pretrainedmodels/models/xception.py in xception(num_classes, pretrained)
216 model = Xception(num_classes=num_classes)
217 if pretrained:
--> 218 settings = pretrained_settings['xception'][pretrained]
219 assert num_classes == settings['num_classes'], \
220 "num_classes should be {}, but is {}".format(settings['num_classes'], num_classes)
KeyError: True
When i try to debug the code, cadene seems to use string for pretrained parameter (with the value of ‘imagenet’) while fastai tries to pass the value as pretrained = True. I tried overriding manually but still i am not able to get to work. Has someone able to get past this issue? Kindly help
P.S : I am trying to use it along with create_cnn_model --> internally calls create_body