-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
34 lines (27 loc) · 1.03 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from main import infer
import moviepy.editor as mp
import gradio as gr
import os
import tempfile
def pre_processor(video_path, scale_factor, prompt, crop_duration):
video = mp.VideoFileClip(video_path)
cropped_video = video.subclip(0, min(crop_duration, video.duration))
with tempfile.NamedTemporaryFile(suffix='.mp4', delete=False) as temp_file:
temp_output = temp_file.name
cropped_video.write_videofile(temp_output, codec="libx264")
output = infer(temp_output, scale_factor, prompt)
# Clean up temporary file
os.unlink(temp_output)
return output
demo = gr.Interface(
title="Text Based Video Inpainting 🔥 (SAM2+Florance2+ProPainter)",
fn=pre_processor,
inputs=[
gr.Video(label="Upload Video"),
gr.Slider(0.1, 1.0, step=0.1, value=0.5, label="Resize Scale Factor (Due to OOM error)"),
gr.Textbox(label="Prompt"),
gr.Slider(1, 12, step=1, value=6, label="Crop Duration (seconds)")
],
outputs="video"
)
demo.launch(server_port=7555)