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
cdadb5ce
Commit
cdadb5ce
authored
Mar 01, 2023
by
liuhy
Browse files
编写readme
parent
8cdde046
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
15 deletions
+35
-15
LPRNet_ORT_infer.py
LPRNet_ORT_infer.py
+8
-0
LPRNet_migraphx_infer.py
LPRNet_migraphx_infer.py
+12
-4
README.md
README.md
+3
-3
__pycache__/lprnet.cpython-37.pyc
__pycache__/lprnet.cpython-37.pyc
+0
-0
model/LPRNet.mxr
model/LPRNet.mxr
+0
-0
test.py
test.py
+12
-8
No files found.
LPRNet_ORT_infer.py
View file @
cdadb5ce
...
@@ -3,6 +3,7 @@ import cv2
...
@@ -3,6 +3,7 @@ import cv2
import
numpy
as
np
import
numpy
as
np
import
argparse
import
argparse
import
os
import
os
import
time
print
(
'Runing Based On:'
,
ort
.
get_device
())
print
(
'Runing Based On:'
,
ort
.
get_device
())
...
@@ -50,12 +51,19 @@ def LPRNetInference(args):
...
@@ -50,12 +51,19 @@ def LPRNetInference(args):
if
os
.
path
.
isdir
(
args
.
imgpath
):
if
os
.
path
.
isdir
(
args
.
imgpath
):
images
=
os
.
listdir
(
args
.
imgpath
)
images
=
os
.
listdir
(
args
.
imgpath
)
count
=
0
time1
=
time
.
perf_counter
()
for
image
in
images
:
for
image
in
images
:
img
=
LPRNetPreprocess
(
os
.
path
.
join
(
args
.
imgpath
,
image
))
img
=
LPRNetPreprocess
(
os
.
path
.
join
(
args
.
imgpath
,
image
))
intput
=
sess
.
get_inputs
()[
0
].
shape
intput
=
sess
.
get_inputs
()[
0
].
shape
preb
=
sess
.
run
(
None
,
input_feed
=
{
sess
.
get_inputs
()[
0
].
name
:
img
})[
0
]
preb
=
sess
.
run
(
None
,
input_feed
=
{
sess
.
get_inputs
()[
0
].
name
:
img
})[
0
]
result
=
LPRNetPostprocess
(
preb
)
result
=
LPRNetPostprocess
(
preb
)
if
result
==
image
[:
-
4
]:
count
+=
1
print
(
'Inference Result:'
,
result
)
print
(
'Inference Result:'
,
result
)
time2
=
time
.
perf_counter
()
print
(
'accuracy rate:'
,
count
/
len
(
images
))
print
(
'average time'
,
(
time2
-
time1
)
/
count
*
1000
)
else
:
else
:
img
=
LPRNetPreprocess
(
args
.
imgpath
)
img
=
LPRNetPreprocess
(
args
.
imgpath
)
intput
=
sess
.
get_inputs
()[
0
].
shape
intput
=
sess
.
get_inputs
()[
0
].
shape
...
...
LPRNet_migraphx_infer.py
View file @
cdadb5ce
...
@@ -7,6 +7,7 @@ import numpy as np
...
@@ -7,6 +7,7 @@ import numpy as np
import
migraphx
import
migraphx
import
argparse
import
argparse
import
os
import
os
import
time
CHARS
=
[
'京'
,
'沪'
,
'津'
,
'渝'
,
'冀'
,
'晋'
,
'蒙'
,
'辽'
,
'吉'
,
'黑'
,
CHARS
=
[
'京'
,
'沪'
,
'津'
,
'渝'
,
'冀'
,
'晋'
,
'蒙'
,
'辽'
,
'吉'
,
'黑'
,
'苏'
,
'浙'
,
'皖'
,
'闽'
,
'赣'
,
'鲁'
,
'豫'
,
'鄂'
,
'湘'
,
'粤'
,
'苏'
,
'浙'
,
'皖'
,
'闽'
,
'赣'
,
'鲁'
,
'豫'
,
'鄂'
,
'湘'
,
'粤'
,
...
@@ -56,14 +57,21 @@ def LPRNetInference(args):
...
@@ -56,14 +57,21 @@ def LPRNetInference(args):
if
os
.
path
.
isdir
(
args
.
imgpath
):
if
os
.
path
.
isdir
(
args
.
imgpath
):
images
=
os
.
listdir
(
args
.
imgpath
)
images
=
os
.
listdir
(
args
.
imgpath
)
count
=
0
time1
=
time
.
perf_counter
()
for
image
in
images
:
for
image
in
images
:
img
=
LPRNetPreprocess
(
os
.
path
.
join
(
args
.
imgpath
,
image
))
img
=
LPRNetPreprocess
(
os
.
path
.
join
(
args
.
imgpath
,
image
))
inputName
=
model
.
get_parameter_names
()[
0
]
inputName
=
model
.
get_parameter_names
()[
0
]
inputShape
=
model
.
get_parameter_shapes
()[
inputName
].
lens
()
inputShape
=
model
.
get_parameter_shapes
()[
inputName
].
lens
()
# print("inputName:{0} \ninputShape:{1}".format(inputName,inputShape))
# print("inputName:{0} \ninputShape:{1}".format(inputName,inputShape))
results
=
model
.
run
({
inputName
:
migraphx
.
argument
(
img
)})
results
=
model
.
run
({
inputName
:
migraphx
.
argument
(
img
)})
result
=
LPRNetPostprocess
(
np
.
array
(
results
[
0
]))
result
=
LPRNetPostprocess
(
np
.
array
(
results
[
0
]))
if
result
==
image
[:
-
4
]:
count
+=
1
print
(
'Inference Result:'
,
result
)
print
(
'Inference Result:'
,
result
)
time2
=
time
.
perf_counter
()
print
(
'accuracy rate:'
,
count
/
len
(
images
))
print
(
'average time'
,
(
time2
-
time1
)
/
count
*
1000
)
else
:
else
:
img
=
LPRNetPreprocess
(
args
.
imgpath
)
img
=
LPRNetPreprocess
(
args
.
imgpath
)
inputName
=
model
.
get_parameter_names
()[
0
]
inputName
=
model
.
get_parameter_names
()[
0
]
...
@@ -75,8 +83,8 @@ def LPRNetInference(args):
...
@@ -75,8 +83,8 @@ def LPRNetInference(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'parameters to vaildate net'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'parameters to vaildate net'
)
parser
.
add_argument
(
'--model'
,
default
=
'model/LPRNet.
mxr
'
,
help
=
'model path to inference'
)
parser
.
add_argument
(
'--model'
,
default
=
'model/LPRNet.
onnx
'
,
help
=
'model path to inference'
)
parser
.
add_argument
(
'--imgpath'
,
default
=
'imgs/
川JK070
7.jpg'
,
help
=
'the image path'
)
parser
.
add_argument
(
'--imgpath'
,
default
=
'imgs/
京PL3N6
7.jpg'
,
help
=
'the image path'
)
parser
.
add_argument
(
'--savepath'
,
default
=
'model/LPRNet.mxr'
,
help
=
'mxr model save path and name'
)
parser
.
add_argument
(
'--savepath'
,
default
=
'model/LPRNet.mxr'
,
help
=
'mxr model save path and name'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
...
README.md
View file @
cdadb5ce
...
@@ -42,9 +42,9 @@ LPRNet_migraphx_infer.py是基于Migraphx的推理脚本,使用需安装好Mig
...
@@ -42,9 +42,9 @@ LPRNet_migraphx_infer.py是基于Migraphx的推理脚本,使用需安装好Mig
## 性能和准确率数据
## 性能和准确率数据
测试数据使用的是
[
LPRNet_Pytorch
](
https://github.com/sirius-ai/LPRNet_Pytorch/tree/master/data/test
)
测试数据使用的是
[
LPRNet_Pytorch
](
https://github.com/sirius-ai/LPRNet_Pytorch/tree/master/data/test
)
| size | personal test imgs(%) | DCU
|
| size | personal test imgs(%) | DCU
(pth/ms) |DCU(onnx/ms) | DCU(mxr/ms)
|
| :------: | :------: | :------: |
| :------: | :------: | :------: |
:------: |:------: |
| 1.7M | 96.0+ | |
| 1.7M | 96.0+ |
52 | 51 |
|
## 参考
## 参考
*
[
LPRNet: License Plate Recognition via Deep Neural Networks
](
https://arxiv.org/pdf/1806.10447v1.pdf
)
*
[
LPRNet: License Plate Recognition via Deep Neural Networks
](
https://arxiv.org/pdf/1806.10447v1.pdf
)
*
[
LPRNet_Pytorch
](
https://github.com/sirius-ai/LPRNet_Pytorch
)
*
[
LPRNet_Pytorch
](
https://github.com/sirius-ai/LPRNet_Pytorch
)
...
...
__pycache__/lprnet.cpython-37.pyc
View file @
cdadb5ce
No preview for this file type
model/LPRNet.mxr
View file @
cdadb5ce
No preview for this file type
test.py
View file @
cdadb5ce
...
@@ -5,6 +5,7 @@ import torch
...
@@ -5,6 +5,7 @@ import torch
import
numpy
as
np
import
numpy
as
np
from
lprnet
import
build_lprnet
from
lprnet
import
build_lprnet
from
load_data
import
CHARS
from
load_data
import
CHARS
import
time
def
infer
(
args
,
image
,
model
):
def
infer
(
args
,
image
,
model
):
img
=
cv2
.
imread
(
image
)
img
=
cv2
.
imread
(
image
)
...
@@ -44,15 +45,18 @@ def validation(args):
...
@@ -44,15 +45,18 @@ def validation(args):
if
os
.
path
.
isdir
(
args
.
imgpath
):
if
os
.
path
.
isdir
(
args
.
imgpath
):
images
=
os
.
listdir
(
args
.
imgpath
)
images
=
os
.
listdir
(
args
.
imgpath
)
count
=
0
count
=
0
time1
=
time
.
perf_counter
()
for
image
in
images
:
for
image
in
images
:
res
=
infer
(
args
,
os
.
path
.
join
(
args
.
imgpath
,
image
),
model
)
res
ult
=
infer
(
args
,
os
.
path
.
join
(
args
.
imgpath
,
image
),
model
)
if
res
==
image
[:
-
4
]:
if
res
ult
==
image
[:
-
4
]:
count
+=
1
count
+=
1
print
(
'Image: '
+
image
+
' recongise result: '
+
res
)
print
(
'Image: '
+
image
+
' recongise result: '
+
result
)
print
(
'acc rate:'
,
count
/
len
(
images
))
time2
=
time
.
perf_counter
()
print
(
'accuracy rate:'
,
count
/
len
(
images
))
print
(
'average time'
,
(
time2
-
time1
)
/
count
*
1000
)
else
:
else
:
res
=
infer
(
args
,
args
.
imgpath
,
model
)
res
ult
=
infer
(
args
,
args
.
imgpath
,
model
)
print
(
'Image: '
+
args
.
imgpath
+
' recongise result: '
+
res
)
print
(
'Image: '
+
args
.
imgpath
+
' recongise result: '
+
res
ult
)
if
args
.
export_onnx
:
if
args
.
export_onnx
:
print
(
'export pytroch model to onnx model...'
)
print
(
'export pytroch model to onnx model...'
)
...
@@ -71,8 +75,8 @@ def validation(args):
...
@@ -71,8 +75,8 @@ def validation(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'parameters to vaildate net'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'parameters to vaildate net'
)
#
parser.add_argument('--model', default='model/lprnet.pth', help='model path to vaildate')
parser
.
add_argument
(
'--model'
,
default
=
'model/lprnet.pth'
,
help
=
'model path to vaildate'
)
parser
.
add_argument
(
'--model'
,
default
=
'weights/Final_LPRNet_model.pth'
,
help
=
'model path to vaildate'
)
#
parser.add_argument('--model', default='weights/Final_LPRNet_model.pth', help='model path to vaildate')
# parser.add_argument('--imgpath', default='imgs/川JK0707.jpg', help='the image path')
# parser.add_argument('--imgpath', default='imgs/川JK0707.jpg', help='the image path')
parser
.
add_argument
(
'--imgpath'
,
default
=
'/code/lpr_ori/data/test'
,
help
=
'the image path'
)
parser
.
add_argument
(
'--imgpath'
,
default
=
'/code/lpr_ori/data/test'
,
help
=
'the image path'
)
parser
.
add_argument
(
'--device'
,
default
=
'cuda'
,
help
=
'Use cuda to vaildate model'
)
parser
.
add_argument
(
'--device'
,
default
=
'cuda'
,
help
=
'Use cuda to vaildate model'
)
...
...
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