Spaces:
Build error
Build error
init
Browse files- README.md +1 -1
- app.py +49 -0
- core.bin +3 -0
- mic.bin +3 -0
- z_app_factory.so +0 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Detect Face
|
3 |
-
emoji:
|
4 |
colorFrom: green
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
title: Detect Face
|
3 |
+
emoji: π
|
4 |
colorFrom: green
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
30 |
+
return image
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
title = "Detect Face"
|
35 |
+
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."
|
36 |
+
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>"
|
37 |
+
|
38 |
+
gr.Interface(
|
39 |
+
inference,
|
40 |
+
[gr.inputs.Image(label="Input")],
|
41 |
+
gr.outputs.Image(type="pil", label="Output"),
|
42 |
+
title=title,
|
43 |
+
description=description,
|
44 |
+
article=article,
|
45 |
+
examples=[
|
46 |
+
["imgs/face1.jpg"],
|
47 |
+
["imgs/face2.jpg"],
|
48 |
+
["imgs/11.jpg"]
|
49 |
+
]).launch(debug=True)
|
core.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1281f04ab4f02355c8bb2592518091130ae81f85c27ef068b5e2ddd9f07b43da
|
3 |
+
size 16336999
|
mic.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ebc1ac4d0f2363419842427822b3ab81e3ba3d8eaf6da7a61800c3cbbc084991
|
3 |
+
size 1367712
|
z_app_factory.so
ADDED
Binary file (632 kB). View file
|
|