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

Method _run_inference

benchmark/methods/lingbot_map.py:149–188  ·  view source on GitHub ↗

Run LingbotMap inference and return raw predictions dict.

(self, images)

Source from the content-addressed store, hash-verified

147 return images.to(self.device)
148
149 def _run_inference(self, images):
150 """Run LingbotMap inference and return raw predictions dict."""
151 if self.use_amp:
152 dtype = torch.bfloat16 if torch.cuda.get_device_capability()[0] >= 8 else torch.float16
153 else:
154 dtype = torch.float32
155
156 print(f" → Running {self.mode} inference (dtype: {dtype})")
157
158 num_frames = images.shape[0]
159 with torch.no_grad(), torch.amp.autocast("cuda", dtype=dtype):
160 if self.mode == 'streaming':
161 keyframe_interval = _resolve_keyframe_interval(
162 self.keyframe_interval, num_frames, self.auto_keyframe_threshold
163 )
164 if keyframe_interval != self.keyframe_interval:
165 print(
166 f" → Auto-selected keyframe_interval={keyframe_interval} "
167 f"(num_frames={num_frames}, raw={self.keyframe_interval!r}, "
168 f"threshold={self.auto_keyframe_threshold})"
169 )
170 predictions = self.model.inference_streaming(
171 images,
172 num_scale_frames=self.num_scale_frames,
173 keyframe_interval=keyframe_interval,
174 output_device=torch.device("cpu"),
175 )
176 else:
177 predictions = self.model.inference_windowed(
178 images,
179 window_size=self.window_size,
180 overlap_size=self.overlap_size,
181 num_scale_frames=self.num_scale_frames,
182 keyframe_interval=self.keyframe_interval,
183 flow_threshold=self.flow_threshold,
184 max_non_keyframe_gap=self.max_non_keyframe_gap,
185 output_device=torch.device("cpu"),
186 )
187
188 return predictions
189
190 def _process_outputs(self, predictions, image_shape):
191 """Convert model predictions to benchmark output format.

Callers 1

process_sceneMethod · 0.95

Calls 3

inference_streamingMethod · 0.45
inference_windowedMethod · 0.45

Tested by

no test coverage detected