README.md CHANGED
@@ -90,25 +90,29 @@ We are exploring more tasks where the backbone can be leveragead are are looing
90
  ### Basic Feature Extraction
91
 
92
  ```python
93
- import torch
94
  from transformers import AutoImageProcessor, AutoModel
 
95
  from PIL import Image
96
 
97
- # Load the custom processor and model
98
- repo_id = "theairlabcmu/AnyThermal"
99
- processor = AutoImageProcessor.from_pretrained(repo_id, trust_remote_code=True)
100
- model = AutoModel.from_pretrained(repo_id)
 
 
 
 
 
101
 
102
- # Load your image (works with RGB, Grayscale, etc.)
103
- image = Image.open("path_to_your_image.jpg")
 
104
 
105
- # Preprocess: This automatically handles RGB conversion and
106
- # snaps dimensions to the nearest multiple of 14.
107
- inputs = processor(images=image, return_tensors="pt")
108
 
109
- # Inference
110
- with torch.no_grad():
111
- outputs = model(**inputs)
112
  ```
113
 
114
  ### Task-Specific Applications
 
90
  ### Basic Feature Extraction
91
 
92
  ```python
 
93
  from transformers import AutoImageProcessor, AutoModel
94
+ import torch
95
  from PIL import Image
96
 
97
+ # Load model and processor
98
+ processor = AutoImageProcessor.from_pretrained("theairlabcmu/AnyThermal")
99
+ model = AutoModel.from_pretrained("theairlabcmu/AnyThermal")
100
+
101
+ # Load thermal image (grayscale)
102
+ thermal_image = Image.open("path/to/thermal_image.png").convert("L")
103
+
104
+ # Convert to 3-channel (required for ViT architecture)
105
+ thermal_image = thermal_image.convert("RGB")
106
 
107
+ # Process and extract features
108
+ inputs = processor(images=thermal_image, return_tensors="pt")
109
+ outputs = model(**inputs)
110
 
111
+ # Get CLS token (global image representation)
112
+ cls_features = outputs.last_hidden_state[:, 0] # Shape: [1, 768]
 
113
 
114
+ # Get patch features (spatial feature map)
115
+ patch_features = outputs.last_hidden_state[:, 1:] # Shape: [1, num_patches, 768]
 
116
  ```
117
 
118
  ### Task-Specific Applications
