Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,14 +4,14 @@ import subprocess
|
|
4 |
import tempfile
|
5 |
from glob import glob
|
6 |
|
7 |
-
def run_inference(image_input, audio_input
|
8 |
|
9 |
# Create a temporary folder for downloaded and processed images
|
10 |
temp_dir = tempfile.mkdtemp()
|
11 |
|
12 |
try:
|
13 |
-
#
|
14 |
-
|
15 |
[
|
16 |
"python", "inference.py",
|
17 |
"--config", "configs/inference.yaml",
|
@@ -19,29 +19,17 @@ def run_inference(image_input, audio_input, progress=gr.Progress(track_tqdm=True
|
|
19 |
"--input_audio", audio_input,
|
20 |
"--output_dir", temp_dir,
|
21 |
],
|
22 |
-
|
23 |
-
stderr=subprocess.PIPE, # Capture standard error
|
24 |
-
text=True, # Decode output to text (instead of bytes)
|
25 |
)
|
26 |
|
27 |
-
#
|
28 |
-
for line in process.stdout:
|
29 |
-
print(line, end="") # Print logs to the console (or handle them as needed)
|
30 |
-
|
31 |
-
# Wait for the subprocess to finish and check for errors
|
32 |
-
process.wait()
|
33 |
-
if process.returncode != 0:
|
34 |
-
error_message = process.stderr.read()
|
35 |
-
raise gr.Error(f"Inference failed with error: {error_message}")
|
36 |
-
|
37 |
-
# Collect the output video
|
38 |
output_video = glob(os.path.join(temp_dir, "*.mp4"))
|
39 |
-
return output_video[0]
|
40 |
-
|
41 |
-
except Exception as e:
|
42 |
raise gr.Error(f"Error during inference: {str(e)}")
|
43 |
|
44 |
|
|
|
45 |
with gr.Blocks() as demo:
|
46 |
with gr.Column():
|
47 |
gr.Markdown("# MEMO")
|
|
|
4 |
import tempfile
|
5 |
from glob import glob
|
6 |
|
7 |
+
def run_inference(image_input, audio_input):
|
8 |
|
9 |
# Create a temporary folder for downloaded and processed images
|
10 |
temp_dir = tempfile.mkdtemp()
|
11 |
|
12 |
try:
|
13 |
+
# Run the inference command
|
14 |
+
subprocess.run(
|
15 |
[
|
16 |
"python", "inference.py",
|
17 |
"--config", "configs/inference.yaml",
|
|
|
19 |
"--input_audio", audio_input,
|
20 |
"--output_dir", temp_dir,
|
21 |
],
|
22 |
+
check=True
|
|
|
|
|
23 |
)
|
24 |
|
25 |
+
# Collect the output images
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
output_video = glob(os.path.join(temp_dir, "*.mp4"))
|
27 |
+
return output_video[0]
|
28 |
+
except subprocess.CalledProcessError as e:
|
|
|
29 |
raise gr.Error(f"Error during inference: {str(e)}")
|
30 |
|
31 |
|
32 |
+
|
33 |
with gr.Blocks() as demo:
|
34 |
with gr.Column():
|
35 |
gr.Markdown("# MEMO")
|