Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import tempfile
|
|
|
4 |
|
5 |
# Function to execute the anime upscaler command
|
6 |
def execute_upscaler(input_video, output_path, save_intermediate, async_mode):
|
@@ -11,39 +12,43 @@ def execute_upscaler(input_video, output_path, save_intermediate, async_mode):
|
|
11 |
# Create a temporary directory to store the uploaded video
|
12 |
temp_dir = tempfile.mkdtemp()
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Define the Gradio interface
|
41 |
iface = gr.Interface(
|
42 |
fn=execute_upscaler,
|
43 |
inputs=gr.Video(),
|
44 |
outputs=gr.Video(),
|
45 |
-
live=True
|
46 |
-
capture_session=True
|
47 |
)
|
48 |
|
49 |
# Launch the Gradio interface
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import tempfile
|
4 |
+
import shutil
|
5 |
|
6 |
# Function to execute the anime upscaler command
|
7 |
def execute_upscaler(input_video, output_path, save_intermediate, async_mode):
|
|
|
12 |
# Create a temporary directory to store the uploaded video
|
13 |
temp_dir = tempfile.mkdtemp()
|
14 |
|
15 |
+
try:
|
16 |
+
# Save the uploaded video to the temporary directory
|
17 |
+
input_video_path = os.path.join(temp_dir, "input_video.mp4")
|
18 |
+
input_video.save(input_video_path)
|
19 |
+
|
20 |
+
# Build the command
|
21 |
+
command = [
|
22 |
+
"python3",
|
23 |
+
"anime_upscaler.py",
|
24 |
+
"-m", model_path,
|
25 |
+
"-i", input_video_path,
|
26 |
+
"-o", output_path
|
27 |
+
]
|
28 |
+
|
29 |
+
# Add optional flags
|
30 |
+
if save_intermediate:
|
31 |
+
command.append("-s")
|
32 |
+
if async_mode:
|
33 |
+
command.append("-a")
|
34 |
+
|
35 |
+
# Execute the command
|
36 |
+
import subprocess
|
37 |
+
result = subprocess.run(command, capture_output=True, text=True)
|
38 |
+
|
39 |
+
# Return the output of the command
|
40 |
+
return result.stdout
|
41 |
+
|
42 |
+
finally:
|
43 |
+
# Cleanup: Remove the temporary directory
|
44 |
+
shutil.rmtree(temp_dir)
|
45 |
|
46 |
# Define the Gradio interface
|
47 |
iface = gr.Interface(
|
48 |
fn=execute_upscaler,
|
49 |
inputs=gr.Video(),
|
50 |
outputs=gr.Video(),
|
51 |
+
live=True
|
|
|
52 |
)
|
53 |
|
54 |
# Launch the Gradio interface
|