itmorn commited on
Commit
0da0b1f
1 Parent(s): c2c3308
Files changed (6) hide show
  1. .gitignore +1 -0
  2. app.py +32 -14
  3. core.bin +2 -2
  4. imgs/2313.png +0 -0
  5. mic.bin +2 -2
  6. z_app_factory.so +0 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ /.idea
app.py CHANGED
@@ -3,32 +3,49 @@ 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
- annotated_image = image.copy()
9
- lst2d_res = get_app(image)
10
- thickness = 3
11
- lineType = 8
12
- font = cv2.FONT_HERSHEY_SIMPLEX
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  for face in lst2d_res:
 
15
  bbox = [int(i) for i in face["bbox"]]
16
  score = face['score']
17
  point_color = (0, int(255 * score), 0) # BGR
18
  x1, y1 = bbox[:2]
19
  x2, y2 = bbox[2:]
20
- cv2.putText(annotated_image, str(score)[:4], (x1, y1 - 10), font, 0.8, (0, 255, 0), 2)
21
- cv2.line(annotated_image, (x1, y1), (x2, y1), point_color, thickness, lineType)
22
- cv2.line(annotated_image, (x2, y1), (x2, y2), point_color, thickness, lineType)
23
- cv2.line(annotated_image, (x1, y1), (x1, y2), point_color, thickness, lineType)
24
- cv2.line(annotated_image, (x1, y2), (x2, y2), point_color, thickness, lineType)
25
 
26
  for kp in face["kps"]:
27
  x, y = [int(i) for i in kp]
28
- cv2.circle(annotated_image, (x, y), 2, (2, 30, 200), 2)
29
 
30
- annotated_image = cv2.cvtColor(annotated_image, cv2.COLOR_RGB2BGR)
31
- return annotated_image
32
 
33
 
34
 
@@ -46,5 +63,6 @@ gr.Interface(
46
  examples=[
47
  ["imgs/face1.jpg"],
48
  ["imgs/face2.jpg"],
49
- ["imgs/11.jpg"]
 
50
  ]).launch(debug=True)
 
3
  from z_app_factory import get_app
4
 
5
 
6
+ thickness = 3
7
+ lineType = 8
8
+ font = cv2.FONT_HERSHEY_SIMPLEX
9
+
10
  def inference(image):
11
  image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
12
+ code,lst2d_res = get_app(image)
13
+ msg = "aaa"
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 greater than 5MB"
22
+ elif code == 405:
23
+ msg = "System error, please contact\n the server for troubleshooting"
24
+
25
+ if code!=200:
26
+ img_out = np.zeros((500, 600,3),dtype=np.uint8)
27
+ cv2.putText(img_out, msg, (20, 200), font, 1, (0, 255, 0), 2)
28
+ return img_out
29
 
30
  for face in lst2d_res:
31
+
32
  bbox = [int(i) for i in face["bbox"]]
33
  score = face['score']
34
  point_color = (0, int(255 * score), 0) # BGR
35
  x1, y1 = bbox[:2]
36
  x2, y2 = bbox[2:]
37
+ cv2.putText(image, str(score)[:4], (x1, y1 - 10), font, 0.8, (0, 255, 0), 2)
38
+ cv2.line(image, (x1, y1), (x2, y1), point_color, thickness, lineType)
39
+ cv2.line(image, (x2, y1), (x2, y2), point_color, thickness, lineType)
40
+ cv2.line(image, (x1, y1), (x1, y2), point_color, thickness, lineType)
41
+ cv2.line(image, (x1, y2), (x2, y2), point_color, thickness, lineType)
42
 
43
  for kp in face["kps"]:
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
 
 
63
  examples=[
64
  ["imgs/face1.jpg"],
65
  ["imgs/face2.jpg"],
66
+ ["imgs/cc.png"],
67
+ ["imgs/2313.png"]
68
  ]).launch(debug=True)
core.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1e8f1ea11748c0e7ee3b9e3f127348017f22fc576c4558e8ce4a6ec5bd315fe6
3
- size 16334604
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f02f1f3a3063a53802bd427234db4eed6dbc600e1e5dba59a9eb064401c40fc7
3
+ size 20928518
imgs/2313.png ADDED
mic.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ebc1ac4d0f2363419842427822b3ab81e3ba3d8eaf6da7a61800c3cbbc084991
3
- size 1367712
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c5c351ce535def9746f385c8d7cf48e2d332ab4de71a0bbdbb40d0f82129524
3
+ size 1926896
z_app_factory.so CHANGED
Binary files a/z_app_factory.so and b/z_app_factory.so differ