Spaces:
Paused
Paused
Simzy420 commited on
Commit ·
faad2da
1
Parent(s): 046638c
Add loading bars, bigger colored RunPod balance, video loop, background processing
Browse files- __pycache__/app.cpython-311.pyc +0 -0
- app.py +23 -3
__pycache__/app.cpython-311.pyc
ADDED
|
Binary file (42.8 kB). View file
|
|
|
app.py
CHANGED
|
@@ -369,7 +369,8 @@ def call_wan_i2v(
|
|
| 369 |
) -> Path:
|
| 370 |
client = get_client(token or "")
|
| 371 |
if progress:
|
| 372 |
-
progress(0.
|
|
|
|
| 373 |
|
| 374 |
# Match generate_video argument order from kulkas2pintu/wan222 /config
|
| 375 |
result = client.predict(
|
|
@@ -413,6 +414,8 @@ def call_wan_i2v(
|
|
| 413 |
|
| 414 |
dest = image_path.parent / f"seg_{uuid.uuid4().hex[:8]}.mp4"
|
| 415 |
shutil.copy2(str(video_path), dest)
|
|
|
|
|
|
|
| 416 |
return dest
|
| 417 |
|
| 418 |
|
|
@@ -505,6 +508,7 @@ def do_generate(
|
|
| 505 |
raise gr.Error("Could not read the uploaded image.")
|
| 506 |
|
| 507 |
progress(0.05, desc="Starting generation…")
|
|
|
|
| 508 |
try:
|
| 509 |
clip = call_wan_i2v(
|
| 510 |
img_path,
|
|
@@ -527,6 +531,7 @@ def do_generate(
|
|
| 527 |
f"Generation failed (ZeroGPU queue/quota or upstream error): {e}"
|
| 528 |
) from e
|
| 529 |
|
|
|
|
| 530 |
out = sess / "current.mp4"
|
| 531 |
shutil.copy2(clip, out)
|
| 532 |
last = extract_last_frame(out, sess / "last_frame")
|
|
@@ -574,6 +579,7 @@ def do_extend(
|
|
| 574 |
|
| 575 |
mode_label = (extend_start or EXTEND_START_LAST_FRAME).strip()
|
| 576 |
progress(0.05, desc=f"Extending ({mode_label})…")
|
|
|
|
| 577 |
try:
|
| 578 |
clip = call_wan_i2v(
|
| 579 |
start_img,
|
|
@@ -600,6 +606,7 @@ def do_extend(
|
|
| 600 |
concat_videos(segs, out)
|
| 601 |
except Exception as e:
|
| 602 |
raise gr.Error(f"Concat failed (ffmpeg): {e}") from e
|
|
|
|
| 603 |
|
| 604 |
# Always refresh last_frame from the new concatenated video so later
|
| 605 |
# “Last frame from video” extends stay correct.
|
|
@@ -715,7 +722,20 @@ def toggle_custom_extend_image(mode: str):
|
|
| 715 |
CSS = """
|
| 716 |
.big-btn button { font-size: 1.15rem !important; min-height: 3rem !important; }
|
| 717 |
#status-md { font-size: 1rem; }
|
| 718 |
-
#runpod-balance-md {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 719 |
footer { display: none !important; }
|
| 720 |
"""
|
| 721 |
|
|
@@ -844,7 +864,7 @@ ZeroGPU is free but **queued and quota-limited** — each segment often takes 1
|
|
| 844 |
btn_reset = gr.Button("Reset", size="lg")
|
| 845 |
|
| 846 |
with gr.Column(scale=1):
|
| 847 |
-
video = gr.Video(label="Preview", height=360, autoplay=True)
|
| 848 |
status = gr.Markdown("**Segments:** 0 · **Duration ≈ 0s**", elem_id="status-md")
|
| 849 |
last_preview = gr.Image(label="Last frame (next Extend start)", height=180)
|
| 850 |
download = gr.File(label="Download MP4")
|
|
|
|
| 369 |
) -> Path:
|
| 370 |
client = get_client(token or "")
|
| 371 |
if progress:
|
| 372 |
+
progress(0.2, desc=f"Calling {UPSTREAM_SPACE} (ZeroGPU queue)…")
|
| 373 |
+
progress(0.3, desc="Waiting in ZeroGPU queue… (this can take 1–3 min)")
|
| 374 |
|
| 375 |
# Match generate_video argument order from kulkas2pintu/wan222 /config
|
| 376 |
result = client.predict(
|
|
|
|
| 414 |
|
| 415 |
dest = image_path.parent / f"seg_{uuid.uuid4().hex[:8]}.mp4"
|
| 416 |
shutil.copy2(str(video_path), dest)
|
| 417 |
+
if progress:
|
| 418 |
+
progress(0.75, desc="Video generated, finalizing…")
|
| 419 |
return dest
|
| 420 |
|
| 421 |
|
|
|
|
| 508 |
raise gr.Error("Could not read the uploaded image.")
|
| 509 |
|
| 510 |
progress(0.05, desc="Starting generation…")
|
| 511 |
+
progress(0.15, desc="Preparing image for Wan 2.2…")
|
| 512 |
try:
|
| 513 |
clip = call_wan_i2v(
|
| 514 |
img_path,
|
|
|
|
| 531 |
f"Generation failed (ZeroGPU queue/quota or upstream error): {e}"
|
| 532 |
) from e
|
| 533 |
|
| 534 |
+
progress(0.85, desc="Extracting last frame…")
|
| 535 |
out = sess / "current.mp4"
|
| 536 |
shutil.copy2(clip, out)
|
| 537 |
last = extract_last_frame(out, sess / "last_frame")
|
|
|
|
| 579 |
|
| 580 |
mode_label = (extend_start or EXTEND_START_LAST_FRAME).strip()
|
| 581 |
progress(0.05, desc=f"Extending ({mode_label})…")
|
| 582 |
+
progress(0.15, desc="Preparing extend start image…")
|
| 583 |
try:
|
| 584 |
clip = call_wan_i2v(
|
| 585 |
start_img,
|
|
|
|
| 606 |
concat_videos(segs, out)
|
| 607 |
except Exception as e:
|
| 608 |
raise gr.Error(f"Concat failed (ffmpeg): {e}") from e
|
| 609 |
+
progress(0.90, desc="Concatenating segments…")
|
| 610 |
|
| 611 |
# Always refresh last_frame from the new concatenated video so later
|
| 612 |
# “Last frame from video” extends stay correct.
|
|
|
|
| 722 |
CSS = """
|
| 723 |
.big-btn button { font-size: 1.15rem !important; min-height: 3rem !important; }
|
| 724 |
#status-md { font-size: 1rem; }
|
| 725 |
+
#runpod-balance-md {
|
| 726 |
+
font-size: 1.6rem !important;
|
| 727 |
+
font-weight: 800 !important;
|
| 728 |
+
padding: 0.6rem 1rem !important;
|
| 729 |
+
border-radius: 12px !important;
|
| 730 |
+
background: linear-gradient(135deg, rgba(74,222,128,0.12), rgba(167,139,250,0.10)) !important;
|
| 731 |
+
border: 1px solid rgba(74,222,128,0.35) !important;
|
| 732 |
+
}
|
| 733 |
+
#runpod-balance-md strong { color: #4ade80 !important; }
|
| 734 |
+
/* progress bar animation while generating */
|
| 735 |
+
.gr-progress-bar {
|
| 736 |
+
height: 8px !important;
|
| 737 |
+
border-radius: 999px !important;
|
| 738 |
+
}
|
| 739 |
footer { display: none !important; }
|
| 740 |
"""
|
| 741 |
|
|
|
|
| 864 |
btn_reset = gr.Button("Reset", size="lg")
|
| 865 |
|
| 866 |
with gr.Column(scale=1):
|
| 867 |
+
video = gr.Video(label="Preview", height=360, autoplay=True, loop=True)
|
| 868 |
status = gr.Markdown("**Segments:** 0 · **Duration ≈ 0s**", elem_id="status-md")
|
| 869 |
last_preview = gr.Image(label="Last frame (next Extend start)", height=180)
|
| 870 |
download = gr.File(label="Download MP4")
|