Utility and helper functions for working with 🤗 Diffusers.
Convert a numpy image or a batch of images to a PIL image.
Convert a torch image to a PIL image.
( image: typing.Union[str, PIL.Image.Image] convert_method: typing.Optional[typing.Callable[[PIL.Image.Image], PIL.Image.Image]] = None ) → PIL.Image.Image
Parameters
str
or PIL.Image.Image
) —
The image to convert to the PIL Image format. None
the image will be converted
“RGB”. Returns
PIL.Image.Image
A PIL Image.
Loads image
to a PIL Image.
( image: typing.List[PIL.Image.Image] output_gif_path: str = None fps: int = 10 )
( video_frames: typing.Union[typing.List[numpy.ndarray], typing.List[PIL.Image.Image]] output_video_path: str = None fps: int = 10 )
( images: typing.List[PIL.Image.Image] rows: int cols: int resize: int = None )
Prepares a single grid of images. Useful for visualization purposes.
( shape: typing.Union[typing.Tuple, typing.List] generator: typing.Union[typing.List[ForwardRef('torch.Generator')], ForwardRef('torch.Generator'), NoneType] = None device: typing.Optional[ForwardRef('torch.device')] = None dtype: typing.Optional[ForwardRef('torch.dtype')] = None layout: typing.Optional[ForwardRef('torch.layout')] = None )
A helper function to create random tensors on the desired device
with the desired dtype
. When
passing a list of generators, you can seed each batch size individually. If CPU generators are passed, the tensor
is always created on the CPU.