paranke commited on
Commit
80f1cb4
·
verified ·
1 Parent(s): 2d6ecd6

Upload folder using huggingface_hub

Browse files
config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "TimesformerModel"
4
+ ],
5
+ "depth": 8,
6
+ "dim": 512,
7
+ "n_heads": 6,
8
+ "num_classes": 16,
9
+ "num_frames": 26,
10
+ "patch_size": 16,
11
+ "torch_dtype": "float32",
12
+ "transformers_version": "4.53.1",
13
+ "window_size": 64
14
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:49b7d35f53fdf7c8bc87dd227e002808f407567cba648c7d48d8681bae6ebb57
3
+ size 151853128
vesuvius_timesformer/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from .timesformer_config import TimesformerConfig
2
+ from .timesformer_model import TimesformerModel
3
+
4
+ __all__ = [
5
+ "TimesformerConfig",
6
+ "TimesformerModel",
7
+ ]
vesuvius_timesformer/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (305 Bytes). View file
 
vesuvius_timesformer/__pycache__/timesformer_config.cpython-310.pyc ADDED
Binary file (861 Bytes). View file
 
vesuvius_timesformer/__pycache__/timesformer_model.cpython-310.pyc ADDED
Binary file (1.27 kB). View file
 
vesuvius_timesformer/timesformer_config.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.configuration_utils import PretrainedConfig
2
+
3
+
4
+ class TimesformerConfig(PretrainedConfig):
5
+ def __init__(
6
+ self,
7
+ window_size=64,
8
+ depth=8,
9
+ n_heads=6,
10
+ patch_size=16,
11
+ num_frames=26,
12
+ num_classes=16,
13
+ dim=512,
14
+ **kwargs,
15
+ ):
16
+ self.window_size = window_size
17
+ self.depth = depth
18
+ self.n_heads = n_heads
19
+ self.patch_size = patch_size
20
+ self.num_frames = num_frames
21
+ self.num_classes = num_classes
22
+ self.dim = dim
23
+ super().__init__(**kwargs)
vesuvius_timesformer/timesformer_model.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .timesformer_config import TimesformerConfig
2
+ from transformers.modeling_utils import PreTrainedModel
3
+ import torch
4
+ from timesformer_pytorch import TimeSformer
5
+
6
+
7
+ class TimesformerModel(PreTrainedModel):
8
+ config_class = TimesformerConfig
9
+
10
+ def __init__(self, config):
11
+ super().__init__(config)
12
+ self.backbone = TimeSformer(
13
+ dim=config.dim,
14
+ image_size=config.window_size,
15
+ patch_size=config.patch_size,
16
+ num_frames=config.num_frames,
17
+ num_classes=config.num_classes,
18
+ channels=1,
19
+ depth=config.depth,
20
+ heads=config.n_heads,
21
+ dim_head=64,
22
+ attn_dropout=0.1,
23
+ ff_dropout=0.1,
24
+ )
25
+ self.post_init()
26
+
27
+ def forward(self, tensor):
28
+ x = self.backbone(torch.permute(tensor, (0, 2, 1, 3, 4)))
29
+ x = x.view(-1, 1, 4, 4)
30
+ return x