MCPcopy Create free account
hub / github.com/DSL-Lab/StreamSplat / preprocess_data

Function preprocess_data

splat_inference.py:18–33  ·  view source on GitHub ↗
(frames, depths, timestamps, device)

Source from the content-addressed store, hash-verified

16
17
18def preprocess_data(frames, depths, timestamps, device):
19 frames = torch.from_numpy(np.stack(frames)).float().to(device) / 255.0 # [V, H, W, C] -> [V, C, H, W]
20 frames = frames.permute(0, 3, 1, 2).unsqueeze(0) # [1, V, C, H, W]
21
22 depths = torch.from_numpy(np.stack(depths)).float().to(device) # [V, H, W]
23 depths = depths.unsqueeze(1).unsqueeze(0) # [1, V, 1, H, W]
24
25 timestamps = torch.tensor(timestamps, dtype=torch.float32, device=device).unsqueeze(0) # [1, V]
26
27 timestamps = timestamps / (timestamps[..., -1].unsqueeze(-1))
28
29 max_depth = depths.flatten(1).max(dim=1)[0][:, None, None, None, None]
30 min_depth = depths.flatten(1).min(dim=1)[0][:, None, None, None, None]
31 input_depths = (depths - min_depth) / (max_depth - min_depth + 1e-8)
32
33 return frames, input_depths, timestamps
34
35def get_image(path, H, W):
36 """Load and resize an image."""

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected