LBLong commited on
Commit
1d78bb3
·
verified ·
1 Parent(s): 73d3e51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -7,11 +7,11 @@ from PIL import Image
7
  import numpy as np
8
  from transformers import pipeline
9
 
 
10
  pipe = pipeline("image-classification", model="NTQAI/pedestrian_gender_recognition")
11
  model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
12
  model = YOLO(model_path)
13
 
14
-
15
  def detect_faces(image):
16
  output = model(image)
17
  results = Detections.from_ultralytics(output[0])
@@ -20,8 +20,6 @@ def detect_faces(image):
20
  for i in results:
21
  im = cv2.rectangle(im, (int(i[0][0]),int(i[0][1])), (int(i[0][2]),int(i[0][3])), (0,0,255), 2)
22
 
23
- label_out = pipe(image)
24
-
25
  image_np = np.array(image)
26
  gray_image = cv2.cvtColor(image_np, cv2.COLOR_RGB2GRAY)
27
  face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
@@ -29,6 +27,8 @@ def detect_faces(image):
29
  for (x, y, w, h) in faces:
30
  cv2.rectangle(image_np, (x, y), (x+w, y+h), (0, 255, 0), 2)
31
 
 
 
32
  return (image_np,im,label_out[0]['label'])
33
 
34
  interface = gr.Interface(
 
7
  import numpy as np
8
  from transformers import pipeline
9
 
10
+
11
  pipe = pipeline("image-classification", model="NTQAI/pedestrian_gender_recognition")
12
  model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
13
  model = YOLO(model_path)
14
 
 
15
  def detect_faces(image):
16
  output = model(image)
17
  results = Detections.from_ultralytics(output[0])
 
20
  for i in results:
21
  im = cv2.rectangle(im, (int(i[0][0]),int(i[0][1])), (int(i[0][2]),int(i[0][3])), (0,0,255), 2)
22
 
 
 
23
  image_np = np.array(image)
24
  gray_image = cv2.cvtColor(image_np, cv2.COLOR_RGB2GRAY)
25
  face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
 
27
  for (x, y, w, h) in faces:
28
  cv2.rectangle(image_np, (x, y), (x+w, y+h), (0, 255, 0), 2)
29
 
30
+ label_out = pipe(image)
31
+
32
  return (image_np,im,label_out[0]['label'])
33
 
34
  interface = gr.Interface(