add road model

This commit is contained in:
thsw 2022-09-20 16:37:37 +08:00
parent a67ee03dcf
commit 74261cf8b9
6 changed files with 19 additions and 8 deletions

24
demo.py
View File

@ -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' )

BIN
images/road/c1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 KiB

BIN
images/road/c2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 KiB

BIN
images/road/c3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 KiB

BIN
images/road/c4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 KiB

View File

@ -6,3 +6,6 @@
配合AIlib2.0版本
1.修改河道测试代码,注意使用了新的模型
2.验证模型效果的图像在images/slope,images/sky
2022.09.20
增加道路模型测试图像在test/images/road