Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request, redirect, url_for
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
@app.route('/', methods=['GET', 'POST'])
|
| 7 |
+
def index():
|
| 8 |
+
if request.method == 'POST':
|
| 9 |
+
# Get form inputs
|
| 10 |
+
target_path = request.form['target_path']
|
| 11 |
+
output_quality = request.form['output_quality']
|
| 12 |
+
source_path = request.form['source_path']
|
| 13 |
+
output_path = request.form['output_path']
|
| 14 |
+
execution_provider = request.form['execution_provider']
|
| 15 |
+
frame_processors = request.form.getlist('frame_processors')
|
| 16 |
+
|
| 17 |
+
# Construct command
|
| 18 |
+
command = [
|
| 19 |
+
"python", "run.py",
|
| 20 |
+
"--target", target_path,
|
| 21 |
+
"--output-video-quality", output_quality,
|
| 22 |
+
"--source", source_path,
|
| 23 |
+
"-o", output_path,
|
| 24 |
+
"--execution-provider", execution_provider,
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
# Add frame processors if provided
|
| 28 |
+
if frame_processors:
|
| 29 |
+
command.extend(["--frame-processor"] + frame_processors)
|
| 30 |
+
|
| 31 |
+
# Run the command
|
| 32 |
+
subprocess.run(command)
|
| 33 |
+
|
| 34 |
+
return redirect(url_for('index'))
|
| 35 |
+
|
| 36 |
+
return render_template('./index.html')
|
| 37 |
+
|
| 38 |
+
if __name__ == '__main__':
|
| 39 |
+
app.run(debug=True)
|