-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to output feature maps #570
Comments
Hello, if you just want the feature map, you can build the backbone only. >>> import torch
>>> from mmcv import Config
>>> from mmcls.models import build_classifier
>>>
>>> cfg = Config.fromfile("./configs/_base_/models/resnet101.py")
>>> cfg.model.backbone.out_indices = (0, 1, 2, 3) # Output the feature map of all stages.
>>>
>>> inputs = torch.rand(8, 3, 224, 224)
>>> resnet = build_classifier(cfg.model)
>>> outputs = resnet.extract_feat(inputs) # with neck
>>> for out in outputs:
... print(out.shape)
torch.Size([8, 256])
torch.Size([8, 512])
torch.Size([8, 1024])
torch.Size([8, 2048])
>>> outputs = resnet.backbone(inputs) # without neck
>>> for out in outputs:
... print(out.shape)
torch.Size([8, 256, 56, 56])
torch.Size([8, 512, 28, 28])
torch.Size([8, 1024, 14, 14])
torch.Size([8, 2048, 7, 7]) |
hello sir thank you very much but i still have some question |
def simple_test(self, x):
"""Test without augmentation."""
if isinstance(x, tuple):
x = x[-1]
cls_score = self.fc(x)
return cls_score |
The part of final feature extraction is too hard for me .I really look forward to this API!Thank you for your contribution |
@mzr1996
|
Please try: cfg.model.init_cfg = dict(type='Pretrained', checkpoint='./epoch_100.pth')
resnet = build_classifier(cfg.model) |
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
I use resnet101 and now i want to output feature maps. i write the linear_head.py but it doest work
how to do?thz
The text was updated successfully, but these errors were encountered: