jeffin07 commited on
Commit
9890dda
1 Parent(s): 66765a3

Added Face detection

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -30,8 +30,6 @@ def detect(img_raw):
30
  dets = face_detection(img)
31
  dets = [FaceDetectorResult(o) for o in dets[0]]
32
 
33
-
34
-
35
  img_vis = img_raw.copy()
36
 
37
  vis_threshold = 0.8
@@ -40,15 +38,19 @@ def detect(img_raw):
40
  if b.score < vis_threshold:
41
  continue
42
 
43
- # draw face bounding box
44
  img_vis = cv2.rectangle(img_vis, b.top_left.int().tolist(), b.bottom_right.int().tolist(), (0, 255, 0), 4)
45
-
 
 
 
 
 
46
 
47
  return img_vis
48
 
49
 
50
 
51
-
52
  title = "Kornia Face Detection"
53
  description = "<p style='text-align: center'>This is a Gradio demo for Kornia's Face Detection.</p><p style='text-align: center'>To use it, simply upload your image, or click one of the examples to load them</p>"
54
  article = "<p style='text-align: center'><a href='https://kornia.readthedocs.io/en/latest/' target='_blank'>Kornia Docs</a> | <a href='https://github.com/kornia/kornia' target='_blank'>Kornia Github Repo</a> | <a href='https://kornia.readthedocs.io/en/latest/applications/face_detection.html' target='_blank'>Kornia Face Detection Tutorial</a></p>"
 
30
  dets = face_detection(img)
31
  dets = [FaceDetectorResult(o) for o in dets[0]]
32
 
 
 
33
  img_vis = img_raw.copy()
34
 
35
  vis_threshold = 0.8
 
38
  if b.score < vis_threshold:
39
  continue
40
 
41
+ # Draw face bounding box
42
  img_vis = cv2.rectangle(img_vis, b.top_left.int().tolist(), b.bottom_right.int().tolist(), (0, 255, 0), 4)
43
+ # Draw Keypoints
44
+ img_vis = draw_keypoint(img_vis, b, FaceKeypoint.EYE_LEFT)
45
+ img_vis = draw_keypoint(img_vis, b, FaceKeypoint.EYE_RIGHT)
46
+ img_vis = draw_keypoint(img_vis, b, FaceKeypoint.NOSE)
47
+ img_vis = draw_keypoint(img_vis, b, FaceKeypoint.MOUTH_LEFT)
48
+ img_vis = draw_keypoint(img_vis, b, FaceKeypoint.MOUTH_RIGHT)
49
 
50
  return img_vis
51
 
52
 
53
 
 
54
  title = "Kornia Face Detection"
55
  description = "<p style='text-align: center'>This is a Gradio demo for Kornia's Face Detection.</p><p style='text-align: center'>To use it, simply upload your image, or click one of the examples to load them</p>"
56
  article = "<p style='text-align: center'><a href='https://kornia.readthedocs.io/en/latest/' target='_blank'>Kornia Docs</a> | <a href='https://github.com/kornia/kornia' target='_blank'>Kornia Github Repo</a> | <a href='https://kornia.readthedocs.io/en/latest/applications/face_detection.html' target='_blank'>Kornia Face Detection Tutorial</a></p>"