MCPcopy Create free account
hub / github.com/TencentARC/InstantMesh / load_im

Method load_im

src/data/objaverse.py:110–122  ·  view source on GitHub ↗

replace background pixel with random color in rendering

(self, path, color)

Source from the content-addressed store, hash-verified

108 return len(self.paths)
109
110 def load_im(self, path, color):
111 '''
112 replace background pixel with random color in rendering
113 '''
114 pil_img = Image.open(path)
115
116 image = np.asarray(pil_img, dtype=np.float32) / 255.
117 alpha = image[:, :, 3:]
118 image = image[:, :, :3] * alpha + color * (1 - alpha)
119
120 image = torch.from_numpy(image).permute(2, 0, 1).contiguous().float()
121 alpha = torch.from_numpy(alpha).permute(2, 0, 1).contiguous().float()
122 return image, alpha
123
124 def __getitem__(self, index):
125 while True:

Callers 1

__getitem__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected