Utilities
Utility and helper functions for working with 🤗 Diffusers.
randn_tensor
diffusers.utils.randn_tensor
< source >( 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.
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: typing.Union[str, PIL.Image.Image]
)
→
PIL.Image.Image
Loads image
to a PIL Image.
export_to_video
diffusers.utils.export_to_video
< source >( video_frames: typing.List[numpy.ndarray] output_video_path: str = None )