"examples/vscode:/vscode.git/clone" did not exist on "e645d936bf77e943c7b2d18b1d94ba79beb4a67d"
Commit eb587882 authored by liuhy's avatar liuhy
Browse files

添加注释

parent 69466de5
File added
......@@ -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
......
......@@ -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)
......@@ -8,3 +8,9 @@
对于车牌检测,也可以使用图像分割的思想,例如使用UNet语义分割网络,分割出车牌,
二值化然后查找连通域,计算4个顶点
导出onnx模型:
python test.py --export_onnx true
推理onnx模型:
python LPRNet_ORT_infer.py
......@@ -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.imgpath)
img = cv2.imread(args.img)
height, width, _ = img.shape
if height != 24 or width != 94:
img = cv2.resize(img, (94, 24))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment