MCPcopy
hub / github.com/naver/dust3r / rgb

Function rgb

dust3r/utils/image.py:45–61  ·  view source on GitHub ↗
(ftensor, true_shape=None)

Source from the content-addressed store, hash-verified

43
44
45def rgb(ftensor, true_shape=None):
46 if isinstance(ftensor, list):
47 return [rgb(x, true_shape=true_shape) for x in ftensor]
48 if isinstance(ftensor, torch.Tensor):
49 ftensor = ftensor.detach().cpu().numpy() # H,W,3
50 if ftensor.ndim == 3 and ftensor.shape[0] == 3:
51 ftensor = ftensor.transpose(1, 2, 0)
52 elif ftensor.ndim == 4 and ftensor.shape[1] == 3:
53 ftensor = ftensor.transpose(0, 2, 3, 1)
54 if true_shape is not None:
55 H, W = true_shape
56 ftensor = ftensor[:H, :W]
57 if ftensor.dtype == np.uint8:
58 img = np.float32(ftensor) / 255
59 else:
60 img = (ftensor * 0.5) + 0.5
61 return img.clip(min=0, max=1)
62
63
64def _resize_pil_image(img, long_edge_size):

Callers 12

get_reconstructed_sceneFunction · 0.90
show_duster_pairsFunction · 0.90
scannetpp.pyFile · 0.90
staticthings3d.pyFile · 0.90
habitat.pyFile · 0.90
blendedmvs.pyFile · 0.90
megadepth.pyFile · 0.90
arkitscenes.pyFile · 0.90
waymo.pyFile · 0.90
co3d.pyFile · 0.90
wildrgbd.pyFile · 0.90
_init_from_viewsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected