Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,10 @@ import os
|
|
9 |
|
10 |
class CrowdDetection:
|
11 |
def __init__(self, model_path="yolov8n.pt"):
|
12 |
-
self.model_path = model_path
|
13 |
|
14 |
@spaces.GPU
|
15 |
-
def
|
16 |
try:
|
17 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
18 |
if not os.path.exists(self.model_path):
|
@@ -69,14 +69,14 @@ class CrowdDetection:
|
|
69 |
raise ValueError("❌ Processing failed: No frames processed or output not created")
|
70 |
return output_path
|
71 |
except Exception as e:
|
72 |
-
raise ValueError(f"Error in
|
73 |
|
74 |
class PeopleTracking:
|
75 |
def __init__(self, yolo_model_path="yolov8n.pt"):
|
76 |
self.model_path = yolo_model_path
|
77 |
|
78 |
@spaces.GPU
|
79 |
-
def
|
80 |
try:
|
81 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
82 |
if not os.path.exists(self.model_path):
|
@@ -124,14 +124,14 @@ class PeopleTracking:
|
|
124 |
raise ValueError("❌ Processing failed")
|
125 |
return output_path
|
126 |
except Exception as e:
|
127 |
-
raise ValueError(f"Error in
|
128 |
|
129 |
class FallDetection:
|
130 |
def __init__(self, yolo_model_path="yolov8l.pt"):
|
131 |
self.model_path = yolo_model_path
|
132 |
|
133 |
@spaces.GPU
|
134 |
-
def
|
135 |
try:
|
136 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
137 |
if not os.path.exists(self.model_path):
|
@@ -189,14 +189,14 @@ class FallDetection:
|
|
189 |
raise ValueError("❌ Processing failed")
|
190 |
return output_path
|
191 |
except Exception as e:
|
192 |
-
raise ValueError(f"Error in
|
193 |
|
194 |
class FightDetection:
|
195 |
def __init__(self, yolo_model_path="yolov8n-pose.pt"):
|
196 |
self.model_path = yolo_model_path
|
197 |
|
198 |
@spaces.GPU
|
199 |
-
def
|
200 |
try:
|
201 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
202 |
if not os.path.exists(self.model_path):
|
@@ -254,7 +254,7 @@ class FightDetection:
|
|
254 |
raise ValueError("❌ Processing failed")
|
255 |
return output_path
|
256 |
except Exception as e:
|
257 |
-
raise ValueError(f"Error in
|
258 |
|
259 |
# Unified processing function with status output
|
260 |
def process_video(feature, video):
|
|
|
9 |
|
10 |
class CrowdDetection:
|
11 |
def __init__(self, model_path="yolov8n.pt"):
|
12 |
+
self.model_path = model_path
|
13 |
|
14 |
@spaces.GPU
|
15 |
+
def crowd_detection(self, video_path):
|
16 |
try:
|
17 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
18 |
if not os.path.exists(self.model_path):
|
|
|
69 |
raise ValueError("❌ Processing failed: No frames processed or output not created")
|
70 |
return output_path
|
71 |
except Exception as e:
|
72 |
+
raise ValueError(f"Error in crowd_detection: {str(e)}")
|
73 |
|
74 |
class PeopleTracking:
|
75 |
def __init__(self, yolo_model_path="yolov8n.pt"):
|
76 |
self.model_path = yolo_model_path
|
77 |
|
78 |
@spaces.GPU
|
79 |
+
def people_tracking(self, video_path):
|
80 |
try:
|
81 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
82 |
if not os.path.exists(self.model_path):
|
|
|
124 |
raise ValueError("❌ Processing failed")
|
125 |
return output_path
|
126 |
except Exception as e:
|
127 |
+
raise ValueError(f"Error in people_tracking: {str(e)}")
|
128 |
|
129 |
class FallDetection:
|
130 |
def __init__(self, yolo_model_path="yolov8l.pt"):
|
131 |
self.model_path = yolo_model_path
|
132 |
|
133 |
@spaces.GPU
|
134 |
+
def fall_detection(self, video_path):
|
135 |
try:
|
136 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
137 |
if not os.path.exists(self.model_path):
|
|
|
189 |
raise ValueError("❌ Processing failed")
|
190 |
return output_path
|
191 |
except Exception as e:
|
192 |
+
raise ValueError(f"Error in fall_detection: {str(e)}")
|
193 |
|
194 |
class FightDetection:
|
195 |
def __init__(self, yolo_model_path="yolov8n-pose.pt"):
|
196 |
self.model_path = yolo_model_path
|
197 |
|
198 |
@spaces.GPU
|
199 |
+
def fight_detection(self, video_path):
|
200 |
try:
|
201 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
202 |
if not os.path.exists(self.model_path):
|
|
|
254 |
raise ValueError("❌ Processing failed")
|
255 |
return output_path
|
256 |
except Exception as e:
|
257 |
+
raise ValueError(f"Error in fight_detection: {str(e)}")
|
258 |
|
259 |
# Unified processing function with status output
|
260 |
def process_video(feature, video):
|