Utilities¶
Utility and helper functions for working with 🤗 Diffusers.
mindone.diffusers.utils.numpy_to_pil(images)
¶
Convert a numpy image or a batch of images to a PIL image.
Source code in mindone/diffusers/utils/pil_utils.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
mindone.diffusers.utils.ms_to_pil(images)
¶
Convert a torch image to a PIL image.
Source code in mindone/diffusers/utils/pil_utils.py
26 27 28 29 30 31 32 33 |
|
mindone.diffusers.utils.load_image(image, convert_method=None)
¶
Loads image
to a PIL Image.
PARAMETER | DESCRIPTION |
---|---|
image |
The image to convert to the PIL Image format.
TYPE:
|
convert_method |
A conversion method to apply to the image after loading it. When set to
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Image
|
|
Source code in mindone/diffusers/utils/loading_utils.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
mindone.diffusers.utils.export_to_gif(image, output_gif_path=None, fps=10)
¶
Source code in mindone/diffusers/utils/export_utils.py
27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
mindone.diffusers.utils.export_to_video(video_frames, output_video_path=None, fps=10)
¶
Source code in mindone/diffusers/utils/export_utils.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
mindone.diffusers.utils.make_image_grid(images, rows, cols, resize=None)
¶
Prepares a single grid of images. Useful for visualization purposes.
Source code in mindone/diffusers/utils/pil_utils.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
mindone.diffusers.utils.mindspore_utils.randn_tensor(shape, generator=None, dtype=None)
¶
A helper function to create random tensors with the desired dtype
. When
passing a list of generators, you can seed each batch size individually.
Source code in mindone/diffusers/utils/mindspore_utils.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|