Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
LPRNet_pytorch
Commits
eb587882
"examples/vscode:/vscode.git/clone" did not exist on "e645d936bf77e943c7b2d18b1d94ba79beb4a67d"
Commit
eb587882
authored
Feb 27, 2023
by
liuhy
Browse files
添加注释
parent
69466de5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
4 deletions
+14
-4
LPRNet.onnx
LPRNet.onnx
+0
-0
LPRNet_ORT_infer.py
LPRNet_ORT_infer.py
+3
-0
LPRNet_migraphx_infer.py
LPRNet_migraphx_infer.py
+4
-3
README.md
README.md
+6
-0
test.py
test.py
+1
-1
No files found.
LPRNet.onnx
0 → 100644
View file @
eb587882
File added
LPRNet_ORT_infer.py
View file @
eb587882
...
...
@@ -27,7 +27,10 @@ def LPRNetPostprocess(infer_res):
for
j
in
range
(
infer_res
.
shape
[
1
]):
preb_label
.
append
(
np
.
argmax
(
infer_res
[:,
j
],
axis
=
0
))
no_repeat_blank_label
=
[]
print
(
preb_label
)
pre_c
=
preb_label
[
0
]
print
(
pre_c
)
if
pre_c
!=
len
(
CHARS
)
-
1
:
no_repeat_blank_label
.
append
(
pre_c
)
for
c
in
preb_label
:
# dropout repeate label and blank label
...
...
LPRNet_migraphx_infer.py
View file @
eb587882
...
...
@@ -52,7 +52,8 @@ def LPRNetInference(model_name, imgs):
model
=
migraphx
.
parse_onnx
(
model_name
)
# migraphx.quantize_fp16(model)
model
.
compile
(
t
=
migraphx
.
get_target
(
"gpu"
),
device_id
=
0
)
# device_id: 设置GPU设备,默认为0号设备(>=1.2版本中支持)
# migraphx.save(model, 'LPRNet.mxr')
path
=
model_name
.
split
(
'/'
)
migraphx
.
save
(
model
,
'/'
.
join
((
path
[:
-
1
],
path
[
-
1
][
-
4
]
+
'mxr'
)))
inputName
=
model
.
get_parameter_names
()[
0
]
inputShape
=
model
.
get_parameter_shapes
()[
inputName
].
lens
()
...
...
@@ -64,8 +65,8 @@ def LPRNetInference(model_name, imgs):
return
result
if
__name__
==
'__main__'
:
#
model_name = 'LPRNet.onnx'
model_name
=
'model/LPRNet.mxr'
model_name
=
'LPRNet.onnx'
#
model_name = 'model/LPRNet.mxr'
image
=
'imgs/川JK0707.jpg'
InferRes
=
LPRNetInference
(
model_name
,
image
)
print
(
image
,
'Inference Result:'
,
InferRes
)
README.md
View file @
eb587882
...
...
@@ -8,3 +8,9 @@
对于车牌检测,也可以使用图像分割的思想,例如使用UNet语义分割网络,分割出车牌,
二值化然后查找连通域,计算4个顶点
导出onnx模型:
python test.py --export_onnx true
推理onnx模型:
python LPRNet_ORT_infer.py
test.py
View file @
eb587882
...
...
@@ -11,7 +11,7 @@ def validation(args):
model
.
load_state_dict
(
torch
.
load
(
args
.
model
,
map_location
=
args
.
device
))
model
.
to
(
args
.
device
)
img
=
cv2
.
imread
(
args
.
img
path
)
img
=
cv2
.
imread
(
args
.
img
)
height
,
width
,
_
=
img
.
shape
if
height
!=
24
or
width
!=
94
:
img
=
cv2
.
resize
(
img
,
(
94
,
24
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment