MCPcopy Create free account
hub / github.com/GeWu-Lab/AnyTouch2 / _AnyTouchEncoderWrapper

Class _AnyTouchEncoderWrapper

sparsh/train_task.py:38–51  ·  view source on GitHub ↗

Wraps TactileVideoMAE with a fixed sensor type so downstream tasks can call model_encoder(x) without providing sensor_type explicitly.

Source from the content-addressed store, hash-verified

36
37
38class _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
54def load_model_from_multi_clip(ckpt, model):

Callers 1

trainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected