|
import gradio as gr
|
|
import os
|
|
import tempfile
|
|
from Fight_detec_func import fight_detec
|
|
from objec_detect_yolo import detection
|
|
|
|
def analyze_video(video_file):
|
|
|
|
temp_dir = tempfile.mkdtemp()
|
|
video_path = os.path.join(temp_dir, video_file.name)
|
|
with open(video_path, 'wb') as f:
|
|
f.write(video_file.read())
|
|
|
|
|
|
fight_result = fight_detec(video_path, debug=False)
|
|
yolo_result = detection(video_path)
|
|
|
|
|
|
os.remove(video_path)
|
|
os.rmdir(temp_dir)
|
|
|
|
return {
|
|
"Fight Detection": fight_result[0],
|
|
"YOLO Object Detection": yolo_result
|
|
}
|
|
|
|
iface = gr.Interface(
|
|
fn=analyze_video,
|
|
inputs=gr.Video(label="Upload Video"),
|
|
outputs=gr.JSON(label="Detection Results"),
|
|
title="Fight and Object Detection System",
|
|
description="Upload a video to detect fights and objects using our AI models"
|
|
)
|
|
|
|
iface.launch()
|
|
|