Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -67,7 +67,7 @@ stream = StreamDiffusionV2Pipeline(
|
|
| 67 |
device=device,
|
| 68 |
height=HEIGHT,
|
| 69 |
width=WIDTH,
|
| 70 |
-
step=
|
| 71 |
noise_scale=NOISE_SCALE,
|
| 72 |
model_type="T2V-1.3B",
|
| 73 |
use_taehv=True, # tiny-VAE decode -> much faster per-chunk -> lower lag
|
|
@@ -127,13 +127,24 @@ def run_session() -> str:
|
|
| 127 |
pass
|
| 128 |
yield READY_SENTINEL
|
| 129 |
|
| 130 |
-
|
| 131 |
buffer = []
|
| 132 |
session = None
|
| 133 |
deadline = time.time() + SESSION_DURATION
|
| 134 |
last = None
|
| 135 |
|
| 136 |
while time.time() < deadline:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
drained = 0
|
| 138 |
while drained < 256:
|
| 139 |
try:
|
|
@@ -156,7 +167,7 @@ def run_session() -> str:
|
|
| 156 |
|
| 157 |
t0 = time.time()
|
| 158 |
if session is None:
|
| 159 |
-
session, init_video = PM.start_stream_session(
|
| 160 |
outs = [init_video]
|
| 161 |
else:
|
| 162 |
outs = PM.run_stream_batch(session, vid)
|
|
|
|
| 67 |
device=device,
|
| 68 |
height=HEIGHT,
|
| 69 |
width=WIDTH,
|
| 70 |
+
step=2, # 2 denoising steps (quality); TAEHV keeps it fast
|
| 71 |
noise_scale=NOISE_SCALE,
|
| 72 |
model_type="T2V-1.3B",
|
| 73 |
use_taehv=True, # tiny-VAE decode -> much faster per-chunk -> lower lag
|
|
|
|
| 127 |
pass
|
| 128 |
yield READY_SENTINEL
|
| 129 |
|
| 130 |
+
cur_prompt = _read_prompt() or DEFAULT_PROMPT
|
| 131 |
buffer = []
|
| 132 |
session = None
|
| 133 |
deadline = time.time() + SESSION_DURATION
|
| 134 |
last = None
|
| 135 |
|
| 136 |
while time.time() < deadline:
|
| 137 |
+
# Live prompt change: re-encode text and reset the cross-attn cache,
|
| 138 |
+
# WITHOUT touching the rolling self-attn KV (keeps temporal continuity).
|
| 139 |
+
new_prompt = _read_prompt() or DEFAULT_PROMPT
|
| 140 |
+
if new_prompt != cur_prompt and session is not None:
|
| 141 |
+
cur_prompt = new_prompt
|
| 142 |
+
cond = PM.pipeline.text_encoder(text_prompts=[cur_prompt])
|
| 143 |
+
cond["prompt_embeds"] = cond["prompt_embeds"].repeat(PM.pipeline.batch_size, 1, 1)
|
| 144 |
+
PM.pipeline.conditional_dict = cond
|
| 145 |
+
for blk in PM.pipeline.crossattn_cache:
|
| 146 |
+
blk["is_init"] = False
|
| 147 |
+
|
| 148 |
drained = 0
|
| 149 |
while drained < 256:
|
| 150 |
try:
|
|
|
|
| 167 |
|
| 168 |
t0 = time.time()
|
| 169 |
if session is None:
|
| 170 |
+
session, init_video = PM.start_stream_session(cur_prompt, vid, NOISE_SCALE)
|
| 171 |
outs = [init_video]
|
| 172 |
else:
|
| 173 |
outs = PM.run_stream_batch(session, vid)
|