mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-03-20 23:58:12 +00:00
support teacache
This commit is contained in:
16
examples/TeaCache/README.md
Normal file
16
examples/TeaCache/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# TeaCache
|
||||
|
||||
TeaCache ([Timestep Embedding Aware Cache](https://github.com/ali-vilab/TeaCache)) is a training-free caching approach that estimates and leverages the fluctuating differences among model outputs across timesteps, thereby accelerating the inference.
|
||||
|
||||
## Examples
|
||||
|
||||
We provide examples on FLUX.1-dev. See [./flux_teacache.py](./flux_teacache.py).
|
||||
|
||||
Steps: 50
|
||||
|
||||
GPU: A100
|
||||
|
||||
|TeaCache is disabled|tea_cache_l1_thresh=0.2|tea_cache_l1_thresh=0.4|tea_cache_l1_thresh=0.6|tea_cache_l1_thresh=0.8|
|
||||
|-|-|-|-|-|
|
||||
|23s|13s|9s|6s|5s|
|
||||
|||||
|
||||
15
examples/TeaCache/flux_teacache.py
Normal file
15
examples/TeaCache/flux_teacache.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import torch
|
||||
from diffsynth import ModelManager, FluxImagePipeline
|
||||
|
||||
|
||||
model_manager = ModelManager(torch_dtype=torch.bfloat16, device="cuda", model_id_list=["FLUX.1-dev"])
|
||||
pipe = FluxImagePipeline.from_model_manager(model_manager)
|
||||
|
||||
prompt = "CG, masterpiece, best quality, solo, long hair, wavy hair, silver hair, blue eyes, blue dress, medium breasts, dress, underwater, air bubble, floating hair, refraction, portrait. The girl's flowing silver hair shimmers with every color of the rainbow and cascades down, merging with the floating flora around her."
|
||||
|
||||
for tea_cache_l1_thresh in [None, 0.2, 0.4, 0.6, 0.8]:
|
||||
image = pipe(
|
||||
prompt=prompt, embedded_guidance=3.5, seed=0,
|
||||
num_inference_steps=50, tea_cache_l1_thresh=tea_cache_l1_thresh
|
||||
)
|
||||
image.save(f"image_{tea_cache_l1_thresh}.png")
|
||||
Reference in New Issue
Block a user