|
11 | 11 | TRANSFORMER_MODELS = { |
12 | 12 | 'ResNet-50': 'microsoft/resnet-50', |
13 | 13 | 'ResNet-101': 'microsoft/resnet-101', |
| 14 | + 'Swin Transformer (Tiny)': 'microsoft/swin-tiny-patch4-window7-224', |
| 15 | + 'Swin Transformer (Base)': 'microsoft/swin-base-patch4-window7-224', |
| 16 | + 'ViT (Base)': 'google/vit-base-patch16-224', |
| 17 | + 'ViT (Large)': 'google/vit-large-patch16-224', |
14 | 18 | 'DINOv2 (Small)': 'facebook/dinov2-small', |
15 | 19 | 'DINOv2 (Base)': 'facebook/dinov2-base', |
16 | 20 | 'DINOv2 (Large)': 'facebook/dinov2-large', |
17 | 21 | 'DINOv2 (Giant)': 'facebook/dinov2-giant', |
18 | 22 | 'DINOv2 (Giant ImageNet1k)': 'facebook/dinov2-giant-imagenet1k-1-layer', |
19 | | - 'Swin Transformer (Tiny)': 'microsoft/swin-tiny-patch4-window7-224', |
20 | | - 'Swin Transformer (Base)': 'microsoft/swin-base-patch4-window7-224', |
21 | | - 'ViT (Base)': 'google/vit-base-patch16-224', |
22 | | - 'ViT (Large)': 'google/vit-large-patch16-224', |
23 | 23 | } |
24 | 24 |
|
25 | | -# Check if HF_TOKEN environment variable is set |
26 | | -# (if not, user can definitely not access the model) |
27 | | -hf_token = os.getenv("HF_TOKEN") |
| 25 | +try: |
| 26 | + from transformers import pipeline |
| 27 | + from huggingface_hub import snapshot_download |
| 28 | + |
| 29 | + # Check if HF_TOKEN environment variable is set |
| 30 | + # (if not, user can definitely not access the model) |
| 31 | + hf_token = os.getenv("HF_TOKEN") |
| 32 | + |
| 33 | + if hf_token and hf_token.strip(): |
| 34 | + # Add the DINOv3 models if the HuggingFace token is set |
| 35 | + TRANSFORMER_MODELS.update({ |
| 36 | + 'DINOv3 ConvNext (Tiny)': 'facebook/dinov3-convnext-tiny-pretrain-lvd1689m', |
| 37 | + 'DINOv3 ConvNext (Small)': 'facebook/dinov3-convnext-small-pretrain-lvd1689m', |
| 38 | + 'DINOv3 ConvNext (Base)': 'facebook/dinov3-convnext-base-pretrain-lvd1689m', |
| 39 | + 'DINOv3 ConvNext (Large)': 'facebook/dinov3-convnext-large-pretrain-lvd1689m', |
| 40 | + 'DINOv3 ViT (Small/16)': 'facebook/dinov3-vits16-pretrain-lvd1689m', |
| 41 | + 'DINOv3 ViT (Small/16+)': 'facebook/dinov3-vits16plus-pretrain-lvd1689m', |
| 42 | + 'DINOv3 ViT (Base/16)': 'facebook/dinov3-vitb16-pretrain-lvd1689m', |
| 43 | + 'DINOv3 ViT (Large/16)': 'facebook/dinov3-vitl16-pretrain-lvd1689m', |
| 44 | + 'DINOv3 ViT (Huge/16+)': 'facebook/dinov3-vith16plus-pretrain-lvd1689m', |
| 45 | + 'DINOv3 ViT (7B/16)': 'facebook/dinov3-vit7b16-pretrain-lvd1689m', |
| 46 | + }) |
28 | 47 |
|
29 | | -if hf_token and hf_token.strip(): |
30 | | - # Add the DINOv3 models if the HuggingFace token is set |
31 | | - TRANSFORMER_MODELS.update({ |
32 | | - 'DINOv3 ConvNext (Tiny)': 'facebook/dinov3-convnext-tiny-pretrain-lvd1689m', |
33 | | - 'DINOv3 ConvNext (Small)': 'facebook/dinov3-convnext-small-pretrain-lvd1689m', |
34 | | - 'DINOv3 ConvNext (Base)': 'facebook/dinov3-convnext-base-pretrain-lvd1689m', |
35 | | - 'DINOv3 ConvNext (Large)': 'facebook/dinov3-convnext-large-pretrain-lvd1689m', |
36 | | - 'DINOv3 ViT (Small/16)': 'facebook/dinov3-vits16-pretrain-lvd1689m', |
37 | | - 'DINOv3 ViT (Small/16+)': 'facebook/dinov3-vits16plus-pretrain-lvd1689m', |
38 | | - 'DINOv3 ViT (Base/16)': 'facebook/dinov3-vitb16-pretrain-lvd1689m', |
39 | | - 'DINOv3 ViT (Large/16)': 'facebook/dinov3-vitl16-pretrain-lvd1689m', |
40 | | - 'DINOv3 ViT (Huge/16+)': 'facebook/dinov3-vith16plus-pretrain-lvd1689m', |
41 | | - 'DINOv3 ViT (7B/16)': 'facebook/dinov3-vit7b16-pretrain-lvd1689m', |
42 | | - }) |
| 48 | +except Exception as e: |
| 49 | + pass |
43 | 50 |
|
44 | 51 |
|
45 | 52 | def is_transformer_model(model_name): |
|
0 commit comments