pytorch-image-models icon indicating copy to clipboard operation
pytorch-image-models copied to clipboard

[BUG] Fail to turn swin_base_patch4_window12_384 into feature extractor

Open rentainhe opened this issue 3 years ago • 1 comments

Hi, I'm trying to use swin_base_patch4_window12_384 model to extract features, but I meet some error as follows:

model = timm.create_model("swin_base_patch4_window12_384", features_only=True, pretrained=False)
AttributeError: 'SwinTransformer' object has no attribute 'feature_info'

it seems like that there's no feature_info in SwinTransformer

rentainhe avatar Aug 26 '22 09:08 rentainhe

Hi, do you have extracted features from swin v2?

Bailey-24 avatar Dec 10 '22 03:12 Bailey-24

@rentainhe @Bailey-24 took some time to get around to this, but on main branch, all swin v1 & v2 models support feat extraction now. Be aware they are NHWC outputs, not NCHW like most convnets. EDIT on main branch right now, in pypi pre-release in days and hopefully a non pre-release cycle happens in a month or so (0.9).

model = timm.create_model("swin_base_patch4_window12_384", features_only=True, pretrained=False)
oo = model(torch.randn(2, 3, 384, 384))
for x in oo:
    print(x.shape)

torch.Size([2, 96, 96, 128])
torch.Size([2, 48, 48, 256])
torch.Size([2, 24, 24, 512])
torch.Size([2, 12, 12, 1024])

rwightman avatar Mar 20 '23 04:03 rwightman

When I try your code I get this: AttributeError: 'SwinTransformer' object has no attribute 'feature_info'

Mojzaar avatar Apr 06 '23 17:04 Mojzaar

Old version, need recent 0.8.x see readme

On Thu, Apr 6, 2023, 10:28 AM Mojtaba @.***> wrote:

When I try your code I get this: AttributeError: 'SwinTransformer' object has no attribute 'feature_info'

— Reply to this email directly, view it on GitHub https://github.com/huggingface/pytorch-image-models/issues/1438#issuecomment-1499395359, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLQICASBAIXU6AQOLCIULDW734KVANCNFSM57WC6D2Q . You are receiving this because you modified the open/close state.Message ID: @.***>

rwightman avatar Apr 06 '23 17:04 rwightman