diff --git a/demo.py b/demo.py index ff935cb..29aadb1 100644 --- a/demo.py +++ b/demo.py @@ -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() diff --git a/images/jkm/jkm_20221115145501_1115.jpg b/images/jkm/jkm_20221115145501_1115.jpg new file mode 100644 index 0000000..d5cdebc Binary files /dev/null and b/images/jkm/jkm_20221115145501_1115.jpg differ diff --git a/images/jkm/xck_zbsb69v1mgb_1667266690674.png b/images/jkm/xck_zbsb69v1mgb_1667266690674.png new file mode 100644 index 0000000..885bc24 Binary files /dev/null and b/images/jkm/xck_zbsb69v1mgb_1667266690674.png differ diff --git a/images/plate/plate_1668493089006.jpg b/images/plate/plate_1668493089006.jpg new file mode 100644 index 0000000..2cbaaf9 Binary files /dev/null and b/images/plate/plate_1668493089006.jpg differ diff --git a/images/plate/plate_20221108143302_A236.jpg b/images/plate/plate_20221108143302_A236.jpg new file mode 100644 index 0000000..08ea4ce Binary files /dev/null and b/images/plate/plate_20221108143302_A236.jpg differ diff --git a/images/plate/plate_IMG_20221030_100612.jpg b/images/plate/plate_IMG_20221030_100612.jpg new file mode 100644 index 0000000..53f52ba Binary files /dev/null and b/images/plate/plate_IMG_20221030_100612.jpg differ diff --git a/readme.md b/readme.md index 0a64275..aca6243 100644 --- a/readme.md +++ b/readme.md @@ -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