Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,13 +4,13 @@ import glob
|
|
4 |
import shutil
|
5 |
import numpy as np
|
6 |
import gradio as gr
|
7 |
-
from
|
8 |
-
from moviepy import *
|
9 |
from insightface.app import FaceAnalysis
|
10 |
|
11 |
def video_to_images(video_path, images_path):
|
12 |
cam = cv2.VideoCapture(video_path)
|
13 |
fps = cam.get(cv2.CAP_PROP_FPS)
|
|
|
14 |
clip = VideoFileClip(video_path)
|
15 |
clip.audio.write_audiofile("./audio.mp3")
|
16 |
|
@@ -70,7 +70,7 @@ def process(video):
|
|
70 |
output_path = "output.mp4"
|
71 |
frames_dir = "frames"
|
72 |
|
73 |
-
|
74 |
fps = video_to_images(input_path, frames_dir)
|
75 |
blur_faces_in_images(frames_dir)
|
76 |
images_to_video(frames_dir, output_path, fps)
|
@@ -82,8 +82,8 @@ demo = gr.Interface(
|
|
82 |
fn=process,
|
83 |
inputs=gr.Video(label="Upload Video"),
|
84 |
outputs=gr.Video(label="Faces Blurred"),
|
85 |
-
title="Face
|
86 |
-
description="
|
87 |
)
|
88 |
|
89 |
if __name__ == "__main__":
|
|
|
4 |
import shutil
|
5 |
import numpy as np
|
6 |
import gradio as gr
|
7 |
+
from moviepy.editor import VideoFileClip, AudioFileClip, CompositeAudioClip
|
|
|
8 |
from insightface.app import FaceAnalysis
|
9 |
|
10 |
def video_to_images(video_path, images_path):
|
11 |
cam = cv2.VideoCapture(video_path)
|
12 |
fps = cam.get(cv2.CAP_PROP_FPS)
|
13 |
+
|
14 |
clip = VideoFileClip(video_path)
|
15 |
clip.audio.write_audiofile("./audio.mp3")
|
16 |
|
|
|
70 |
output_path = "output.mp4"
|
71 |
frames_dir = "frames"
|
72 |
|
73 |
+
shutil.copy(video, input_path) # ✅ Fix: copy the uploaded file
|
74 |
fps = video_to_images(input_path, frames_dir)
|
75 |
blur_faces_in_images(frames_dir)
|
76 |
images_to_video(frames_dir, output_path, fps)
|
|
|
82 |
fn=process,
|
83 |
inputs=gr.Video(label="Upload Video"),
|
84 |
outputs=gr.Video(label="Faces Blurred"),
|
85 |
+
title="Face Blur App",
|
86 |
+
description="Detects and blurs all faces in your video using InsightFace."
|
87 |
)
|
88 |
|
89 |
if __name__ == "__main__":
|