Wraps TactileVideoMAE with a fixed sensor type so downstream tasks can call model_encoder(x) without providing sensor_type explicitly.
| 36 | |
| 37 | |
| 38 | class _AnyTouchEncoderWrapper(nn.Module): |
| 39 | """Wraps TactileVideoMAE with a fixed sensor type so downstream tasks can call |
| 40 | model_encoder(x) without providing sensor_type explicitly.""" |
| 41 | |
| 42 | def __init__(self, base_model: nn.Module, sensor_type: int): |
| 43 | super().__init__() |
| 44 | self.base_model = base_model |
| 45 | self._sensor_type = sensor_type |
| 46 | |
| 47 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 48 | sensor = torch.full( |
| 49 | (x.shape[0],), self._sensor_type, dtype=torch.long, device=x.device |
| 50 | ) |
| 51 | return self.base_model(x, sensor_type=sensor, probe=True) |
| 52 | |
| 53 | |
| 54 | def load_model_from_multi_clip(ckpt, model): |