|
23 | 23 | from ...loaders import Flux2LoraLoaderMixin |
24 | 24 | from ...models import AutoencoderKLFlux2, Flux2Transformer2DModel |
25 | 25 | from ...schedulers import FlowMatchEulerDiscreteScheduler |
26 | | -from ...utils import ( |
27 | | - is_torch_xla_available, |
28 | | - logging, |
29 | | - replace_example_docstring, |
30 | | -) |
| 26 | +from ...utils import is_torch_xla_available, logging, replace_example_docstring |
31 | 27 | from ...utils.torch_utils import randn_tensor |
32 | 28 | from ..pipeline_utils import DiffusionPipeline |
33 | 29 | from .image_processor import Flux2ImageProcessor |
@@ -79,17 +75,21 @@ def format_text_input(prompts: List[str], system_message: str = None): |
79 | 75 | ] |
80 | 76 |
|
81 | 77 |
|
82 | | - |
83 | 78 | def compute_empirical_mu(image_seq_len: int, num_steps: int) -> float: |
84 | | - a1, b1 = 0.00020573, 1.85733333 |
| 79 | + a1, b1 = 8.73809524e-05, 1.89833333 |
85 | 80 | a2, b2 = 0.00016927, 0.45666666 |
86 | 81 |
|
| 82 | + if image_seq_len > 4300: |
| 83 | + mu = a2 * image_seq_len + b2 |
| 84 | + return float(mu) |
| 85 | + |
87 | 86 | m_200 = a2 * image_seq_len + b2 |
88 | | - m_30 = a1 * image_seq_len + b1 |
| 87 | + m_10 = a1 * image_seq_len + b1 |
89 | 88 |
|
90 | | - a = (m_200 - m_30) / 170.0 |
| 89 | + a = (m_200 - m_10) / 190.0 |
91 | 90 | b = m_200 - 200.0 * a |
92 | 91 | mu = a * num_steps + b |
| 92 | + |
93 | 93 | return float(mu) |
94 | 94 |
|
95 | 95 |
|
@@ -171,7 +171,7 @@ class Flux2Pipeline(DiffusionPipeline, Flux2LoraLoaderMixin): |
171 | 171 | r""" |
172 | 172 | The Flux2 pipeline for text-to-image generation. |
173 | 173 |
|
174 | | - Reference: TODO |
| 174 | + Reference: [https://bfl.ai/blog/flux-2](https://bfl.ai/blog/flux-2) |
175 | 175 |
|
176 | 176 | Args: |
177 | 177 | transformer ([`Flux2Transformer2DModel`]): |
@@ -783,10 +783,7 @@ def __call__( |
783 | 783 | if hasattr(self.scheduler.config, "use_flow_sigmas") and self.scheduler.config.use_flow_sigmas: |
784 | 784 | sigmas = None |
785 | 785 | image_seq_len = latents.shape[1] |
786 | | - mu = compute_empirical_mu( |
787 | | - image_seq_len=image_seq_len, |
788 | | - num_steps= num_inference_steps, |
789 | | - ) |
| 786 | + mu = compute_empirical_mu(image_seq_len=image_seq_len, num_steps=num_inference_steps) |
790 | 787 | timesteps, num_inference_steps = retrieve_timesteps( |
791 | 788 | self.scheduler, |
792 | 789 | num_inference_steps, |
|
0 commit comments