Guiders¶
Guiders are components in Modular Diffusers that control how the diffusion process is guided during generation. They implement various guidance techniques to improve generation quality and control.
mindone.diffusers.guiders.guider_utils.BaseGuidance
¶
Bases: ConfigMixin
, PushToHubMixin
Base class providing the skeleton for implementing guidance techniques.
Source code in mindone/diffusers/guiders/guider_utils.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 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 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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
mindone.diffusers.guiders.guider_utils.BaseGuidance.cleanup_models(denoiser)
¶
Cleans up the models for the guidance technique after a given batch of data. This method should be overridden
in subclasses to implement specific model cleanup logic. It is useful for removing any hooks or other stateful
modifications made during prepare_models
.
Source code in mindone/diffusers/guiders/guider_utils.py
119 120 121 122 123 124 125 |
|
mindone.diffusers.guiders.guider_utils.BaseGuidance.from_pretrained(pretrained_model_name_or_path=None, subfolder=None, return_unused_kwargs=False, **kwargs)
classmethod
¶
Instantiate a guider from a pre-defined JSON configuration file in a local directory or Hub repository.
PARAMETER | DESCRIPTION |
---|---|
pretrained_model_name_or_path
|
Can be either:
TYPE:
|
subfolder
|
The subfolder location of a model file within a larger model repository on the Hub or locally.
TYPE:
|
return_unused_kwargs
|
Whether kwargs that are not consumed by the Python class should be returned or not.
TYPE:
|
cache_dir
|
Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used.
TYPE:
|
force_download
|
Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist.
TYPE:
|
proxies
|
A dictionary of proxy servers to use by protocol or endpoint, for example,
TYPE:
|
output_loading_info
|
Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages.
TYPE:
|
local_files_only
|
Whether to only load local model weights and configuration files or not. If set to
TYPE:
|
token
|
The token to use as HTTP bearer authorization for remote files. If
TYPE:
|
revision
|
The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git.
TYPE:
|
To use private or gated models, log-in with hf
auth login
. You can also activate the special
"offline-mode" to use this method in a
firewalled environment.
Source code in mindone/diffusers/guiders/guider_utils.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
mindone.diffusers.guiders.guider_utils.BaseGuidance.prepare_models(denoiser)
¶
Prepares the models for the guidance technique on a given batch of data. This method should be overridden in subclasses to implement specific model preparation logic.
Source code in mindone/diffusers/guiders/guider_utils.py
112 113 114 115 116 117 |
|
mindone.diffusers.guiders.guider_utils.BaseGuidance.save_pretrained(save_directory, push_to_hub=False, **kwargs)
¶
Save a guider configuration object to a directory so that it can be reloaded using the
[~BaseGuidance.from_pretrained
] class method.
PARAMETER | DESCRIPTION |
---|---|
save_directory
|
Directory where the configuration JSON file will be saved (will be created if it does not exist).
TYPE:
|
push_to_hub
|
Whether or not to push your model to the Hugging Face Hub after saving it. You can specify the
repository you want to push to with
TYPE:
|
kwargs
|
Additional keyword arguments passed along to the [
TYPE:
|
Source code in mindone/diffusers/guiders/guider_utils.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
mindone.diffusers.guiders.guider_utils.BaseGuidance.set_input_fields(**kwargs)
¶
Set the input fields for the guidance technique. The input fields are used to specify the names of the returned
attributes containing the prepared data after prepare_inputs
is called. The prepared data is obtained from
the values of the provided keyword arguments to this method.
PARAMETER | DESCRIPTION |
---|---|
**kwargs
|
A dictionary where the keys are the names of the fields that will be used to store the data once it is
prepared with If a string is provided, it will be used as the conditional data (or unconditional if used with a guidance method that requires it). If a tuple of length 2 is provided, the first element must be the conditional data identifier and the second element must be the unconditional data identifier or None. Example:
TYPE:
|
Source code in mindone/diffusers/guiders/guider_utils.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
mindone.diffusers.guiders.classifier_free_guidance.ClassifierFreeGuidance
¶
Bases: BaseGuidance
Classifier-free guidance (CFG): https://huggingface.co/papers/2207.12598
CFG is a technique used to improve generation quality and condition-following in diffusion models. It works by jointly training a model on both conditional and unconditional data, and using a weighted sum of the two during inference. This allows the model to tradeoff between generation quality and sample diversity. The original paper proposes scaling and shifting the conditional distribution based on the difference between conditional and unconditional predictions. [x_pred = x_cond + scale * (x_cond - x_uncond)]
Diffusers implemented the scaling and shifting on the unconditional prediction instead based on the Imagen paper, which is equivalent to what the original paper proposed in theory. [x_pred = x_uncond + scale * (x_cond - x_uncond)]
The intution behind the original formulation can be thought of as moving the conditional distribution estimates further away from the unconditional distribution estimates, while the diffusers-native implementation can be thought of as moving the unconditional distribution towards the conditional distribution estimates to get rid of the unconditional predictions (usually negative features like "bad quality, bad anotomy, watermarks", etc.)
The use_original_formulation
argument can be set to True
to use the original CFG formulation mentioned in the
paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time.
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/classifier_free_guidance.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
mindone.diffusers.guiders.classifier_free_zero_star_guidance.ClassifierFreeZeroStarGuidance
¶
Bases: BaseGuidance
Classifier-free Zero* (CFG-Zero*): https://huggingface.co/papers/2503.18886
This is an implementation of the Classifier-Free Zero* guidance technique, which is a variant of classifier-free guidance. It proposes zero initialization of the noise predictions for the first few steps of the diffusion process, and also introduces an optimal rescaling factor for the noise predictions, which can help in improving the quality of generated images.
The authors of the paper suggest setting zero initialization in the first 4% of the inference steps.
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
zero_init_steps
|
The number of inference steps for which the noise predictions are zeroed out (see Section 4.2).
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/classifier_free_zero_star_guidance.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
mindone.diffusers.guiders.skip_layer_guidance.SkipLayerGuidance
¶
Bases: BaseGuidance
Skip Layer Guidance (SLG): https://github.com/Stability-AI/sd3.5
Spatio-Temporal Guidance (STG): https://huggingface.co/papers/2411.18664
SLG was introduced by StabilityAI for improving structure and anotomy coherence in generated images. It works by skipping the forward pass of specified transformer blocks during the denoising process on an additional conditional batch of data, apart from the conditional and unconditional batches already used in CFG ([~guiders.classifier_free_guidance.ClassifierFreeGuidance]), and then scaling and shifting the CFG predictions based on the difference between conditional without skipping and conditional with skipping predictions.
The intution behind SLG can be thought of as moving the CFG predicted distribution estimates further away from worse versions of the conditional distribution estimates (because skipping layers is equivalent to using a worse version of the model for the conditional prediction).
STG is an improvement and follow-up work combining ideas from SLG, PAG and similar techniques for improving generation quality in video diffusion models.
Additional reading: - Guiding a Diffusion Model with a Bad Version of Itself
The values for skip_layer_guidance_scale
, skip_layer_guidance_start
, and skip_layer_guidance_stop
are
defaulted to the recommendations by StabilityAI for Stable Diffusion 3.5 Medium.
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
skip_layer_guidance_scale
|
The scale parameter for skip layer guidance. Anatomy and structure coherence may improve with higher values, but it may also lead to overexposure and saturation.
TYPE:
|
skip_layer_guidance_start
|
The fraction of the total number of denoising steps after which skip layer guidance starts.
TYPE:
|
skip_layer_guidance_stop
|
The fraction of the total number of denoising steps after which skip layer guidance stops.
TYPE:
|
skip_layer_guidance_layers
|
The layer indices to apply skip layer guidance to. Can be a single integer or a list of integers. If not
provided,
TYPE:
|
skip_layer_config
|
The configuration for the skip layer guidance. Can be a single
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/skip_layer_guidance.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 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 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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
mindone.diffusers.guiders.smoothed_energy_guidance.SmoothedEnergyGuidance
¶
Bases: BaseGuidance
Smoothed Energy Guidance (SEG): https://huggingface.co/papers/2408.00760
SEG is only supported as an experimental prototype feature for now, so the implementation may be modified in the future without warning or guarantee of reproducibility. This implementation assumes: - Generated images are square (height == width) - The model does not combine different modalities together (e.g., text and image latent streams are not combined together such as Flux)
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
seg_guidance_scale
|
The scale parameter for smoothed energy guidance. Anatomy and structure coherence may improve with higher values, but it may also lead to overexposure and saturation.
TYPE:
|
seg_blur_sigma
|
The amount by which we blur the attention weights. Setting this value greater than 9999.0 results in infinite blur, which means uniform queries. Controlling it exponentially is empirically effective.
TYPE:
|
seg_blur_threshold_inf
|
The threshold above which the blur is considered infinite.
TYPE:
|
seg_guidance_start
|
The fraction of the total number of denoising steps after which smoothed energy guidance starts.
TYPE:
|
seg_guidance_stop
|
The fraction of the total number of denoising steps after which smoothed energy guidance stops.
TYPE:
|
seg_guidance_layers
|
The layer indices to apply smoothed energy guidance to. Can be a single integer or a list of integers. If
not provided,
TYPE:
|
seg_guidance_config
|
The configuration for the smoothed energy layer guidance. Can be a single
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/smoothed_energy_guidance.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 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 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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
mindone.diffusers.guiders.perturbed_attention_guidance.PerturbedAttentionGuidance
¶
Bases: BaseGuidance
Perturbed Attention Guidance (PAG): https://huggingface.co/papers/2403.17377
The intution behind PAG can be thought of as moving the CFG predicted distribution estimates further away from worse versions of the conditional distribution estimates. PAG was one of the first techniques to introduce the idea of using a worse version of the trained model for better guiding itself in the denoising process. It perturbs the attention scores of the latent stream by replacing the score matrix with an identity matrix for selectively chosen layers.
Additional reading: - Guiding a Diffusion Model with a Bad Version of Itself
PAG is implemented with similar implementation to SkipLayerGuidance due to overlap in the configuration parameters and implementation details.
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
perturbed_guidance_scale
|
The scale parameter for perturbed attention guidance.
TYPE:
|
perturbed_guidance_start
|
The fraction of the total number of denoising steps after which perturbed attention guidance starts.
TYPE:
|
perturbed_guidance_stop
|
The fraction of the total number of denoising steps after which perturbed attention guidance stops.
TYPE:
|
perturbed_guidance_layers
|
The layer indices to apply perturbed attention guidance to. Can be a single integer or a list of integers.
If not provided,
TYPE:
|
perturbed_guidance_config
|
The configuration for the perturbed attention guidance. Can be a single
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/perturbed_attention_guidance.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 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 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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
mindone.diffusers.guiders.adaptive_projected_guidance.AdaptiveProjectedGuidance
¶
Bases: BaseGuidance
Adaptive Projected Guidance (APG): https://huggingface.co/papers/2410.02416
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
adaptive_projected_guidance_momentum
|
The momentum parameter for the adaptive projected guidance. Disabled if set to
TYPE:
|
adaptive_projected_guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/adaptive_projected_guidance.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
mindone.diffusers.guiders.auto_guidance.AutoGuidance
¶
Bases: BaseGuidance
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
auto_guidance_layers
|
The layer indices to apply skip layer guidance to. Can be a single integer or a list of integers. If not
provided,
TYPE:
|
auto_guidance_config
|
The configuration for the skip layer guidance. Can be a single
TYPE:
|
dropout
|
The dropout probability for autoguidance on the enabled skip layers (either with
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/auto_guidance.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 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 183 184 185 186 187 188 189 |
|
mindone.diffusers.guiders.tangential_classifier_free_guidance.TangentialClassifierFreeGuidance
¶
Bases: BaseGuidance
Tangential Classifier Free Guidance (TCFG): https://huggingface.co/papers/2503.18137
PARAMETER | DESCRIPTION |
---|---|
guidance_scale
|
The scale parameter for classifier-free guidance. Higher values result in stronger conditioning on the text prompt, while lower values allow for more freedom in generation. Higher values may lead to saturation and deterioration of image quality.
TYPE:
|
guidance_rescale
|
The rescale factor applied to the noise predictions. This is used to improve image quality and fix overexposure. Based on Section 3.4 from Common Diffusion Noise Schedules and Sample Steps are Flawed.
TYPE:
|
use_original_formulation
|
Whether to use the original formulation of classifier-free guidance as proposed in the paper. By default, we use the diffusers-native implementation that has been in the codebase for a long time. See [~guiders.classifier_free_guidance.ClassifierFreeGuidance] for more details.
TYPE:
|
start
|
The fraction of the total number of denoising steps after which guidance starts.
TYPE:
|
stop
|
The fraction of the total number of denoising steps after which guidance stops.
TYPE:
|
Source code in mindone/diffusers/guiders/tangential_classifier_free_guidance.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|