MCPcopy Create free account
hub / github.com/PowerHouseMan/ComfyUI-AdvancedLivePortrait / pil2tensor

Function pil2tensor

nodes.py:46–47  ·  view source on GitHub ↗
(image)

Source from the content-addressed store, hash-verified

44def tensor2pil(image):
45 return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
46def pil2tensor(image):
47 return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
48def rgb_crop(rgb, region):
49 return rgb[region[1]:region[3], region[0]:region[2]]
50

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected