Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,43 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Function to execute the anime upscaler command
|
| 4 |
+
def execute_upscaler(model_path, input_path, output_path, save_intermediate, async_mode):
|
| 5 |
+
# Build the command
|
| 6 |
+
command = [
|
| 7 |
+
"python3",
|
| 8 |
+
"anime_upscaler.py",
|
| 9 |
+
"-m", model_path,
|
| 10 |
+
"-i", input_path,
|
| 11 |
+
"-o", output_path
|
| 12 |
+
]
|
| 13 |
|
| 14 |
+
# Add optional flags
|
| 15 |
+
if save_intermediate:
|
| 16 |
+
command.append("-s")
|
| 17 |
+
if async_mode:
|
| 18 |
+
command.append("-a")
|
| 19 |
+
|
| 20 |
+
# Execute the command
|
| 21 |
+
import subprocess
|
| 22 |
+
result = subprocess.run(command, capture_output=True, text=True)
|
| 23 |
+
|
| 24 |
+
# Return the output of the command
|
| 25 |
+
return result.stdout
|
| 26 |
+
|
| 27 |
+
# Define the Gradio interface
|
| 28 |
+
iface = gr.Interface(
|
| 29 |
+
fn=execute_upscaler,
|
| 30 |
+
inputs=[
|
| 31 |
+
gr.File("file", label="Model Path (.pth)"),
|
| 32 |
+
gr.File("file", label="Input Video"),
|
| 33 |
+
gr.File("file", label="Output Path"),
|
| 34 |
+
gr.Checkbox("Save Intermediate", default=False),
|
| 35 |
+
gr.Checkbox("Async Mode", default=False),
|
| 36 |
+
],
|
| 37 |
+
outputs="text",
|
| 38 |
+
live=True,
|
| 39 |
+
capture_session=True
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
# Launch the Gradio interface
|
| 43 |
+
iface.launch()
|