anythermal_checkpoints.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d5e32f2ab731406fa3a47d58601758fff5ed9e1d1c87fcdf1a159004c87464ac
3
- size 2500636617
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd4574987e56f58d0c6993987ddf9c4b72dd21f3786db3facab5914762aab4ef
3
+ size 2498757381
custom_processor.py DELETED
@@ -1,48 +0,0 @@
1
- from transformers import BitImageProcessor as BaseProcessor
2
- import numpy as np
3
-
4
- from transformers import AutoImageProcessor
5
- from transformers.image_utils import PILImageResampling
6
-
7
- class CustomDinov2Processor(BaseProcessor):
8
- model_type = "dinov2"
9
-
10
- def preprocess(self, images, **kwargs):
11
- # 1. Handle "Already Normalized" (0-1) check
12
- test_img = images[0] if isinstance(images, list) else images
13
-
14
- # Determine max value to see if we should rescale
15
- if hasattr(test_img, "getextrema"): # PIL
16
- extrema = test_img.getextrema()
17
- max_val = max([b[1] for b in extrema]) if isinstance(extrema[0], tuple) else extrema[1]
18
- elif hasattr(test_img, "max"): # Numpy/Tensor
19
- max_val = test_img.max()
20
- else:
21
- max_val = 255
22
-
23
- # If already 0-1, disable rescaling (1/255)
24
- if max_val <= 1.0:
25
- kwargs["do_rescale"] = False
26
- else:
27
- kwargs["do_rescale"] = True
28
-
29
- # 2. Force RGB Conversion (handles grayscale)
30
- kwargs["do_convert_rgb"] = True
31
-
32
- return super().preprocess(images, **kwargs)
33
-
34
- def resize(self, image: np.ndarray, size=None, resample=PILImageResampling.BILINEAR, **kwargs) -> np.ndarray:
35
- # 3. Your dynamic "nearest 14" logic
36
- h, w = image.shape[:2]
37
- new_h = (h // 14) * 14
38
- new_w = (w // 14) * 14
39
-
40
- return super().resize(
41
- image,
42
- size={"height": new_h, "width": new_w},
43
- resample=resample,
44
- **kwargs
45
- )
46
-
47
- # Register the class so it saves to the Hub correctly
48
- CustomDinov2Processor.register_for_auto_class("AutoImageProcessor")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
depth/config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "AnyThermalDepthModel"
4
+ ],
5
+ "model_type": "anythermal_depth",
6
+ "auto_map": {
7
+ "AutoConfig": "model.AnyThermalDepthConfig",
8
+ "AutoModel": "model.AnyThermalDepthModel"
9
+ },
10
+ "hidden_size": 768,
11
+ "num_hidden_layers": 12,
12
+ "num_attention_heads": 12,
13
+ "mlp_ratio": 4,
14
+ "hidden_act": "gelu",
15
+ "dropout": 0.0,
16
+ "attention_dropout": 0.0,
17
+ "initializer_range": 0.02,
18
+ "layer_norm_eps": 1e-06,
19
+ "image_size": 518,
20
+ "patch_size": 14,
21
+ "num_channels": 3,
22
+ "qkv_bias": true,
23
+ "layerscale_value": 1.0,
24
+ "drop_path_rate": 0.0,
25
+ "use_swiglu_ffn": false,
26
+ "features": 256
27
+ }
depth/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d45f5b9c90e4243a85c80dda747b28efcef527195dc5eceea21bd93dd56d269
3
+ size 425617642
preprocessor_config.json CHANGED
@@ -1,30 +1,16 @@
1
  {
2
- "crop_size": {
3
- "height": 224,
4
- "width": 224
5
- },
6
  "do_center_crop": false,
7
  "do_convert_rgb": true,
8
  "do_normalize": true,
9
  "do_rescale": true,
10
  "do_resize": true,
11
- "image_mean": [
12
- 0.48145466,
13
- 0.4578275,
14
- 0.40821073
15
- ],
16
- "image_processor_type": "CustomDinov2Processor",
17
- "image_std": [
18
- 0.26862954,
19
- 0.26130258,
20
- 0.27577711
21
- ],
22
- "resample": 2,
23
  "rescale_factor": 0.00392156862745098,
24
  "size": {
25
- "shortest_edge": 14
26
- },
27
- "auto_map": {
28
- "AutoImageProcessor": "custom_processor.CustomDinov2Processor"
29
  }
30
  }
 
1
  {
 
 
 
 
2
  "do_center_crop": false,
3
  "do_convert_rgb": true,
4
  "do_normalize": true,
5
  "do_rescale": true,
6
  "do_resize": true,
7
+ "image_mean": [0.48145466, 0.4578275, 0.40821073],
8
+ "image_std": [0.26862954, 0.26130258, 0.27577711],
9
+ "image_processor_type": "BitImageProcessor",
10
+ "resample": 3,
 
 
 
 
 
 
 
 
11
  "rescale_factor": 0.00392156862745098,
12
  "size": {
13
+ "height": 224,
14
+ "width": 224
 
 
15
  }
16
  }
