MCPcopy Create free account
hub / github.com/Robbyant/lingbot-map / _process_outputs

Method _process_outputs

benchmark/methods/lingbot_map.py:190–256  ·  view source on GitHub ↗

Convert model predictions to benchmark output format. Args: predictions: Raw model outputs with 'pose_enc', 'depth', 'depth_conf', etc. image_shape: (H, W) of the processed images. Returns: Tuple of (rgb_list, depth_list, pose_list, intrinsics_li

(self, predictions, image_shape)

Source from the content-addressed store, hash-verified

188 return predictions
189
190 def _process_outputs(self, predictions, image_shape):
191 """Convert model predictions to benchmark output format.
192
193 Args:
194 predictions: Raw model outputs with 'pose_enc', 'depth', 'depth_conf', etc.
195 image_shape: (H, W) of the processed images.
196
197 Returns:
198 Tuple of (rgb_list, depth_list, pose_list, intrinsics_list, confidence_list)
199 """
200 from lingbot_map.utils.pose_enc import pose_encoding_to_extri_intri
201
202 # Decode pose encoding to extrinsic + intrinsic
203 # pose_encoding_to_extri_intri() output is C2W directly (no inverse needed)
204 extrinsic, intrinsic = pose_encoding_to_extri_intri(
205 predictions["pose_enc"], image_shape
206 )
207
208 extrinsic = extrinsic.float().cpu().numpy().squeeze(0) # [S, 3, 4]
209 intrinsic = intrinsic.float().cpu().numpy().squeeze(0) # [S, 3, 3]
210 depth = predictions["depth"].float().cpu().numpy().squeeze(0) # [S, H, W, 1]
211
212 # Extract processed images
213 if "images" in predictions:
214 images = predictions["images"].float().cpu().numpy().squeeze(0) # [S, 3, H, W]
215 else:
216 images = None
217
218 num_frames = extrinsic.shape[0]
219 print(f" → Extracting {num_frames} frames")
220
221 rgb_list = []
222 depth_list = []
223 pose_list = []
224 intrinsics_list = []
225 confidence_list = []
226
227 for i in range(num_frames):
228 # RGB: [3, H, W] float [0,1] -> [H, W, 3] uint8
229 if images is not None:
230 rgb = images[i].transpose(1, 2, 0)
231 rgb = (rgb * 255).clip(0, 255).astype(np.uint8)
232 rgb_list.append(rgb)
233
234 # Pose: 3x4 C2W -> 4x4 C2W
235 pose = np.eye(4, dtype=np.float32)
236 pose[:3, :] = extrinsic[i].astype(np.float32)
237 pose_list.append(pose)
238
239 # Intrinsics: 3x3 K -> [fx, fy, cx, cy]
240 K = intrinsic[i]
241 intrinsics_list.append(np.array(
242 [K[0, 0], K[1, 1], K[0, 2], K[1, 2]], dtype=np.float32
243 ))
244
245 # Depth: [H, W, 1] -> [H, W]
246 depth_frame = depth[i]
247 if depth_frame.ndim == 3 and depth_frame.shape[-1] == 1:

Callers 1

process_sceneMethod · 0.95

Calls 1

Tested by

no test coverage detected