itmorn commited on
Commit
3c00b4e
·
1 Parent(s): 4a14d52
Files changed (3) hide show
  1. app.py +26 -14
  2. core.bin +2 -2
  3. z_app_factory.so +0 -0
app.py CHANGED
@@ -1,14 +1,32 @@
1
  import cv2
2
  import gradio as gr
 
 
3
  from z_app_factory import get_app
4
 
 
 
 
5
 
6
  def inference(image):
7
  image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
8
- lst2d_res = get_app(image)
9
- thickness = 3
10
- lineType = 8
11
- font = cv2.FONT_HERSHEY_SIMPLEX
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  for face in lst2d_res:
14
  bbox = [int(i) for i in face["bbox"]]
@@ -26,20 +44,14 @@ def inference(image):
26
  x, y = [int(i) for i in kp]
27
  cv2.circle(image, (x, y), 2, (2, 30, 200), 2)
28
 
29
- landmarks = face["landmarks"]
30
- lst = [[int(i) for i in kp] for kp in landmarks]
31
- for i, kp in enumerate(lst):
32
- x, y = kp
33
- cv2.circle(image, (x, y), 1, (200, 200, 20), 1)
34
-
35
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
36
  return image
37
 
38
 
39
 
40
- title = "Face Keypoint"
41
- description = "demo for Face Keypoint. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
42
- article = "<p style='text-align: center'><a href='https://www.yuque.com/itmorn/ability/face_keypoint' target='_blank'>Project Documents</a> | <a href='https://www.bilibili.com/video/BV1DN4y1P7j3' target='_blank'>Video Demo</a></p>"
43
 
44
  gr.Interface(
45
  inference,
@@ -51,5 +63,5 @@ gr.Interface(
51
  examples=[
52
  ["imgs/face1.jpg"],
53
  ["imgs/face2.jpg"],
54
- ["imgs/cc.png"]
55
  ]).launch(debug=True)
 
1
  import cv2
2
  import gradio as gr
3
+ import numpy as np
4
+
5
  from z_app_factory import get_app
6
 
7
+ thickness = 3
8
+ lineType = 8
9
+ font = cv2.FONT_HERSHEY_SIMPLEX
10
 
11
  def inference(image):
12
  image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
13
+ code,lst2d_res = get_app(image)
14
+ if code == 401:
15
+ msg = "Not RGB three channel picture"
16
+ elif code == 402:
17
+ msg = "Pixels less than 32 × 32"
18
+ elif code == 403:
19
+ msg = "Pixels greater than 4096 × 4096"
20
+ elif code == 404:
21
+ msg = "Files larger than 5MB"
22
+ elif code == 405:
23
+ msg = "System error, please contact the server for troubleshooting"
24
+
25
+ if code!=200:
26
+ img_out = np.zeros((500, 600,3))
27
+ cv2.putText(img_out, msg, (20, 20), font, 1, (0, 255, 0), 2)
28
+ return img_out
29
+
30
 
31
  for face in lst2d_res:
32
  bbox = [int(i) for i in face["bbox"]]
 
44
  x, y = [int(i) for i in kp]
45
  cv2.circle(image, (x, y), 2, (2, 30, 200), 2)
46
 
 
 
 
 
 
 
47
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
48
  return image
49
 
50
 
51
 
52
+ title = "Detect Face"
53
+ description = "demo for Detect Face. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
54
+ article = "<p style='text-align: center'><a href='https://www.yuque.com/itmorn/ability/detect_face' target='_blank'>Project Documents</a> | <a href='https://www.bilibili.com/video/BV1cg411v7CR' target='_blank'>Video Demo</a></p>"
55
 
56
  gr.Interface(
57
  inference,
 
63
  examples=[
64
  ["imgs/face1.jpg"],
65
  ["imgs/face2.jpg"],
66
+ ["imgs/11.jpg"]
67
  ]).launch(debug=True)
core.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:28a28f235c49290d48d6acb21ddacbb3cd44a3e84cb37d5bb8dacf7d8eeb8120
3
- size 20954255
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e76e20bf4de2ba09de06c1af157ac4495e94d24d068622fc64b9fad49514567d
3
+ size 20956224
z_app_factory.so CHANGED
Binary files a/z_app_factory.so and b/z_app_factory.so differ