Skip to content

Commit

Permalink
hubconf added
Browse files Browse the repository at this point in the history
  • Loading branch information
SharanSMenon committed Jan 21, 2022
1 parent fe73da3 commit e57bd7c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Swin Transformer PyTorch Hub

This is just a quick way to load Swin Transformers from image classification from PyTorch Hub. This repository makes it possible to load Swin Transformers in 1 line of code.

```python
import torch
model = torch.hub.load() # not yet ready
```
12 changes: 12 additions & 0 deletions hubconf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import torch
import swin

MODEL_URLS = {
"swin_tiny_patch4_window7_224": "https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth"
}

def swin_tiny_patch4_window7_224(pretrained=False):
model = swin.SwinTransformer()
if pretrained:
model.load_state_dict(torch.hub.load_state_dict_from_url(MODEL_URLS["swin_tiny_patch4_window7_224"], map_location="cpu"))
return model

0 comments on commit e57bd7c

Please sign in to comment.