Utilities
Utility and helper functions for working with 🤗 Diffusers.
numpy_to_pil
Convert a numpy image or a batch of images to a PIL image.
pt_to_pil
Convert a torch image to a PIL image.
load_image
diffusers.utils.load_image
< source >( image: Union convert_method: Optional = None ) → PIL.Image.Image
Parameters
- image (
str
orPIL.Image.Image
) — The image to convert to the PIL Image format. - convert_method (Callable[[PIL.Image.Image], PIL.Image.Image], optional) —
A conversion method to apply to the image after loading it. When set to
None
the image will be converted “RGB”.
Returns
PIL.Image.Image
A PIL Image.
Loads image
to a PIL Image.
export_to_gif
export_to_video
diffusers.utils.export_to_video
< source >( video_frames: Union output_video_path: str = None fps: int = 10 )
make_image_grid
Prepares a single grid of images. Useful for visualization purposes.
randn_tensor
diffusers.utils.torch_utils.randn_tensor
< source >( shape: Union generator: Union = None device: Optional = None dtype: Optional = None layout: Optional = 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.