VideoVibeplus / app.py
morbiwalaq's picture
Create app.py
17f9bef verified
import gradio as gr
import cv2
import numpy as np
from transformers import pipeline
# Load a video enhancement model from Hugging Face
# Replace 'your-model-name' with the actual model you want to use
video_enhancer = pipeline("image-enhancement", model="your-model-name")
def enhance_video(video_path):
# Open the video file
cap = cv2.VideoCapture(video_path)
frames = []
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
# Enhance the frame using the model
enhanced_frame = video_enhancer(frame)
frames.append(enhanced_frame)
cap.release()
# Save the enhanced video
output_path = "enhanced_video.mp4"
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter(output_path, fourcc, 30.0, (frames[0].shape[1], frames[0].shape[0]))
for frame in frames:
out.write(frame)
out.release()
return output_path
# Create a Gradio interface
iface = gr.Interface(
fn=enhance_video,
inputs=gr.inputs.Video(label="Upload Video"),
outputs=gr.outputs.Video(label="Enhanced Video"),
title="Video Enhancer",
description="Upload a video to enhance its quality using a Hugging Face model."
)
# Launch the interface
iface.launch()