Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -426,18 +426,15 @@ def encode_remote(prompt, references, canvas, num_frames, rewrite_prompt=False):
|
|
| 426 |
|
| 427 |
|
| 428 |
@spaces.GPU(duration=get_duration, size=GPU_SIZE)
|
| 429 |
-
def _generate(prompt_embeds, text_token_tags, references, height, width, num_frames, steps, seed
|
| 430 |
"""The only thing on GPU time: the two reference encoders, the packed-sequence denoise loop and the decoders.
|
| 431 |
References cross as paths and are decoded here; only the three generated outputs come back. A `@spaces.GPU`
|
| 432 |
argument crosses a process boundary by pickling, a 5 s 1344x768 reference video is 370 MB of expanded frames, and
|
| 433 |
the full `PipelineState` still holds the packed latents and the rotary grid on the card.
|
| 434 |
-
The adapters are attached here rather than in the caller: `spaces` runs this body in its own worker, so the
|
| 435 |
-
transformer the request sees is the one that has to carry them.
|
| 436 |
"""
|
| 437 |
import torch
|
| 438 |
if PLACEMENT == "lazy":
|
| 439 |
PIPE.to("cuda")
|
| 440 |
-
apply_loras(PIPE.transformer_ref, loras or ())
|
| 441 |
state = PIPE(
|
| 442 |
prompt_embeds=prompt_embeds.to("cuda"),
|
| 443 |
text_token_tags=text_token_tags,
|
|
@@ -680,16 +677,6 @@ with gr.Blocks(title="MiniMax-H3 Reference Custom Lora") as demo:
|
|
| 680 |
image.change(auto_canvas, image, canvas, show_progress="hidden", api_name=False)
|
| 681 |
video.change(auto_canvas, video, canvas, show_progress="hidden", api_name=False)
|
| 682 |
|
| 683 |
-
# `reference, strength, reference, strength, ...`, which is how `generate` unpacks them.
|
| 684 |
-
lora_inputs = [field for pair in zip(lora_references, lora_scales) for field in pair]
|
| 685 |
-
lora_upload.upload(_fill_lora_slots, [lora_upload, *lora_references], lora_references, api_name=False)
|
| 686 |
-
lora_preset_add.click(
|
| 687 |
-
_add_preset_lora,
|
| 688 |
-
[lora_preset, *lora_references, *lora_scales],
|
| 689 |
-
[*lora_references, *lora_scales, steps],
|
| 690 |
-
api_name=False,
|
| 691 |
-
)
|
| 692 |
-
|
| 693 |
# Same order as `SETTINGS_KEYS`.
|
| 694 |
settings_fields = [prompt, upsample, canvas, match, duration, steps, seed]
|
| 695 |
save.click(save_settings, settings_fields, settings_download, api_name=False)
|
|
|
|
| 426 |
|
| 427 |
|
| 428 |
@spaces.GPU(duration=get_duration, size=GPU_SIZE)
|
| 429 |
+
def _generate(prompt_embeds, text_token_tags, references, height, width, num_frames, steps, seed):
|
| 430 |
"""The only thing on GPU time: the two reference encoders, the packed-sequence denoise loop and the decoders.
|
| 431 |
References cross as paths and are decoded here; only the three generated outputs come back. A `@spaces.GPU`
|
| 432 |
argument crosses a process boundary by pickling, a 5 s 1344x768 reference video is 370 MB of expanded frames, and
|
| 433 |
the full `PipelineState` still holds the packed latents and the rotary grid on the card.
|
|
|
|
|
|
|
| 434 |
"""
|
| 435 |
import torch
|
| 436 |
if PLACEMENT == "lazy":
|
| 437 |
PIPE.to("cuda")
|
|
|
|
| 438 |
state = PIPE(
|
| 439 |
prompt_embeds=prompt_embeds.to("cuda"),
|
| 440 |
text_token_tags=text_token_tags,
|
|
|
|
| 677 |
image.change(auto_canvas, image, canvas, show_progress="hidden", api_name=False)
|
| 678 |
video.change(auto_canvas, video, canvas, show_progress="hidden", api_name=False)
|
| 679 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 680 |
# Same order as `SETTINGS_KEYS`.
|
| 681 |
settings_fields = [prompt, upsample, canvas, match, duration, steps, seed]
|
| 682 |
save.click(save_settings, settings_fields, settings_download, api_name=False)
|