Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
|
|
|
| 3 |
from utils.video_processor import compare_videos
|
| 4 |
|
| 5 |
def compare_videos_interface(video1, video2):
|
|
@@ -8,20 +9,18 @@ def compare_videos_interface(video1, video2):
|
|
| 8 |
|
| 9 |
# Validate file extensions
|
| 10 |
valid_extensions = [".mp4", ".avi", ".mov"]
|
| 11 |
-
if not any(video1.
|
| 12 |
-
not any(video2.
|
| 13 |
return "Invalid video format. Please upload MP4, AVI, or MOV files.", None, None
|
| 14 |
|
| 15 |
# Save uploaded videos temporarily
|
| 16 |
os.makedirs("temp", exist_ok=True)
|
| 17 |
-
video1_path = os.path.join("temp", os.path.basename(video1
|
| 18 |
-
video2_path = os.path.join("temp", os.path.basename(video2
|
| 19 |
|
| 20 |
# Copy uploaded files to temp directory
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
with open(video2_path, "wb") as f:
|
| 24 |
-
f.write(video2.read())
|
| 25 |
|
| 26 |
try:
|
| 27 |
# Compare videos
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
import shutil
|
| 4 |
from utils.video_processor import compare_videos
|
| 5 |
|
| 6 |
def compare_videos_interface(video1, video2):
|
|
|
|
| 9 |
|
| 10 |
# Validate file extensions
|
| 11 |
valid_extensions = [".mp4", ".avi", ".mov"]
|
| 12 |
+
if not any(video1.lower().endswith(ext) for ext in valid_extensions) or \
|
| 13 |
+
not any(video2.lower().endswith(ext) for ext in valid_extensions):
|
| 14 |
return "Invalid video format. Please upload MP4, AVI, or MOV files.", None, None
|
| 15 |
|
| 16 |
# Save uploaded videos temporarily
|
| 17 |
os.makedirs("temp", exist_ok=True)
|
| 18 |
+
video1_path = os.path.join("temp", os.path.basename(video1))
|
| 19 |
+
video2_path = os.path.join("temp", os.path.basename(video2))
|
| 20 |
|
| 21 |
# Copy uploaded files to temp directory
|
| 22 |
+
shutil.copy(video1, video1_path)
|
| 23 |
+
shutil.copy(video2, video2_path)
|
|
|
|
|
|
|
| 24 |
|
| 25 |
try:
|
| 26 |
# Compare videos
|