Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import subprocess
|
3 |
import os
|
4 |
import gdown
|
|
|
5 |
|
6 |
# Ensure 'checkpoint' directory exists
|
7 |
os.makedirs("checkpoint", exist_ok=True)
|
@@ -61,9 +62,16 @@ def run_xportrait(
|
|
61 |
# Run the command
|
62 |
try:
|
63 |
subprocess.run(command, check=True)
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
except subprocess.CalledProcessError as e:
|
66 |
-
return f"An error occurred: {e}"
|
67 |
|
68 |
# Set up Gradio interface
|
69 |
app = gr.Interface(
|
@@ -81,7 +89,7 @@ app = gr.Interface(
|
|
81 |
gr.Number(value=4, label="Number of Mix"),
|
82 |
gr.Number(value=30, label="DDIM Steps")
|
83 |
],
|
84 |
-
outputs="text",
|
85 |
title="XPortrait Model Runner",
|
86 |
description="Run XPortrait with customizable parameters."
|
87 |
)
|
|
|
2 |
import subprocess
|
3 |
import os
|
4 |
import gdown
|
5 |
+
import glob
|
6 |
|
7 |
# Ensure 'checkpoint' directory exists
|
8 |
os.makedirs("checkpoint", exist_ok=True)
|
|
|
62 |
# Run the command
|
63 |
try:
|
64 |
subprocess.run(command, check=True)
|
65 |
+
|
66 |
+
# Find the generated video file in the output directory
|
67 |
+
video_files = glob.glob(os.path.join(output_dir, "*.mp4")) + glob.glob(os.path.join(output_dir, "*.avi"))
|
68 |
+
print(video_files)
|
69 |
+
if video_files:
|
70 |
+
return f"Output video saved at: {video_files[0]}", video_files[0]
|
71 |
+
else:
|
72 |
+
return "No video file was found in the output directory.", None
|
73 |
except subprocess.CalledProcessError as e:
|
74 |
+
return f"An error occurred: {e}", None
|
75 |
|
76 |
# Set up Gradio interface
|
77 |
app = gr.Interface(
|
|
|
89 |
gr.Number(value=4, label="Number of Mix"),
|
90 |
gr.Number(value=30, label="DDIM Steps")
|
91 |
],
|
92 |
+
outputs=["text", "video"],
|
93 |
title="XPortrait Model Runner",
|
94 |
description="Run XPortrait with customizable parameters."
|
95 |
)
|