mkhodary101 commited on
Commit
1237fa8
·
verified ·
1 Parent(s): 92e7cc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -415,6 +415,13 @@ import os
415
  from ultralytics import YOLO
416
  import gradio as gr
417
 
 
 
 
 
 
 
 
418
  class IntrusionDetectionEn:
419
  def __init__(self, model_path="yolov8n.pt", max_intrusion_time=300, iou_threshold=0.5, conf_threshold=0.7):
420
  self.model_path = model_path
@@ -435,8 +442,7 @@ class IntrusionDetectionEn:
435
  self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
436
  self.model = YOLO(self.model_path)
437
  self.model.to(self.device)
438
-
439
- @spaces.GPU
440
  def is_staff(self, person_crop):
441
  """Checks if the detected person is a staff member based on clothing color."""
442
  avg_color = np.mean(person_crop, axis=(0, 1)) # Compute average color (BGR)
@@ -449,6 +455,7 @@ class IntrusionDetectionEn:
449
  return True
450
  return False
451
 
 
452
  def intrusion_detect_en(self, video_path):
453
  try:
454
  cap = cv2.VideoCapture(video_path)
@@ -505,6 +512,7 @@ class IntrusionDetectionEn:
505
 
506
 
507
 
 
508
  import cv2
509
  import numpy as np
510
  from ultralytics import YOLO
 
415
  from ultralytics import YOLO
416
  import gradio as gr
417
 
418
+ import torch
419
+ import cv2
420
+ import numpy as np
421
+ import os
422
+ from ultralytics import YOLO
423
+ import gradio as gr
424
+
425
  class IntrusionDetectionEn:
426
  def __init__(self, model_path="yolov8n.pt", max_intrusion_time=300, iou_threshold=0.5, conf_threshold=0.7):
427
  self.model_path = model_path
 
442
  self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
443
  self.model = YOLO(self.model_path)
444
  self.model.to(self.device)
445
+
 
446
  def is_staff(self, person_crop):
447
  """Checks if the detected person is a staff member based on clothing color."""
448
  avg_color = np.mean(person_crop, axis=(0, 1)) # Compute average color (BGR)
 
455
  return True
456
  return False
457
 
458
+ @gr.GPU
459
  def intrusion_detect_en(self, video_path):
460
  try:
461
  cap = cv2.VideoCapture(video_path)
 
512
 
513
 
514
 
515
+
516
  import cv2
517
  import numpy as np
518
  from ultralytics import YOLO