Spaces:
Runtime error
Runtime error
init
Browse files- app.py +26 -14
- core.bin +2 -2
- 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 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 = "
|
| 41 |
-
description = "demo for
|
| 42 |
-
article = "<p style='text-align: center'><a href='https://www.yuque.com/itmorn/ability/
|
| 43 |
|
| 44 |
gr.Interface(
|
| 45 |
inference,
|
|
@@ -51,5 +63,5 @@ gr.Interface(
|
|
| 51 |
examples=[
|
| 52 |
["imgs/face1.jpg"],
|
| 53 |
["imgs/face2.jpg"],
|
| 54 |
-
["imgs/
|
| 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:
|
| 3 |
-
size
|
|
|
|
| 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
|
|
|