File size: 1,017 Bytes
f68e74f
 
 
 
cf69cd2
f68e74f
c8e9946
f68e74f
c8e9946
 
 
1c990aa
70e718d
c8e9946
 
 
 
 
 
 
f68e74f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
import gradio as gr
import os
import tempfile
from Fight_detec_func import fight_detec
from objec_detect_yolo import detect_objects_in_video

def analyze_video(video_path):
    temp_dir = "/tmp"
    output_path = os.path.join(temp_dir, "output.mp4")

    # Call your fight and object detection functions
    fight_result = fight_detec(video_path)
    crime_result, annotated_video_path = detect_objects_in_video(video_path)

    return {
        "Fight": fight_result,
        "Crime": crime_result,
        "Output Video": annotated_video_path
    }

    
    # Clean up
    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()