MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / infer_monodepth

Function infer_monodepth

eval_code/recons/interfaces/moge.py:10–25  ·  view source on GitHub ↗
(file: str, model: MoGe, hydra_cfg: DictConfig)

Source from the content-addressed store, hash-verified

8from models.fastmodel import MoGe
9
10def infer_monodepth(file: str, model: MoGe, hydra_cfg: DictConfig):
11 device = hydra_cfg.device
12
13 image = cv2.imread(file)
14 image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
15 height, width = image.shape[:2]
16 if hasattr(hydra_cfg, 'load_img_size'):
17 resize_to = hydra_cfg.load_img_size
18 height, width = min(resize_to, int(resize_to * height / width)), min(resize_to, int(resize_to * width / height))
19 image = cv2.resize(image, (width, height), cv2.INTER_AREA)
20 image_tensor = torch.tensor(image / 255, dtype=torch.float32, device=device).permute(2, 0, 1)
21
22 # Inference
23 output = model.model.infer(image_tensor, apply_mask=False)
24 # points, depth, mask, intrinsics = output['points'].cpu().numpy(), output['depth'].cpu().numpy(), output['mask'].cpu().numpy(), output['intrinsics'].cpu().numpy()
25 return output['depth']

Callers

nothing calls this directly

Calls 2

resizeMethod · 0.80
inferMethod · 0.45

Tested by

no test coverage detected