diff --git a/demo.py b/demo.py index 23d6b68..b057f38 100644 --- a/demo.py +++ b/demo.py @@ -73,13 +73,21 @@ def river_demo(): cv2.imwrite( os.path.join( outpth,folders[i] ) ,image_array ) print('----AIprocess:%s, %.1f, %s'%(folders[i], (time11 - time00) * 1000,timeOut)) -def forest_demo(): + +def road_forest_demo(business ): + + ##使用森林,道路模型,business 控制['forest','road'] ##预先设置的参数 device_='1' ##选定模型,可选 cpu,'0','1' + + ##以下参数目前不可改 - Detweights = "../AIlib/weights/forest/best.pt" - labelnames = "../AIlib/weights/forest/labelnames.json" + #business='forest';imageW=4916 ####森林模型 + #business='road'; + imageW=1536 ####道路模型 + Detweights = "../AIlib/weights/%s/best.pt"%(business) + labelnames = "../AIlib/weights/%s/labelnames.json"%(business) postFile= '../AIlib/conf/para.json' conf_thres,iou_thres,classes,rainbows=get_postProcess_para(postFile) @@ -110,7 +118,7 @@ def forest_demo(): ##只加载检测模型,准备好显示字符 device = select_device(device_) names=get_labelnames(labelnames) - imageW=4915;###默认是1920,在森林巡检的高清图像中是4920 + #imageW=4915;###默认是1920,在森林巡检的高清图像中是4920 outfontsize=int(imageW/1920*40);### label_arraylist = get_label_arrays(names,rainbows,outfontsize=outfontsize,fontpath="../AIlib/conf/platech.ttf") half = device.type != 'cpu' # half precision only supported on CUDA @@ -122,7 +130,7 @@ def forest_demo(): ##图像测试 #url='images/examples/20220624_响水河_12300_1621.jpg' - impth = 'images/forest/' + impth = 'images/%s/'%(business) outpth = 'images/results/' folders = os.listdir(impth) for i in range(len(folders)): @@ -139,10 +147,10 @@ def forest_demo(): print('----image:%s, process:%s ,save:%s, %s'%(folders[i],(time11-time00) * 1000, (time.time() - time11) * 1000,timeOut) ) - + if __name__=="__main__": - river_demo() - #forest_demo() + #river_demo() + road_forest_demo('road' ) diff --git a/images/road/c1.jpg b/images/road/c1.jpg new file mode 100644 index 0000000..60e40d0 Binary files /dev/null and b/images/road/c1.jpg differ diff --git a/images/road/c2.jpg b/images/road/c2.jpg new file mode 100644 index 0000000..d6a0d6e Binary files /dev/null and b/images/road/c2.jpg differ diff --git a/images/road/c3.jpg b/images/road/c3.jpg new file mode 100644 index 0000000..7f7439e Binary files /dev/null and b/images/road/c3.jpg differ diff --git a/images/road/c4.jpg b/images/road/c4.jpg new file mode 100644 index 0000000..61009b8 Binary files /dev/null and b/images/road/c4.jpg differ diff --git a/readme.md b/readme.md index 332cfd3..0a64275 100644 --- a/readme.md +++ b/readme.md @@ -6,3 +6,6 @@ 配合AIlib2.0版本 1.修改河道测试代码,注意使用了新的模型 2.验证模型效果的图像在images/slope,images/sky + +2022.09.20 +增加道路模型,测试图像在test/images/road