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

torch.hub: add support for DOFA and Swin models #2052

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions hubconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@
* https://pytorch.org/docs/stable/hub.html
"""

from torchgeo.models import resnet18, resnet50, vit_small_patch16_224
from torchgeo.models import (
dofa_base_patch16_224,
dofa_large_patch16_224,
resnet18,
resnet50,
swin_v2_b,
vit_small_patch16_224,
)

__all__ = ('resnet18', 'resnet50', 'vit_small_patch16_224')
__all__ = (
'dofa_base_patch16_224',
'dofa_large_patch16_224',
'resnet18',
'resnet50',
'swin_v2_b',
'vit_small_patch16_224',
)

dependencies = ['timm']
18 changes: 15 additions & 3 deletions torchgeo/models/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,38 @@
import torch.nn as nn
from torchvision.models._api import WeightsEnum

from .dofa import (
DOFABase16_Weights,
DOFALarge16_Weights,
dofa_base_patch16_224,
dofa_large_patch16_224,
)
from .resnet import ResNet18_Weights, ResNet50_Weights, resnet18, resnet50
from .swin import Swin_V2_B_Weights, swin_v2_b
from .vit import ViTSmall16_Weights, vit_small_patch16_224

_model = {
'dofa_base_patch16_224': dofa_base_patch16_224,
'dofa_large_patch16_224': dofa_large_patch16_224,
'resnet18': resnet18,
'resnet50': resnet50,
'vit_small_patch16_224': vit_small_patch16_224,
'swin_v2_b': swin_v2_b,
'vit_small_patch16_224': vit_small_patch16_224,
}

_model_weights = {
dofa_base_patch16_224: DOFABase16_Weights,
dofa_large_patch16_224: DOFALarge16_Weights,
resnet18: ResNet18_Weights,
resnet50: ResNet50_Weights,
vit_small_patch16_224: ViTSmall16_Weights,
swin_v2_b: Swin_V2_B_Weights,
vit_small_patch16_224: ViTSmall16_Weights,
'dofa_base_patch16_224': DOFABase16_Weights,
'dofa_large_patch16_224': DOFALarge16_Weights,
'resnet18': ResNet18_Weights,
'resnet50': ResNet50_Weights,
'vit_small_patch16_224': ViTSmall16_Weights,
'swin_v2_b': Swin_V2_B_Weights,
'vit_small_patch16_224': ViTSmall16_Weights,
}


Expand Down
Loading