saketh-005 commited on
Commit
3a2441a
·
verified ·
1 Parent(s): 1a84c6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -2,12 +2,11 @@ import gradio as gr
2
  import numpy as np
3
  from ultralytics import YOLO
4
 
5
- # Use lightweight face model
6
- model = YOLO("yolov8n.pt") # lightweight model
7
 
8
  def detect_faces(image):
9
  image_np = np.array(image)
10
-
11
  results = model(image_np)
12
 
13
  faces = []
@@ -15,8 +14,7 @@ def detect_faces(image):
15
  for r in results:
16
  boxes = r.boxes.xyxy.cpu().numpy()
17
 
18
- for box in boxes:
19
- xmin, ymin, xmax, ymax = box
20
  cx = (xmin + xmax) / 2
21
  cy = (ymin + ymax) / 2
22
 
 
2
  import numpy as np
3
  from ultralytics import YOLO
4
 
5
+ # Use face detection model
6
+ model = YOLO("yolov8n-face.pt")
7
 
8
  def detect_faces(image):
9
  image_np = np.array(image)
 
10
  results = model(image_np)
11
 
12
  faces = []
 
14
  for r in results:
15
  boxes = r.boxes.xyxy.cpu().numpy()
16
 
17
+ for xmin, ymin, xmax, ymax in boxes:
 
18
  cx = (xmin + xmax) / 2
19
  cy = (ymin + ymax) / 2
20