Closed saurabh502 closed 5 years ago
Hi @saurabh502,
In the nasnet.py
of Cadene pretrainedmodels, the num_classes
is set to 1001 in def nasnetalarge
but in pretained_settings
for "imagenet" it's set to 1000 😂.... So if you use pretrained = 'imagenet+background'
instead of pretrained = 'imagenet'
then you won't have this error, but looks like they got a bug.
However, I didn't include NASNet in here because we'll need to do some additional works to make it work with fastai. The Cadene implementation has some submodules like CellStem1
which takes more than 1 argument in forward
. In fastai create_body
, it takes the original model's children and converts to Sequential
, which won't work with CellStem1
. So we need to encapsulate the mudules in the Cadene implementation into blocks that take only 1 argument in forward
, then we can make it work with fastai.
For the arch_summary
, it's in the utils.py
, did you import it?
I have added an example for NASNet for reference.
When using provided code I am getting below error:
Code:
learn = create_cnn(data, pnasnet5large, pretrained=True,path=MODEL_PATH, cut=None, split= lambda m: (list(m[0][0].children())[8], m[1]))
Error: `--------------------------------------------------------------------------- Exception Traceback (most recent call last)
Hi, the trick is we have to override the “model_meta”, otherwise in “create_body” your cut will be overriden. Can you try with exact the code in the notebook (you can set pretrained to true)?
Hi, now I am not getting any error on
learn = create_cnn(data, pnasnet5large, pretrained=False,path=MODEL_PATH)
but when I am running
learn.lr_find()
I am getting below error: `--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last)
Do you have a small image dataset? It seems the model doesn't work with images smaller than 64x64. The original model was designed for images of 299x299, although we added adaptive pooling layer to make it work for images with different sizes, looks like some layers in the body still don't work. If this is the case, maybe you can resize your images and try again?
Hi, I was using 150x150 , but when I changed size to 299x299 I am able to run code without error. But because of this training time has increased. Can we look into how to work with smaller image sizes?
Are you getting this error if you run for a single image? Something like this:
learn.model(torch.randn(1,3,150,150))
Can we look into how to work with smaller image sizes?
Apparently this model implementation wasn't designed for different input image sizes, and the size mismatch issue happens in quite early layers (rather than in the last few layers). So probably it'll not be easy to fix, but we can take a look
Hi,
When I am trying to use nasnetalarge I am getting AssertionError. Below is the code and error details.
Code
def nasnetalarge(pretrained=True): pretrained = 'imagenet' if pretrained else None model = pretrainedmodels.__dict__['nasnetalarge'](pretrained=pretrained) return model
This is causing error:learn = create_cnn(data, nasnetalarge, pretrained=True,path=MODEL_PATH, cut=-2, split_on=lambda m: (m[0][4], m[1]))
Error: `AssertionError Traceback (most recent call last)