add detection of plate and jkm

This commit is contained in:
wangjin0928 2022-11-21 10:55:37 +08:00
parent 2b1cced68a
commit 43809bebcb
7 changed files with 40 additions and 4 deletions

39
demo.py
View File

@ -151,10 +151,43 @@ def road_forest_demo(business ):
print('----image:%s, process:%s ,save:%s, %s'%(folders[i],(time11-time00) * 1000, (time.time() - time11) * 1000,timeOut) )
def jkm_demo():
from utilsK.jkmUtils import pre_process,post_process,get_return_data
img_type = 'plate' ## code,plate
par={'code':{'weights':'../AIlib/weights/jkm/health_yolov5s_v3.jit','img_type':'code','nc':10 },
'plate':{'weights':'../AIlib/weights/jkm/plate_yolov5s_v3.jit','img_type':'plate','nc':1 },
'conf_thres': 0.4,
'iou_thres':0.45,
'device':'cuda:0',
'plate_dilate':(0.5,0.1)
}
###加载模型
device = torch.device(par['device'])
jit_weights = par['code']['weights']
model = torch.jit.load(jit_weights)
jit_weights = par['plate']['weights']
model_plate = torch.jit.load(jit_weights)
imgd='images/plate'
imgpaths = os.listdir(imgd)
for imgp in imgpaths[0:]:
#imgp = 'plate_IMG_20221030_100612.jpg'
imgpath = os.path.join(imgd,imgp)
im0 = cv2.imread(imgpath) #读取数据
img ,padInfos = pre_process(im0,device) ##预处理
if img_type=='code': pred = model(img) ##模型推理
else: pred = model_plate(img)
boxes = post_process(pred,padInfos,device,conf_thres= par['conf_thres'], iou_thres= par['iou_thres'],nc=par[img_type]['nc']) #后处理
dataBack=get_return_data(im0,boxes,modelType=img_type,plate_dilate=par['plate_dilate'])
print(imgp,boxes,dataBack['type'])
for key in dataBack.keys():
if isinstance(dataBack[key],list):
cv2.imwrite( 'images/results/%s_%s.jpg'%( imgp.replace('.jpg','').replace('.png',''),key),dataBack[key][0] ) ###返回值: dataBack
if __name__=="__main__":
river_demo()
#river_demo()
#road_forest_demo('forest' )
jkm_demo()

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

@ -8,4 +8,7 @@
2.验证模型效果的图像在images/slope,images/sky
2022.09.20
增加道路模型测试图像在test/images/road
增加道路模型测试图像在test/images/road
2022.11.21
增加健康码健康吗、行程卡检测、车牌检测测试图像在test/images/jkm、test/images/plate