Spaces:
Runtime error
Runtime error
init
Browse files- README.md +1 -1
- app.py +55 -0
- core.bin +3 -0
- imgs/cc.png +0 -0
- imgs/face1.jpg +0 -0
- imgs/face2.jpg +0 -0
- mic.bin +3 -0
- requirements.txt +10 -0
- z_app_factory.so +0 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Face Keypoint
|
3 |
-
emoji:
|
4 |
colorFrom: yellow
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
title: Face Keypoint
|
3 |
+
emoji: π
|
4 |
colorFrom: yellow
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"]]
|
15 |
+
score = face['score']
|
16 |
+
point_color = (0, int(255 * score), 0) # BGR
|
17 |
+
x1, y1 = bbox[:2]
|
18 |
+
x2, y2 = bbox[2:]
|
19 |
+
cv2.putText(image, str(score)[:4], (x1, y1 - 10), font, 0.8, (0, 255, 0), 2)
|
20 |
+
cv2.line(image, (x1, y1), (x2, y1), point_color, thickness, lineType)
|
21 |
+
cv2.line(image, (x2, y1), (x2, y2), point_color, thickness, lineType)
|
22 |
+
cv2.line(image, (x1, y1), (x1, y2), point_color, thickness, lineType)
|
23 |
+
cv2.line(image, (x1, y2), (x2, y2), point_color, thickness, lineType)
|
24 |
+
|
25 |
+
for kp in face["kps"]:
|
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), 2, (200, 200, 20), 2)
|
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,
|
46 |
+
[gr.inputs.Image(label="Input")],
|
47 |
+
gr.outputs.Image(type="pil", label="Output"),
|
48 |
+
title=title,
|
49 |
+
description=description,
|
50 |
+
article=article,
|
51 |
+
examples=[
|
52 |
+
["imgs/face1.jpg"],
|
53 |
+
["imgs/face2.jpg"],
|
54 |
+
["imgs/cc.png"]
|
55 |
+
]).launch(debug=True)
|
core.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b4f9c0d0bd999c0894a3c29476d56eae977460c6c0f63e515c4d1cc991b1bbbd
|
3 |
+
size 20958222
|
imgs/cc.png
ADDED
imgs/face1.jpg
ADDED
imgs/face2.jpg
ADDED
mic.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f10843e7373c4f7b8d20b957cd058a1ea66152271fbf9496325407e1fc0c1a80
|
3 |
+
size 1854560
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pyarmor
|
2 |
+
opencv-python
|
3 |
+
onnxruntime-gpu
|
4 |
+
onnx
|
5 |
+
py7zr
|
6 |
+
onnx
|
7 |
+
tqdm
|
8 |
+
scikit-image
|
9 |
+
fs
|
10 |
+
flask
|
z_app_factory.so
ADDED
Binary file (618 kB). View file
|
|