segmentation_cart/config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "AnyThermalSegmentationModel"
4
+ ],
5
+ "model_type": "anythermal",
6
+ "auto_map": {
7
+ "AutoConfig": "model.AnyThermalConfig",
8
+ "AutoModel": "model.AnyThermalSegmentationModel"
9
+ },
10
+ "hidden_size": 768,
11
+ "num_hidden_layers": 12,
12
+ "num_attention_heads": 12,
13
+ "mlp_ratio": 4,
14
+ "hidden_act": "gelu",
15
+ "dropout": 0.0,
16
+ "attention_dropout": 0.0,
17
+ "initializer_range": 0.02,
18
+ "layer_norm_eps": 1e-06,
19
+ "image_size": 518,
20
+ "patch_size": 14,
21
+ "num_channels": 3,
22
+ "qkv_bias": true,
23
+ "layerscale_value": 1.0,
24
+ "drop_path_rate": 0.0,
25
+ "use_swiglu_ffn": false,
26
+ "num_labels": 10
27
+ }
segmentation_cart/preprocessor_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_center_crop": false,
3
+ "do_convert_rgb": true,
4
+ "do_normalize": false,
5
+ "do_rescale": true,
6
+ "do_resize": false,
7
+ "image_processor_type": "BitImageProcessor",
8
+ "rescale_factor": 0.00392156862745098
9
+ }
segmentation_cart/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28f828818cdbb6dde254df59ee6b221d3f91875766c621bd5206d4f82e75bdf6
3
+ size 348159849
segmentation_mfnet/config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "AnyThermalSegmentationModel"
4
+ ],
5
+ "model_type": "anythermal",
6
+ "auto_map": {
7
+ "AutoConfig": "model.AnyThermalConfig",
8
+ "AutoModel": "model.AnyThermalSegmentationModel"
9
+ },
10
+ "hidden_size": 768,
11
+ "num_hidden_layers": 12,
12
+ "num_attention_heads": 12,
13
+ "mlp_ratio": 4,
14
+ "hidden_act": "gelu",
15
+ "dropout": 0.0,
16
+ "attention_dropout": 0.0,
17
+ "initializer_range": 0.02,
18
+ "layer_norm_eps": 1e-06,
19
+ "image_size": 518,
20
+ "patch_size": 14,
21
+ "num_channels": 3,
22
+ "qkv_bias": true,
23
+ "layerscale_value": 1.0,
24
+ "drop_path_rate": 0.0,
25
+ "use_swiglu_ffn": false,
26
+ "num_labels": 9
27
+ }
segmentation_mfnet/preprocessor_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_center_crop": false,
3
+ "do_convert_rgb": true,
4
+ "do_normalize": false,
5
+ "do_rescale": true,
6
+ "do_resize": false,
7
+ "image_processor_type": "BitImageProcessor",
8
+ "rescale_factor": 0.00392156862745098
9
+ }
segmentation_mfnet/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0841214f4ac2b7b31405037593c79960ae2b10ed4cece3c93953c3c4560b26ec
3
+ size 348159776
vpr/config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "AnyThermalVPRModel"
4
+ ],
5
+ "model_type": "anythermal_vpr",
6
+ "auto_map": {
7
+ "AutoConfig": "model.AnyThermalVPRConfig",
8
+ "AutoModel": "model.AnyThermalVPRModel"
9
+ },
10
+ "hidden_size": 768,
11
+ "num_hidden_layers": 12,
12
+ "num_attention_heads": 12,
13
+ "mlp_ratio": 4,
14
+ "hidden_act": "gelu",
15
+ "dropout": 0.0,
16
+ "attention_dropout": 0.0,
17
+ "initializer_range": 0.02,
18
+ "layer_norm_eps": 1e-06,
19
+ "image_size": 518,
20
+ "patch_size": 14,
21
+ "num_channels": 3,
22
+ "qkv_bias": true,
23
+ "layerscale_value": 1.0,
24
+ "drop_path_rate": 0.0,
25
+ "use_swiglu_ffn": false,
26
+ "num_clusters": 64,
27
+ "cluster_dim": 128,
28
+ "token_dim": 256
29
+ }
vpr/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41f4aa7b27bae7e4ff6331b27222c703845933bf668f312a3578eeb82fcdaa25
3
+ size 352035578