AI / app.py
Asjad135's picture
Upload 3 files
e047f7d verified
import gradio as gr
import subprocess
import tempfile
import os
def upscale_video(video):
with tempfile.TemporaryDirectory() as tempdir:
input_path = os.path.join(tempdir, "input.mp4")
output_path = os.path.join(tempdir, "output.mp4")
with open(input_path, "wb") as f:
f.write(video.read())
cmd = [
"python", "inference_realesrgan.py",
"-i", input_path,
"-o", output_path,
"-n", "RealESRGAN_x4plus",
"--outscale", "2"
]
try:
subprocess.run(cmd, check=True)
return output_path
except subprocess.CalledProcessError as e:
return f"Error: {str(e)}"
demo = gr.Interface(fn=upscale_video,
inputs=gr.Video(label="Upload your video"),
outputs=gr.Video(label="Upscaled Output"),
title="Video Upscaler - Real-ESRGAN",
description="Upload a low-resolution video and get an upscaled version using Real-ESRGAN.")
demo.launch()