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

Add ImageNet pre-trained weights under pretrained feature flag #18

Merged
merged 6 commits into from
Feb 14, 2024

Conversation

laggui
Copy link
Member

@laggui laggui commented Feb 13, 2024

This PR adds new methods to directly initialize a ResNet-{18, 34, 50, 101, 152} with ImageNet pre-trained weights from torchvision.

The weights are automatically downloaded from the web to a default ~/.cache/resnet-burn/ folder using download_file_as_bytes which provides a progress bar.

Changes:

  • Refactor all modules to have configs with init and init_with methods following good practice
  • Add pretrained feature flag
    • New weights module
    • New resnet*_pretrained methods
  • Refactor example accordingly

Because loading the pre-trained weights requires a fix not yet in a released version of candle-core, the current burn dependency is pinned to a specific revision that pins the correct dependency.

TODO:

  • Change burn dependency to a specific version once the new candle-core version is released and included in a burn release/patch

@laggui
Copy link
Member Author

laggui commented Feb 13, 2024

@antimora tagging you specifically regarding the pattern we might want to adopt for pre-trained weights as discussed in #16

@antimora
Copy link
Collaborator

Thank you! I'll review it soon.

Copy link
Member

@louisfd louisfd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (rather superficial review though). Just two minor comments but approved in advance

resnet-burn/src/model/block.rs Outdated Show resolved Hide resolved
resnet-burn/src/model/resnet.rs Show resolved Hide resolved
@laggui
Copy link
Member Author

laggui commented Feb 14, 2024

Also fixed some minor issues with the bigger ResNet models.

@laggui laggui merged commit 323a00d into main Feb 14, 2024
2 checks passed
@laggui laggui deleted the resnet-pretrained branch February 14, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants