Spaces:
Sleeping
Sleeping
Delete appSmall.py
Browse files- appSmall.py +0 -50
appSmall.py
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from pathlib import Path
|
3 |
-
import subprocess
|
4 |
-
from inference_img import * # Assuming necessary functions are exposed here
|
5 |
-
|
6 |
-
# Constants
|
7 |
-
OUTPUT_GIF = Path("demo/output.gif")
|
8 |
-
FRAME1_PATH = Path("demo/frame1.png")
|
9 |
-
FRAME2_PATH = Path("demo/frame2.png")
|
10 |
-
|
11 |
-
# Function to generate GIF
|
12 |
-
def generate_demo_gif(_1, _2):
|
13 |
-
try:
|
14 |
-
result = subprocess.run([
|
15 |
-
"python", "inference_img.py",
|
16 |
-
"--img", str(FRAME1_PATH), str(FRAME2_PATH),
|
17 |
-
"--exp=4",
|
18 |
-
"--model", "train_log/"
|
19 |
-
], capture_output=True, text=True)
|
20 |
-
|
21 |
-
print("STDOUT:", result.stdout)
|
22 |
-
print("STDERR:", result.stderr)
|
23 |
-
|
24 |
-
if result.returncode == 0 and OUTPUT_GIF.exists():
|
25 |
-
return str(OUTPUT_GIF), "✅ GIF generated successfully!"
|
26 |
-
else:
|
27 |
-
return None, "❌ GIF generation failed. Check logs or file paths."
|
28 |
-
|
29 |
-
except Exception as e:
|
30 |
-
print(f"Error: {e}")
|
31 |
-
return None, f"❌ Subprocess error: {e}"
|
32 |
-
|
33 |
-
# Gradio UI
|
34 |
-
with gr.Blocks() as demo_ui:
|
35 |
-
with gr.Tab("Demo"):
|
36 |
-
gr.Markdown("### Preview frames and generate animation. #FREE CPU cut off, 5.5 seconds and done. No AI democracy.")
|
37 |
-
with gr.Row():
|
38 |
-
img1_preview = gr.Image(value=str(FRAME1_PATH), label="Frame 1", interactive=False)
|
39 |
-
img2_preview = gr.Image(value=str(FRAME2_PATH), label="Frame 2", interactive=False)
|
40 |
-
generate_btn = gr.Button("Generate GIF")
|
41 |
-
output_gif = gr.Image(label="Animated GIF")
|
42 |
-
status_msg = gr.Markdown()
|
43 |
-
|
44 |
-
generate_btn.click(
|
45 |
-
fn=generate_demo_gif,
|
46 |
-
inputs=[img1_preview, img2_preview], # Non-interactive but passed to match fn signature
|
47 |
-
outputs=[output_gif, status_msg]
|
48 |
-
)
|
49 |
-
|
50 |
-
demo_ui.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|