Upload folder using huggingface_hub
Browse files- config.json +4 -0
- modeling_spatial_embeddings.py +18 -1
config.json
CHANGED
|
@@ -3,6 +3,10 @@
|
|
| 3 |
"architectures": [
|
| 4 |
"SpatialEmbeddingsModel"
|
| 5 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
"backbone_model_name": "facebook/dinov3-vit7b16-pretrain-lvd1689m",
|
| 7 |
"dropout": 0.1,
|
| 8 |
"dtype": "float32",
|
|
|
|
| 3 |
"architectures": [
|
| 4 |
"SpatialEmbeddingsModel"
|
| 5 |
],
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_spatial_embeddings.SpatialEmbeddingsConfig",
|
| 8 |
+
"AutoModel": "modeling_spatial_embeddings.SpatialEmbeddingsModel"
|
| 9 |
+
},
|
| 10 |
"backbone_model_name": "facebook/dinov3-vit7b16-pretrain-lvd1689m",
|
| 11 |
"dropout": 0.1,
|
| 12 |
"dtype": "float32",
|
modeling_spatial_embeddings.py
CHANGED
|
@@ -2,9 +2,26 @@ import torch
|
|
| 2 |
import torch.nn as nn
|
| 3 |
import torch.nn.functional as F
|
| 4 |
from transformers import PreTrainedModel, AutoModel
|
| 5 |
-
from .configuration_spatial_embeddings import SpatialEmbeddingsConfig
|
| 6 |
from typing import Optional, Tuple, Union, Literal
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
class EmbeddingProjector(nn.Module):
|
| 10 |
"""
|
|
|
|
| 2 |
import torch.nn as nn
|
| 3 |
import torch.nn.functional as F
|
| 4 |
from transformers import PreTrainedModel, AutoModel
|
|
|
|
| 5 |
from typing import Optional, Tuple, Union, Literal
|
| 6 |
|
| 7 |
+
# Handle import for both local development and HuggingFace Hub loading
|
| 8 |
+
try:
|
| 9 |
+
from .configuration_spatial_embeddings import SpatialEmbeddingsConfig
|
| 10 |
+
except ImportError:
|
| 11 |
+
# When loaded from HuggingFace Hub, relative imports may not work
|
| 12 |
+
# Try absolute import instead
|
| 13 |
+
try:
|
| 14 |
+
from configuration_spatial_embeddings import SpatialEmbeddingsConfig
|
| 15 |
+
except ImportError:
|
| 16 |
+
# Last resort: import from the module directly
|
| 17 |
+
import sys
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
# Get the directory where this file is located
|
| 20 |
+
current_dir = Path(__file__).parent
|
| 21 |
+
if str(current_dir) not in sys.path:
|
| 22 |
+
sys.path.insert(0, str(current_dir))
|
| 23 |
+
from configuration_spatial_embeddings import SpatialEmbeddingsConfig
|
| 24 |
+
|
| 25 |
|
| 26 |
class EmbeddingProjector(nn.Module):
|
| 27 |
"""
|