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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
mindone.diffusers.utils.ms_to_pil(images)
¶
Convert a mindspore image to a PIL image.
Source code in mindone/diffusers/utils/pil_utils.py
28 29 30 31 32 33 34 35 |
|
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
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 53 54 55 56 |
|
mindone.diffusers.utils.export_to_gif(image, output_gif_path=None, fps=10)
¶
Source code in mindone/diffusers/utils/export_utils.py
29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
mindone.diffusers.utils.export_to_video(video_frames, output_video_path=None, fps=10, quality=5.0, bitrate=None, macro_block_size=16)
¶
quality
Video output quality. Default is 5. Uses variable bit rate. Highest quality is 10, lowest is 0. Set to None to
prevent variable bitrate flags to FFMPEG so you can manually specify them using output_params instead.
Specifying a fixed bitrate using bitrate
disables this parameter.
bitrate
Set a constant bitrate for the video encoding. Default is None causing quality
parameter to be used instead.
Better quality videos with smaller file sizes will result from using the quality
variable bitrate parameter
rather than specifiying a fixed bitrate with this parameter.
macro_block_size
Size constraint for video. Width and height, must be divisible by this number. If not divisible by this number imageio will tell ffmpeg to scale the image up to the next closest size divisible by this number. Most codecs are compatible with a macroblock size of 16 (default), some can go smaller (4, 8). To disable this automatic feature set it to None or 1, however be warned many players can't decode videos that are odd in size and some codecs will produce poor results or fail. See https://en.wikipedia.org/wiki/Macroblock.
Source code in mindone/diffusers/utils/export_utils.py
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
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
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|