Skip to content
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

[BUG] feature_info.channels() is not match #2370

Open
brianhou0208 opened this issue Dec 18, 2024 · 1 comment
Open

[BUG] feature_info.channels() is not match #2370

brianhou0208 opened this issue Dec 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@brianhou0208
Copy link
Contributor

Describe the bug
These models return feature_info.channels() is not match

  • ecaresnet50d_pruned
  • ecaresnet101d_pruned
  • efficientnet_b1_pruned
  • efficientnet_b2_pruned
  • efficientnet_b3_pruned

To Reproduce

import timm
import torch

model_list = [
    ["ecaresnet50d_pruned", 224],
    ["ecaresnet101d_pruned", 224],
    ["efficientnet_b1_pruned", 224],
    ["efficientnet_b2_pruned", 224],
    ["efficientnet_b3_pruned", 224]
]

if __name__ == "__main__":
    for model_name, img_size in model_list:
        x = torch.rand(1, 3, 224, 224)
        model = timm.create_model(f"{model_name}", features_only=True).eval()
        y = model(x)
        print(model_name)
        print(f"    Feature shape: {[f.detach().numpy().shape[1:] for f in y]}")
        print(f"    Feature channels: {model.feature_info.channels()}")
        print()
ecaresnet50d_pruned
    Feature shape: [(64, 112, 112), (19, 56, 56), (171, 28, 28), (818, 14, 14), (2022, 7, 7)]
    Feature channels: [64, 256, 512, 1024, 2048]

ecaresnet101d_pruned
    Feature shape: [(64, 112, 112), (26, 56, 56), (142, 28, 28), (278, 14, 14), (2042, 7, 7)]
    Feature channels: [64, 256, 512, 1024, 2048]

efficientnet_b1_pruned
    Feature shape: [(16, 112, 112), (12, 56, 56), (35, 28, 28), (67, 14, 14), (320, 7, 7)]
    Feature channels: [16, 24, 40, 112, 320]

efficientnet_b2_pruned
    Feature shape: [(16, 112, 112), (17, 56, 56), (42, 28, 28), (116, 14, 14), (352, 7, 7)]
    Feature channels: [16, 24, 48, 120, 352]

efficientnet_b3_pruned
    Feature shape: [(24, 112, 112), (12, 56, 56), (40, 28, 28), (120, 14, 14), (384, 7, 7)]
    Feature channels: [24, 32, 48, 136, 384]

Expected behavior

  • ecaresnet50d_pruned feature channels (64, 19, 171, 818, 2022)
  • ecaresnet101d_pruned feature channels (64, 26, 142, 278, 2042)
  • efficientnet_b1_pruned feature channels (16, 12, 35, 67, 320)
  • efficientnet_b2_pruned feature channels (16, 17, 42, 116, 352)
  • efficientnet_b3_pruned feature channels (24, 12, 40, 120, 384)
@brianhou0208 brianhou0208 added the bug Something isn't working label Dec 18, 2024
@rwightman
Copy link
Collaborator

rwightman commented Dec 18, 2024

@brianhou0208 known issue, along with #1597 ... don't really have a good way to handle the channel count changes in these pruned models, I feel it'd be quite a bit of work to do cleanly. If you see a clean path to a good soln, PR are welcome, there might be some way to make the pruning process aware of / able to modify the info....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants