Spaces:
Sleeping
Sleeping
Pudding proof
Browse files
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from pathlib import Path
|
3 |
+
import subprocess
|
4 |
+
|
5 |
+
# Paths
|
6 |
+
FRAME1 = Path("demo/frame1.jpg")
|
7 |
+
FRAME2 = Path("demo/frame2.jpg")
|
8 |
+
OUTPUT_GIF = Path("demo/demo.gif")
|
9 |
+
|
10 |
+
def generate_demo_gif():
|
11 |
+
try:
|
12 |
+
result = subprocess.run([
|
13 |
+
"python", "inference_img.py",
|
14 |
+
"--img", str(FRAME1), str(FRAME2),
|
15 |
+
"--exp=4"
|
16 |
+
], capture_output=True, text=True)
|
17 |
+
|
18 |
+
print("STDOUT:", result.stdout)
|
19 |
+
print("STDERR:", result.stderr)
|
20 |
+
|
21 |
+
if result.returncode == 0 and OUTPUT_GIF.exists():
|
22 |
+
return OUTPUT_GIF
|
23 |
+
else:
|
24 |
+
return None
|
25 |
+
except Exception as e:
|
26 |
+
print(f"Error: {e}")
|
27 |
+
return None
|
28 |
+
|
29 |
+
def demo_tab():
|
30 |
+
gif_path = generate_demo_gif()
|
31 |
+
if gif_path:
|
32 |
+
return gif_path
|
33 |
+
else:
|
34 |
+
return "GIF generation failed."
|
35 |
+
|
36 |
+
with gr.Blocks() as demo_ui:
|
37 |
+
with gr.Tab("Demo"):
|
38 |
+
gr.Image(value=demo_tab(), label="Generated GIF")
|
39 |
+
|
40 |
+
demo_ui.launch()
|