MCPcopy Create free account
hub / github.com/AlayaLab/Hive / numpy_to_pil

Method numpy_to_pil

models/flowsep/diffusers/image_processor.py:56–69  ·  view source on GitHub ↗

Convert a numpy image or a batch of images to a PIL image.

(images)

Source from the content-addressed store, hash-verified

54
55 @staticmethod
56 def numpy_to_pil(images):
57 """
58 Convert a numpy image or a batch of images to a PIL image.
59 """
60 if images.ndim == 3:
61 images = images[None, ...]
62 images = (images * 255).round().astype("uint8")
63 if images.shape[-1] == 1:
64 # special case for grayscale (single channel) images
65 pil_images = [Image.fromarray(image.squeeze(), mode="L") for image in images]
66 else:
67 pil_images = [Image.fromarray(image) for image in images]
68
69 return pil_images
70
71 @staticmethod
72 def numpy_to_pt(images):

Callers 1

postprocessMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected