Spaces:
Configuration error
Configuration error
Commit ·
307d7cf
1
Parent(s): efdefa8
Try increasing GPU duration
Browse files
app.py
CHANGED
|
@@ -11,14 +11,17 @@ import gradio as gr
|
|
| 11 |
import imageio
|
| 12 |
import numpy as np
|
| 13 |
import ftfy
|
|
|
|
| 14 |
try:
|
| 15 |
import spaces
|
| 16 |
except ImportError:
|
|
|
|
| 17 |
class _SpacesShim:
|
| 18 |
@staticmethod
|
| 19 |
def GPU(*args, **kwargs):
|
| 20 |
def decorator(fn):
|
| 21 |
return fn
|
|
|
|
| 22 |
return decorator
|
| 23 |
|
| 24 |
spaces = _SpacesShim()
|
|
@@ -31,7 +34,6 @@ from transformers import CLIPVisionModel
|
|
| 31 |
from src.models.Wan.autoencoder_wanT import AutoencoderKLWan
|
| 32 |
from src.models.Wan.transformer_wan import WanDecoderTransformer
|
| 33 |
|
| 34 |
-
|
| 35 |
ROOT = Path(__file__).resolve().parent
|
| 36 |
if str(ROOT) not in sys.path:
|
| 37 |
sys.path.insert(0, str(ROOT))
|
|
@@ -559,7 +561,7 @@ def decode_with_refdecoder(latents, reference_frame, vae, transformer):
|
|
| 559 |
return video
|
| 560 |
|
| 561 |
|
| 562 |
-
@spaces.GPU(duration=
|
| 563 |
def generate_latents_on_gpu(image, prompt, seed):
|
| 564 |
log_cuda_mem("start generate_latents_on_gpu")
|
| 565 |
GENERATION_PIPE.to(DEVICE)
|
|
@@ -607,7 +609,10 @@ def decode_refdecoder_on_gpu(latents, reference_frame):
|
|
| 607 |
REFDECODER_TRANSFORMER.to(DEVICE)
|
| 608 |
try:
|
| 609 |
video = decode_with_refdecoder(
|
| 610 |
-
latents,
|
|
|
|
|
|
|
|
|
|
| 611 |
)
|
| 612 |
video = video.detach().cpu()
|
| 613 |
finally:
|
|
@@ -991,8 +996,7 @@ button.download-ref:disabled {
|
|
| 991 |
|
| 992 |
with gr.Blocks(title="RefDecoder I2V Demo", theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
|
| 993 |
with gr.Column(elem_classes="app-shell"):
|
| 994 |
-
gr.HTML(
|
| 995 |
-
"""
|
| 996 |
<script>
|
| 997 |
(() => {
|
| 998 |
if (window.__refdecoderResizeBound) return;
|
|
@@ -1049,18 +1053,15 @@ with gr.Blocks(title="RefDecoder I2V Demo", theme=gr.themes.Soft(), css=CUSTOM_C
|
|
| 1049 |
The app generates latents once, then renders them with Wan's original VAE and with RefDecoder.
|
| 1050 |
</p>
|
| 1051 |
</div>
|
| 1052 |
-
"""
|
| 1053 |
-
)
|
| 1054 |
|
| 1055 |
with gr.Column(elem_classes=["panel-card", "compare-panel"]):
|
| 1056 |
-
gr.HTML(
|
| 1057 |
-
"""
|
| 1058 |
<div class="section-title">Inputs</div>
|
| 1059 |
<div class="section-copy">
|
| 1060 |
Upload a reference image, optionally add a prompt, and compare the decoders below.
|
| 1061 |
</div>
|
| 1062 |
-
"""
|
| 1063 |
-
)
|
| 1064 |
with gr.Row(equal_height=True):
|
| 1065 |
with gr.Column(scale=3):
|
| 1066 |
image_input = gr.Image(
|
|
@@ -1091,14 +1092,12 @@ with gr.Blocks(title="RefDecoder I2V Demo", theme=gr.themes.Soft(), css=CUSTOM_C
|
|
| 1091 |
status_md = gr.Markdown(value="", elem_classes="run-status")
|
| 1092 |
|
| 1093 |
with gr.Column(elem_classes="panel-card"):
|
| 1094 |
-
gr.HTML(
|
| 1095 |
-
"""
|
| 1096 |
<div class="section-title">Decoder Comparison</div>
|
| 1097 |
<div class="section-copy">
|
| 1098 |
Left side shows Wan Baseline. Right side shows RefDecoder. Drag the divider across the frame to compare them.
|
| 1099 |
</div>
|
| 1100 |
-
"""
|
| 1101 |
-
)
|
| 1102 |
compare_output = gr.HTML(value=build_compare_html(None, None))
|
| 1103 |
|
| 1104 |
with gr.Row(elem_classes="download-row"):
|
|
|
|
| 11 |
import imageio
|
| 12 |
import numpy as np
|
| 13 |
import ftfy
|
| 14 |
+
|
| 15 |
try:
|
| 16 |
import spaces
|
| 17 |
except ImportError:
|
| 18 |
+
|
| 19 |
class _SpacesShim:
|
| 20 |
@staticmethod
|
| 21 |
def GPU(*args, **kwargs):
|
| 22 |
def decorator(fn):
|
| 23 |
return fn
|
| 24 |
+
|
| 25 |
return decorator
|
| 26 |
|
| 27 |
spaces = _SpacesShim()
|
|
|
|
| 34 |
from src.models.Wan.autoencoder_wanT import AutoencoderKLWan
|
| 35 |
from src.models.Wan.transformer_wan import WanDecoderTransformer
|
| 36 |
|
|
|
|
| 37 |
ROOT = Path(__file__).resolve().parent
|
| 38 |
if str(ROOT) not in sys.path:
|
| 39 |
sys.path.insert(0, str(ROOT))
|
|
|
|
| 561 |
return video
|
| 562 |
|
| 563 |
|
| 564 |
+
@spaces.GPU(duration=150)
|
| 565 |
def generate_latents_on_gpu(image, prompt, seed):
|
| 566 |
log_cuda_mem("start generate_latents_on_gpu")
|
| 567 |
GENERATION_PIPE.to(DEVICE)
|
|
|
|
| 609 |
REFDECODER_TRANSFORMER.to(DEVICE)
|
| 610 |
try:
|
| 611 |
video = decode_with_refdecoder(
|
| 612 |
+
latents,
|
| 613 |
+
reference_frame,
|
| 614 |
+
REFDECODER_VAE,
|
| 615 |
+
REFDECODER_TRANSFORMER,
|
| 616 |
)
|
| 617 |
video = video.detach().cpu()
|
| 618 |
finally:
|
|
|
|
| 996 |
|
| 997 |
with gr.Blocks(title="RefDecoder I2V Demo", theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
|
| 998 |
with gr.Column(elem_classes="app-shell"):
|
| 999 |
+
gr.HTML("""
|
|
|
|
| 1000 |
<script>
|
| 1001 |
(() => {
|
| 1002 |
if (window.__refdecoderResizeBound) return;
|
|
|
|
| 1053 |
The app generates latents once, then renders them with Wan's original VAE and with RefDecoder.
|
| 1054 |
</p>
|
| 1055 |
</div>
|
| 1056 |
+
""")
|
|
|
|
| 1057 |
|
| 1058 |
with gr.Column(elem_classes=["panel-card", "compare-panel"]):
|
| 1059 |
+
gr.HTML("""
|
|
|
|
| 1060 |
<div class="section-title">Inputs</div>
|
| 1061 |
<div class="section-copy">
|
| 1062 |
Upload a reference image, optionally add a prompt, and compare the decoders below.
|
| 1063 |
</div>
|
| 1064 |
+
""")
|
|
|
|
| 1065 |
with gr.Row(equal_height=True):
|
| 1066 |
with gr.Column(scale=3):
|
| 1067 |
image_input = gr.Image(
|
|
|
|
| 1092 |
status_md = gr.Markdown(value="", elem_classes="run-status")
|
| 1093 |
|
| 1094 |
with gr.Column(elem_classes="panel-card"):
|
| 1095 |
+
gr.HTML("""
|
|
|
|
| 1096 |
<div class="section-title">Decoder Comparison</div>
|
| 1097 |
<div class="section-copy">
|
| 1098 |
Left side shows Wan Baseline. Right side shows RefDecoder. Drag the divider across the frame to compare them.
|
| 1099 |
</div>
|
| 1100 |
+
""")
|
|
|
|
| 1101 |
compare_output = gr.HTML(value=build_compare_html(None, None))
|
| 1102 |
|
| 1103 |
with gr.Row(elem_classes="download-row"):
|