MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / to_pil_image

Function to_pil_image

k_diffusion/utils.py:28–35  ·  view source on GitHub ↗

Converts from a tensor to a PIL image.

(x)

Source from the content-addressed store, hash-verified

26
27
28def to_pil_image(x):
29 """Converts from a tensor to a PIL image."""
30 if x.ndim == 4:
31 assert x.shape[0] == 1
32 x = x[0]
33 if x.shape[0] == 1:
34 x = x[0]
35 return TF.to_pil_image((x.clamp(-1, 1) + 1) / 2)
36
37
38def hf_datasets_augs_helper(examples, transform, image_key, mode='RGB'):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected