walkwithfastai / walkwithfastai.github.io

Host for https://walkwithfastai.com
Other
143 stars 53 forks source link

Cannot pull in other efficientnet versions #12

Closed craine closed 3 years ago

craine commented 3 years ago

Hi. I'm pulling in: from wwf.vision.timm import *

When I ran your example: timm.list_models('efficientnet')[:10]

I see various models but for some reason even though I see b4 when I try to run it I get: Pretrained model URL is invalid, using random initialization. <fastai.learner.Learner at 0x7fe259fdd9b0>

But I don't get that with any b3 models.

This is my learn: learn = timm_learner(dls, 'efficientnet_b4', loss_func=LabelSmoothingCrossEntropy(), metrics=[accuracy], opt_func=ranger)

muellerzr commented 3 years ago

Which URL are you trying for b4? The only pretrained weights for it are the TF weights. (That’s a timm thing)

On Wed, Dec 2, 2020 at 6:57 AM craine notifications@github.com wrote:

Hi. I'm pulling in: from wwf.vision.timm import *

When I ran your example: timm.list_models('efficientnet')[:10]

I see various models but for some reason even though I see b4 when I try to run it I get: Pretrained model URL is invalid, using random initialization. <fastai.learner.Learner at 0x7fe259fdd9b0>

But I don't get that with any b3 models.

This is my learn: learn = timm_learner(dls, 'efficientnet_b4', loss_func=LabelSmoothingCrossEntropy(), metrics=[accuracy], opt_func=ranger)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/walkwithfastai/walkwithfastai.github.io/issues/12, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3YCV5LLKG4S6N6VZ6FQ5LSSYTTNANCNFSM4UKMOBIA .

craine commented 3 years ago

I wasn't using any specific URL.. I just did the view timm models and saw efficientnet_b4 and thought I could pull it in like that. I guess I'm not clear from your tutorial: https://walkwithfastai.com/vision.external.timm

It shows searching for models. All those models aren't available when using your from wwf.vision.timm import * ?

muellerzr commented 3 years ago

My timm module interacts with his library. What you searched for was a list of architectures, not pretrained models. So while efficientnet_b4 is a valid architecture, it doesn’t have normal pretrained weights that he trained. To use pretrained b4 weights you need to use the TF ported weights.

On Wed, Dec 2, 2020 at 8:53 AM craine notifications@github.com wrote:

I wasn't using any specific URL.. I just did the view timm models and saw efficientnet_b4 and thought I could pull it in like that. I guess I'm not clear from your tutorial: https://walkwithfastai.com/vision.external.timm

It shows searching for models. All those models aren't available when using your from wwf.vision.timm import * ?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/walkwithfastai/walkwithfastai.github.io/issues/12#issuecomment-737243533, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3YCVZLXK4UE5NMHBEA5RDSSZBF7ANCNFSM4UKMOBIA .

craine commented 3 years ago

Ah! Got it. I see this: body = create_timm_body('efficientnet_b3a', pretrained=True)

How do I see what is available that are pre-trained models?

muellerzr commented 3 years ago

I would recommend reading through Ross' library here instead, as WWF doesn't directly do anything special. It just uses timm to generate the model through its own system (then wraps and adjusts the head to be fastai): https://github.com/rwightman/pytorch-image-models

muellerzr commented 3 years ago

The same string calls are being used.

muellerzr commented 3 years ago

For exact configurations you can look in the exact model's definition file, such as here for effnet's: https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/efficientnet.py