Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
affective_computing
/
face_mask_classifier
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d77ae4ab
authored
2022-02-10 18:35:29 +0800
by
乔峰昇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
'update-mnn'
1 parent
801e5009
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
cls_abnormal_face_mnn_1.0.0_v0.0.1.mnn
infer_mnn.py
cls_abnormal_face_mnn_1.0.0_v0.0.1.mnn
View file @
d77ae4a
No preview for this file type
infer_mnn.py
View file @
d77ae4a
...
...
@@ -3,9 +3,10 @@ import numpy as np
import
MNN
import
os
def
image_infer_mnn
(
mnn_model_path
,
image_path
,
class_list
):
image
=
cv2
.
imread
(
image_path
)
input_image
=
cv2
.
resize
(
image
,
(
128
,
128
))
input_image
=
cv2
.
resize
(
image
,
(
128
,
128
))
input_data
=
input_image
.
astype
(
np
.
float32
)
.
transpose
((
2
,
0
,
1
))
/
255
interpreter
=
MNN
.
Interpreter
(
mnn_model_path
)
session
=
interpreter
.
createSession
()
...
...
@@ -17,7 +18,7 @@ def image_infer_mnn(mnn_model_path, image_path, class_list):
output_data
=
infer_result
.
getData
()
out
=
output_data
.
index
(
max
(
output_data
))
cv2
.
putText
(
image
,
class_list
[
int
(
out
)],(
50
,
50
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
2
,(
0
,
0
,
255
))
cv2
.
putText
(
image
,
class_list
[
int
(
out
)],
(
50
,
50
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
2
,
(
0
,
0
,
255
))
return
image
...
...
@@ -74,10 +75,10 @@ if __name__ == '__main__':
image_path
=
'test_image/mask_2997.jpg'
mnn_model_path
=
'cls_abnormal_face_mnn_1.0.0_v0.0.1.mnn'
# image
#
for i in os.listdir('test_image'):
#
image=image_infer_mnn(mnn_model_path,os.path.join('test_image',i),class_list)
#
cv2.imshow('image',image)
#
cv2.waitKey(0)
for
i
in
os
.
listdir
(
'test_image'
):
image
=
image_infer_mnn
(
mnn_model_path
,
os
.
path
.
join
(
'test_image'
,
i
),
class_list
)
cv2
.
imshow
(
'image'
,
image
)
cv2
.
waitKey
(
0
)
# camera
camera_infer_mnn
(
mnn_model_path
,
0
)
#
camera_infer_mnn(mnn_model_path, 0)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment