mkhodary101 commited on
Commit
3d44b76
·
verified ·
1 Parent(s): 4e43aa1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
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 # Store path, load model later
13
 
14
  @spaces.GPU
15
- def detect_crowd(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,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 detect_crowd: {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 track_people(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,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 track_people: {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 detect_fall(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,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 detect_fall: {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 detect_fight(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,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 detect_fight: {str(e)}")
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):