itmorn commited on
Commit
30fbe46
·
1 Parent(s): ba3b01b
Files changed (8) hide show
  1. README.md +1 -1
  2. app.py +75 -0
  3. core.bin +3 -0
  4. imgs/11.jpg +0 -0
  5. imgs/13.jpg +0 -0
  6. mic.bin +3 -0
  7. requirements.txt +11 -0
  8. z_app_factory.so +0 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Detect Living Face
3
- emoji: 💩
4
  colorFrom: pink
5
  colorTo: indigo
6
  sdk: gradio
 
1
  ---
2
  title: Detect Living Face
3
+ emoji: 🤖
4
  colorFrom: pink
5
  colorTo: indigo
6
  sdk: gradio
app.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import gradio as gr
3
+ import io
4
+ import numpy as np
5
+
6
+ from z_app_factory import get_app
7
+
8
+ thickness = 3
9
+ lineType = 8
10
+ font = cv2.FONT_HERSHEY_SIMPLEX
11
+
12
+ def inference(image):
13
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
14
+ dic_res = get_app(image)
15
+ code = dic_res["code"]
16
+ data = dic_res["data"]
17
+
18
+ msg = "aaa"
19
+ if code == 401:
20
+ msg = "Not RGB three channel picture"
21
+ elif code == 402:
22
+ msg = "Pixels less than 32 * 32"
23
+ elif code == 403:
24
+ msg = "Pixels greater than 4096 * 4096"
25
+ elif code == 404:
26
+ msg = "Files greater than 5MB"
27
+ elif code == 405:
28
+ msg = "System error, please contact\n the server for troubleshooting"
29
+ import numpy as np
30
+ img_out = np.zeros((500, 600, 3), dtype=np.uint8)
31
+ if code!=200:
32
+ cv2.putText(img_out, msg, (20, 200), font, 1, (0, 255, 0), 2)
33
+ return img_out
34
+
35
+ if code==200 and not data:
36
+ cv2.putText(img_out, "no face detected", (20, 200), font, 1, (0, 255, 0), 2)
37
+ return img_out
38
+
39
+ lst_bbox = data['bbox']
40
+ lst_score = data['score']
41
+ for idx, image_bbox in enumerate(lst_bbox):
42
+ score = lst_score[idx]
43
+ cv2.rectangle(
44
+ image,
45
+ (image_bbox[0], image_bbox[1]),
46
+ (image_bbox[0] + image_bbox[2], image_bbox[1] + image_bbox[3]),
47
+ (0, int(255 * score), 0), 2)
48
+
49
+ cv2.putText(
50
+ image,
51
+ str(score)[:4],
52
+ (image_bbox[0], image_bbox[1] - 5),
53
+ cv2.FONT_HERSHEY_SIMPLEX, 1.5 * image.shape[0] / 1024, (0, int(255 * score), 0), 2)
54
+
55
+
56
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
57
+ return image
58
+
59
+
60
+
61
+ title = "Face Keypoint 3d"
62
+ description = "demo for Face Keypoint 3d. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
63
+ article = "<p style='text-align: center'><a href='https://www.yuque.com/itmorn/ability/face_keypoint_3d' target='_blank'>Project Documents</a> | <a href='https://www.bilibili.com/video/BV1GD4y1y77z' target='_blank'>Video Demo</a></p>"
64
+
65
+ gr.Interface(
66
+ inference,
67
+ [gr.inputs.Image(label="Input")],
68
+ gr.outputs.Image(type="pil", label="Output"),
69
+ title=title,
70
+ description=description,
71
+ article=article,
72
+ examples=[
73
+ ["imgs/11.jpg"],
74
+ ["imgs/13.jpg"],
75
+ ]).launch(debug=True)
core.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:722b367e4ceb510545a47b2e514093fc04a82c4d8df0f535c417c1ddfa420a46
3
+ size 25802730
imgs/11.jpg ADDED
imgs/13.jpg ADDED
mic.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d6d4f42c2272406ddb5c278a8548269437f61022e4bacc709cbbccc758a37085
3
+ size 1510312
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pyarmor
2
+ opencv-python
3
+ onnxruntime-gpu
4
+ onnx
5
+ py7zr
6
+ onnx
7
+ tqdm
8
+ scikit-image
9
+ fs
10
+ flask
11
+ torch
z_app_factory.so ADDED
Binary file (664 kB). View file