瀏覽代碼

change parameters

master
wangjin0928 1 年之前
父節點
當前提交
ae7f97481a
共有 24 個檔案被更改,包括 470 行新增383 行删除
  1. +99
    -15
      demo.py
  2. +368
    -361
      demo3.0.py
  3. 二進制
      images/cityMangement3/XJRW20231008132531_093.jpg
  4. 二進制
      images/cityMangement3/XJRW20231009084538_166.jpg
  5. 二進制
      images/results/2023-09-19-09-46-46_frame-18507-18787_type_20230919094646113613-2-0-0_OR.jpg
  6. 二進制
      images/results/DJI_0974_15.jpg
  7. +0
    -3
      images/results/DJI_0974_15.txt
  8. 二進制
      images/results/DJI_0974_15_mask.png
  9. 二進制
      images/results/DJI_0988_20.jpg
  10. +0
    -4
      images/results/DJI_0988_20.txt
  11. 二進制
      images/results/DJI_0988_20_mask.png
  12. 二進制
      images/results/DJI_0996_104.jpg
  13. 二進制
      images/results/DJI_20230626104206_0011_S_7.jpg
  14. +0
    -0
      images/results/DJI_20230626104206_0011_S_7.txt
  15. 二進制
      images/results/DJI_20230626104206_0011_S_7_mask.png
  16. 二進制
      images/results/t1.jpg
  17. 二進制
      images/results/t2.jpg
  18. 二進制
      images/results/t3.jpg
  19. 二進制
      images/results/t4.jpg
  20. 二進制
      images/results/w1.jpg
  21. 二進制
      images/results/w2.jpg
  22. 二進制
      images/results/w3.jpg
  23. 二進制
      images/results/w4.jpg
  24. +3
    -0
      readme.md

+ 99
- 15
demo.py 查看文件

@@ -4,8 +4,9 @@ from concurrent.futures import ThreadPoolExecutor
sys.path.extend(['..','../AIlib2' ])
from AI import AI_process,AI_process_forest,get_postProcess_para,get_postProcess_para_dic,ocr_process,AI_det_track,AI_det_track_batch
from AI import AI_process,AI_process_forest,get_postProcess_para,get_postProcess_para_dic,ocr_process,AI_det_track,AI_det_track_batch,get_images_videos,AI_process_N
from stdc import stdcModel
from yolov5 import yolov5Model
import cv2,os,time
from segutils.segmodel import SegModel
@@ -61,7 +62,6 @@ def process_v1(frame):
#p_result[1] = draw_painting_joint(xyxy,p_result[1],label_arraylist[int(cls)],score=conf,color=rainbows[int(cls)%20],font=font,socre_location="leftBottom")
p_result,timeOut = AI_process(frame[0],frame[1],frame[2],frame[3],frame[4],frame[5],objectPar=frame[6],font=frame[7],segPar=frame[9],mode=frame[10],postPar=frame[11])
#print('##'*20,'line64:',p_result[2])
p_result[1] = drawAllBox(p_result[2],p_result[1],frame[4],frame[5],frame[7])
time11 = time.time()
@@ -145,7 +145,6 @@ def detSeg_demo(opt):
'labelnames':"../AIlib2/weights/conf/river/labelnames.json", ###检测类别对照表
'max_workers':1, ###并行线程数
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'Detweights':"/mnt/thsw2/DSP2/weights/river/yolov5.pt",###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6,7,8,9] ],###控制哪些检测类别显示,输出
'seg_nclass':2,###分割模型类别数目,默认2类
'segRegionCnt':1,###分割模型结果需要保留的等值线数目
@@ -294,14 +293,13 @@ def detSeg_demo(opt):
if opt['business'] == 'cityMangement2':
from DMPR import DMPRModel
from DMPRUtils.jointUtil import dmpr_yolo
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'max_workers':1, ###并行线程数
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'Detweights':"../AIlib2/weights/conf/cityMangement2/yolov5.pt",###检测模型路径
#'Detweights':"/mnt/thsw2/DSP2/weights/cityMangement2/weights/urbanManagement/yolo/best.pt",
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'seg_nclass':4,###分割模型类别数目,默认2类
'segRegionCnt':2,###分割模型结果需要保留的等值线数目
@@ -311,26 +309,23 @@ def detSeg_demo(opt):
'pars':{'carCls':0 ,'illCls':3,'scaleRatio':0.5,'border':80}
}
},
#'Segweights' : '/mnt/thsw2/DSP2/weights/cityMangement2/weights/urbanManagement/DMPR/dp_detector_499.engine',###分割模型权重位置
'Segweights':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'Segweights':"../AIlib2/weights/conf/cityMangement2/dmpr.pth",###检测模型路径
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business'] ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
#'testImgPath':'/mnt/thsw2/DSP2/demoImages/illParking',###测试图像的位置
#'testImgPath':'/mnt/thsw2/DSP2/weights/cityMangement2_0916/images/input',
'testImgPath':'images/cityMangement2/',
'testOutPath':'images/results/',###输出测试图像位置
}
if par['Segweights']:
par['trtFlag_seg']=True if par['Segweights'].endswith('.engine') else False
else:
par['trtFlag_seg']=False
par['trtFlag_det']=True if par['Detweights'].endswith('.engine') else False
mode = par['mode'] if 'mode' in par.keys() else 'others'
@@ -445,7 +440,94 @@ def detSeg_demo(opt):
for video in videopaths:
process_video(video,par0)
print(' ')
def detSeg_demo2(opt):
rainbows=[ [0,0,255],[0,255,0],[255,0,0],[255,0,255],[255,255,0],[255,129,0],[255,0,127],[127,255,0],[0,255,127],[0,127,255],[127,0,255],[255,127,255],[255,255,127],[127,255,255],[0,255,255],[255,127,255],[127,255,255], [0,127,0],[0,0,127],[0,255,255]]
if opt['business'] == 'cityMangement3':
from DMPR import DMPRModel
from DMPRUtils.jointUtil import dmpr_yolo_stdc
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'max_workers':1, ###并行线程数
'postProcess':{
'function':dmpr_yolo_stdc,
'pars':{'carCls':0 ,'illCls':3,'scaleRatio':0.5,'border':80}
},
'models':[
{
#'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } }
},
{
#'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/dmpr.pth'%(opt['business'] ),
'par':{
'depth_factor':32,'NUM_FEATURE_MAP_CHANNEL':6,'dmpr_thresh':0.3, 'dmprimg_size':640,
'name':'dmpr'
},
'model':DMPRModel,
'name':'dmpr'
},
{
#'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/stdc_360X640.pth'%(opt['business'] ),
'par':{
'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,'seg_nclass':2},###分割模型预处理参数
'model':stdcModel,
'name':'stdc'
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'segRegionCnt':2,###分割模型结果需要保留的等值线数目
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business'] ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
#'testImgPath':'images/%s/'%(opt['business']),
'testImgPath':'/mnt/thsw2/DSP2/weights/cityMangement2_1102/images/debug',
'testOutPath':'images/results/',###输出测试图像位置
}
#第一步加载模型
modelList=[ modelPar['model'](weights=modelPar['weight'],par=modelPar['par']) for modelPar in par['models'] ]
print(' load moder over')
#准备画图字体
labelnames = par['labelnames'] ##对应类别表
names=get_labelnames(labelnames)
label_arraylist = get_label_arrays(names,rainbows,outfontsize=par['txtFontSize'],fontpath="../AIlib2/conf/platech.ttf")
#图像测试
imgpaths,videopaths = get_images_videos( par['testImgPath'])
#开始测试
for imgUrl in imgpaths:
img = cv2.imread(imgUrl);bname = os.path.basename(imgUrl)
ret,timeInfos = AI_process_N([img],modelList,par['postProcess'])
timeInfos=bname+':'+timeInfos
print(timeInfos )
if len(ret)>0:
img0 = drawAllBox(ret,img,label_arraylist,rainbows,par['digitFont'])
else: img0= img
cv2.imwrite(os.path.join('images/results/',bname ) ,img0)
def det_demo(business ):
####森林巡检的参数
@@ -1012,9 +1094,9 @@ def crowd_demo(opt):
if __name__=="__main__":
#jkm_demo()
businessAll=['river2','AnglerSwimmer', 'countryRoad','forest2', 'pedestrian' , 'smogfire' , 'vehicle','ship2',"highWay2","channelEmergency","cityMangement","drowning","noParking","illParking",'cityMangement2',"cityRoad","crowdCounting"]
businessAll=['river2','AnglerSwimmer', 'countryRoad','forest2', 'pedestrian' , 'smogfire' , 'vehicle','ship2',"highWay2","channelEmergency","cityMangement","drowning","noParking","illParking",'cityMangement2',"cityRoad","crowdCounting",'cityMangement3']
businessAll = ['crowdCounting']
businessAll = ['cityMangement3']
# forest 、 ocr2 、ocr_en 、 river 、 road 、 ship ,目前都没有在用
@@ -1022,7 +1104,9 @@ if __name__=="__main__":
print('-'*40,'beg to test ',busi,'-'*40)
opt={'gpu':'2080Ti','business':busi}
if opt['business'] in ['highWay2','river2','drowning','noParking','river',"illParking","cityMangement2"]:
detSeg_demo(opt)
detSeg_demo(opt)
elif opt['business'] in ['cityMangement3'] :
detSeg_demo2(opt)
elif opt['business'] in ['crowdCounting'] :
crowd_demo(opt)
elif opt['business'] in ['ship2']:

+ 368
- 361
demo3.0.py 查看文件

@@ -4,10 +4,10 @@ from concurrent.futures import ThreadPoolExecutor
sys.path.extend(['..','../AIlib2' ])
from AI import AI_process,AI_process_forest,get_postProcess_para,get_postProcess_para_dic,ocr_process,AI_det_track,AI_det_track_batch
from AI import AI_process,AI_process_forest,get_postProcess_para,get_postProcess_para_dic,ocr_process,AI_det_track,AI_det_track_batch,AI_det_track_batch_N,get_images_videos,default_mix
import cv2,os,time
from segutils.segmodel import SegModel
from yolov5 import yolov5Model
from stdc import stdcModel
from segutils.trafficUtils import tracfficAccidentMixFunction
from models.experimental import attempt_load
@@ -28,7 +28,16 @@ from scipy import interpolate
from utilsK.drownUtils import mixDrowing_water_postprocess
#import warnings
#warnings.filterwarnings("error")
rainbows=[ [0,0,255],[0,255,0],[255,0,0],[255,0,255],[255,255,0],[255,129,0],[255,0,127],[127,255,0],[0,255,127],[0,127,255],[127,0,255],[255,127,255],[255,255,127],[127,255,255],[0,255,255],[255,127,255],[127,255,255], [0,127,0],[0,0,127],[0,255,255]]
def get_drawPar(par):
labelnames = par['labelnames']
names=get_labelnames(labelnames)
mode_paras=par['detModelpara']
allowedList,allowedList_string=get_needed_objectsIndex(mode_paras)
outfontsize=int(1080/1920*40);###
label_arraylist = get_label_arrays(names,rainbows,outfontsize=par['txtFontSize'],fontpath="../AIlib2/conf/platech.ttf")
drawPar={'names':names,'label_arraylist':label_arraylist,'rainbows':rainbows,'font': par['digitFont'],'allowedList':allowedList}
return drawPar
def view_bar(num, total,time1,prefix='prefix'):
rate = num / total
time_n=time.time()
@@ -108,7 +117,8 @@ def process_video(video,par0,mode='detSeg'):
iframe_list.append(iframe )
if iframe%patch_cnt==0:
time_patch0 = time.time()
retResults,timeInfos = AI_det_track_batch(imgarray_list, iframe_list ,par0['modelPar'],par0['processPar'],par0['sort_tracker'] ,par0['trackPar'],segPar=par0['segPar'])
#retResults,timeInfos = AI_det_track_batch(imgarray_list, iframe_list ,par0['modelPar'],par0['processPar'],par0['sort_tracker'] ,par0['trackPar'],segPar=par0['segPar'])
retResults,timeInfos = AI_det_track_batch_N(imgarray_list, iframe_list ,par0['modelList'],par0['postProcess'],par0['sort_tracker'],par0['trackPar'])
#print('###line111:',retResults[2])
###需要保存成一个二维list,每一个list是一帧检测结果。
###track_det_result 内容格式:x1, y1, x2, y2, conf, cls,iframe,trackId
@@ -177,71 +187,78 @@ def process_video(video,par0,mode='detSeg'):
post_results.append(p_result)
vid_writer_AI.release();
def det_track_demo(business ):
'''
跟踪参数说明:
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100}
sort_max_age--跟踪链断裂时允许目标消失最大的次数。超过之后,会认为是新的目标。
sort_min_hits--每隔目标连续出现的次数,超过这个次数才认为是一个目标。
sort_iou_thresh--检测最小的置信度。
det_cnt--每隔几次做一个跟踪和检测,默认10。
windowsize--轨迹平滑长度,一定是奇数,表示每隔几帧做一平滑,默认29。
patchCnt--每次送入图像的数量,不宜少于100帧。
'''
''' 以下是基于检测和分割的跟踪模型,分割用来修正检测的结果'''
def det_track_demo_N(business ):
####河道巡检的跟踪模型参数
if opt['business'] == 'river' or opt['business'] == 'river2' :
from utilsK.queRiver import riverDetSegMixProcess_N
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'gpuname':'2080Ti',###显卡名称
'max_workers':1, ###并行线程数
'half':True,
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'seg_nclass':2,###分割模型类别数目,默认2类
'segRegionCnt':0,###分割模型结果需要保留的等值线数目
'segPar':{'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'numpy':False, 'RGB_convert_first':True,#分割模型预处理参数
'mixFunction':{'function':riverDetSegMixProcess,'pars':{'slopeIndex':[1,3,4,7], 'riverIou':0.1}} #分割和检测混合处理的函数
},
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'Segweights' : "../weights/%s/AIlib2/%s/stdc_360X640_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###分割模型权重位置
'postProcess':{'function':riverDetSegMixProcess_N,'pars':{'slopeIndex':[1,3,4,7], 'riverIou':0.1}}, #分割和检测混合处理的函数
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
},
{
#'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/stdc_360X640.pth'%(opt['business'] ),
'par':{
'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'numpy':False, 'RGB_convert_first':True,'seg_nclass':2},###分割模型预处理参数
'model':stdcModel,
'name':'stdc'
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%( opt['business'] ),###后处理参数文件
'txtFontSize':80,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
#'testImgPath':'images/videos/river',###测试图像的位置
'testImgPath':'images/tt',###测试图像的位置
'testImgPath':'images/river2',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
if opt['business'] == 'highWay2':
from segutils.trafficUtils import tracfficAccidentMixFunction_N
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%( opt['business'] ), ###检测类别对照表
'half':True,
'gpuname':'3090',###显卡名称
'max_workers':1, ###并行线程数
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'Detweights':"../AIlib2/weights/conf/highWay2/yolov5.pt",
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'seg_nclass':3,###分割模型类别数目,默认2类
'segRegionCnt':2,###分割模型结果需要保留的等值线数目
'segPar':{'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,###分割模型预处理参数
'mixFunction':{'function':tracfficAccidentMixFunction,
'pars':{ 'RoadArea': 16000, 'vehicleArea': 10, 'roadVehicleAngle': 15, 'speedRoadVehicleAngleMax': 75,'radius': 50 , 'roundness': 1.0, 'cls': 9, 'vehicleFactor': 0.1,'cls':9, 'confThres':0.25,'roadIou':0.6,'vehicleFlag':False,'distanceFlag': False }
}
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':5,'windowsize':29,'patchCnt':100},
'postProcess':{'function':tracfficAccidentMixFunction_N,
'pars':{ 'RoadArea': 16000, 'vehicleArea': 10, 'roadVehicleAngle': 15, 'speedRoadVehicleAngleMax': 75,'radius': 50 , 'roundness': 1.0, 'cls': 9, 'vehicleFactor': 0.1,'cls':9, 'confThres':0.25,'roadIou':0.6,'vehicleFlag':False,'distanceFlag': False }
},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
},
{
#'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/stdc_360X640.pth'%(opt['business'] ),
'par':{
'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,'seg_nclass':3},###分割模型预处理参数
'model':stdcModel,
'name':'stdc'
}
],
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':5,'windowsize':29,'patchCnt':100},
'mode':'highWay3.0',
'Segweights' : "../weights/%s/AIlib2/%s/stdc_360X640_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###分割模型权重位置
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business'] ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':0.5,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
@@ -249,61 +266,118 @@ def det_track_demo(business ):
'testImgPath':'/home/chenyukun/777-7-42.mp4',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
par['segPar']['mixFunction']['pars']['modelSize'] = par['segPar']['modelSize']
par['postProcess']['pars']['modelSize'] = par['models'][1]['par']['modelSize']
if opt['business'] == 'noParking':
from utilsK.noParkingUtils import mixNoParking_road_postprocess_N
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%( opt['business'] ), ###检测类别对照表
'half':True,
'gpuname':'3090',###显卡名称
'max_workers':1, ###并行线程数
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'Detweights':"../AIlib2/weights/conf/highWay2/yolov5.pt",
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'seg_nclass':4,###分割模型类别数目,默认2类
'segRegionCnt':2,###分割模型结果需要保留的等值线数目
'segPar':{'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,###分割模型预处理参数
'mixFunction':{'function':mixNoParking_road_postprocess,
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'postProcess':{'function':mixNoParking_road_postprocess_N,
'pars': { 'roundness': 0.3, 'cls': 9, 'laneArea': 10, 'laneAngleCha': 5 ,'RoadArea': 16000,'fitOrder':2}
}
} ,
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
},
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'mode':'highWay3.0',
'Segweights' : "../weights/%s/AIlib2/%s/stdc_360X640_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###分割模型权重位置
{
#'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/stdc_360X640.pth'%(opt['business'] ),
'par':{
'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,'seg_nclass':4},###分割模型预处理参数
'model':stdcModel,
'name':'stdc'
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%('highWay2' ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
'testImgPath':'images/noParking/',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
par['segPar']['mixFunction']['pars']['modelSize'] = par['segPar']['modelSize']
par['postProcess']['pars']['modelSize'] = par['models'][1]['par']['modelSize']
if opt['business'] == 'drowning':
from utilsK.drownUtils import mixDrowing_water_postprocess_N
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%( opt['business'] ), ###检测类别对照表
'max_workers':1, ###并行线程数
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'postProcess':{'function':mixDrowing_water_postprocess_N,
'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
},
{
#'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/stdc_360X640.pth'%(opt['business'] ),
'par':{
'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,'seg_nclass':2},###分割模型预处理参数
'model':stdcModel,
'name':'stdc'
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%('highWay2' ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
'testImgPath':'images/drowning/',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
par['postProcess']['pars']['modelSize'] = par['models'][1]['par']['modelSize']
if opt['business'] == 'cityMangement2':
from DMPR import DMPRModel
from DMPRUtils.jointUtil import dmpr_yolo
from DMPRUtils.jointUtil import dmpr_yolo_stdc
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'max_workers':1, ###并行线程数
'half':True,
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'Detweights':"/mnt/thsw2/DSP2/weights/cityMangement2/weights/urbanManagement/yolo/best.pt",
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'seg_nclass':4,###分割模型类别数目,默认2类
'segRegionCnt':2,###分割模型结果需要保留的等值线数目
'segPar':{ 'depth_factor':32,'NUM_FEATURE_MAP_CHANNEL':6,'dmpr_thresh':0.3, 'dmprimg_size':640,
'mixFunction':{'function':dmpr_yolo,
'pars':{'carCls':0 ,'illCls':3,'scaleRatio':0.5,'border':80}
}
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'postProcess':{
'function':dmpr_yolo_stdc,
'pars':{'carCls':0 ,'illCls':3,'scaleRatio':0.5,'border':80}
},
'models':
[
{
#'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } }
},
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
#'Segweights' : '/mnt/thsw2/DSP2/weights/cityMangement2/weights/urbanManagement/DMPR/dp_detector_499.engine',###分割模型权重位置
'Segweights':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
{
#'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'weight':'../AIlib2/weights/conf/%s/dmpr.pth'%(opt['business'] ),
'par':{
'depth_factor':32,'NUM_FEATURE_MAP_CHANNEL':6,'dmpr_thresh':0.3, 'dmprimg_size':640,
'name':'dmpr'
},
'model':DMPRModel,
'name':'dmpr'
}
] ,
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business'] ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
@@ -312,100 +386,135 @@ def det_track_demo(business ):
#'testImgPath':'images/cityMangement/',
'testOutPath':'images/results/',###输出测试图像位置
}
if opt['business'] == 'drowning':
if opt['business'] == 'cityMangement3':
from DMPR import DMPRModel
from DMPRUtils.jointUtil import dmpr_yolo_stdc
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%( opt['business'] ), ###检测类别对照表
'half':True,
'gpuname':'3090',###显卡名称
'max_workers':1, ###并行线程数
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'Detweights':"../AIlib2/weights/conf/highWay2/yolov5.pt",
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'seg_nclass':2,###分割模型类别数目,默认2类
'segRegionCnt':2,###分割模型结果需要保留的等值线数目
'segPar':{'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,###分割模型预处理参数
'mixFunction':{'function':mixDrowing_water_postprocess,
'pars':{ }
}
},
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'Segweights' : "../weights/%s/AIlib2/%s/stdc_360X640_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###分割模型权重位置
'postFile': '../AIlib2/weights/conf/%s/para.json'%('highWay2' ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
'testImgPath':'images/drowning/',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
par['segPar']['mixFunction']['pars']['modelSize'] = par['segPar']['modelSize']
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'max_workers':1, ###并行线程数
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'postProcess':{
'function':dmpr_yolo_stdc,
'pars':{'carCls':0 ,'illCls':3,'scaleRatio':0.5,'border':80}
},
'models':[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } }
},
{
'weight':"../weights/%s/AIlib2/%s/dmpr_%s.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###DMPR模型路径
#'weight':'../AIlib2/weights/conf/%s/dmpr.pth'%(opt['business'] ),
'par':{
'depth_factor':32,'NUM_FEATURE_MAP_CHANNEL':6,'dmpr_thresh':0.3, 'dmprimg_size':640,
'name':'dmpr'
},
'model':DMPRModel,
'name':'dmpr'
},
{
'weight':"../weights/%s/AIlib2/%s/stdc_360X640_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###分割模型路径
#'weight':'../AIlib2/weights/conf/%s/stdc_360X640.pth'%(opt['business'] ),
'par':{
'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'predResize':True,'numpy':False, 'RGB_convert_first':True,'seg_nclass':2},###分割模型预处理参数
'model':stdcModel,
'name':'stdc'
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business'] ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'segLineShow':True,'waterLineWidth':2},###显示框、线设置
#'testImgPath':'images/%s/'%(opt['business']),
'testImgPath':'/mnt/thsw2/DSP2/weights/cityMangement3/images/debug',
'testOutPath':'images/results/',###输出测试图像位置
}
''' 以下是基于检测的跟踪模型,只有检测没有分割 '''
if opt['business'] == 'forest2':
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/forest2/labelnames.json", ###检测类别对照表
'gpuname':opt['gpu'],###显卡名称
'max_workers':1, ###并行线程数
'half':True,
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [] ],
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###分割模型类别数目,默认2类
'segRegionCnt':0,###分割模型结果需要保留的等值线数目
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [] ],
'postFile': '../AIlib2/weights/conf/forest/para.json',###后处理参数文件
'txtFontSize':80,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
'testImgPath':'../AIdemo2/images/forest2/',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
###车辆巡检参数
###车辆巡检参数
if opt['business'] == 'vehicle':
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/vehicle/labelnames.json", ###检测类别对照表
'gpuname':'2080T',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###分割模型类别数目,默认2类
'segRegionCnt':0,###分割模型结果需要保留的等值线数目
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/vehicle/para.json',###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
'testImgPath':'images/videos/vehicle/',###测试图像的位置
'testImgPath':'images/vehicle/',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
###行人检测模型
}
###行人检测模型
if opt['business'] == 'pedestrian':
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/pedestrian/labelnames.json", ###检测类别对照表
'gpuname':'2080T',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###分割模型类别数目,默认2类
'segRegionCnt':0,###分割模型结果需要保留的等值线数目
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/pedestrian/para.json',###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
@@ -416,41 +525,45 @@ def det_track_demo(business ):
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/smogfire/labelnames.json", ###检测类别对照表
'gpuname':'2080T',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###没有分割模型,此处不用
'segRegionCnt':0,###没有分割模型,此处不用
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/smogfire/para.json',###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
'testImgPath':'../AIdemo2/images/smogfire/',###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
###钓鱼游泳检测
###钓鱼游泳检测
if opt['business'] == 'AnglerSwimmer':
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/AnglerSwimmer/labelnames.json", ###检测类别对照表
'gpuname':'2080T',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###没有分割模型,此处不用
'segRegionCnt':0,###没有分割模型,此处不用
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/AnglerSwimmer/para.json',###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
@@ -462,19 +575,22 @@ def det_track_demo(business ):
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/channelEmergency/labelnames.json", ###检测类别对照表
'gpuname':'2080T',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###没有分割模型,此处不用
'segRegionCnt':0,###没有分割模型,此处不用
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/channelEmergency/para.json',###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
@@ -482,23 +598,25 @@ def det_track_demo(business ):
'testOutPath':'images/results/',###输出测试图像位置
}
###乡村路违法种植
###乡村路违法种植
if opt['business'] == 'countryRoad':
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/countryRoad/labelnames.json", ###检测类别对照表
'gpuname':'2080T',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###没有分割模型,此处不用
'segRegionCnt':0,###没有分割模型,此处不用
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/countryRoad/para.json',###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
@@ -511,18 +629,20 @@ def det_track_demo(business ):
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'gpuname':'2080Ti',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###没有分割模型,此处不用
'segRegionCnt':0,###没有分割模型,此处不用
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business']),###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
@@ -535,45 +655,44 @@ def det_track_demo(business ):
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'gpuname':'2080Ti',###显卡名称
'half':True,
'max_workers':1, ###并行线程数
'trtFlag_det':True,###检测模型是否采用TRT
'trtFlag_seg':False,###分割模型是否采用TRT
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':2,###没有分割模型,此处不用
'segRegionCnt':0,###没有分割模型,此处不用
'segPar':None,###分割模型预处理参数
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':default_mix,'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business']),###后处理参数文件
'txtFontSize':40,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':3},###显示框、线设置
'testImgPath':'images/%s'%(opt['business']),###测试图像的位置
'testOutPath':'images/results/',###输出测试图像位置
}
if opt['business'] == 'illParking':
from utilsK.illParkingUtils import illParking_postprocess
from utilsK.illParkingUtils import illParking_postprocess_N
par={
'device':'0', ###显卡号,如果用TRT模型,只支持0(单显卡)
'half':True,
'labelnames':"../AIlib2/weights/conf/%s/labelnames.json"%(opt['business']), ###检测类别对照表
'max_workers':1, ###并行线程数
'Detweights':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
'seg_nclass':4,###没有分割模型,此处不用
'segRegionCnt':2,###没有分割模型,此处不用
'segPar':{
'mixFunction':{'function':illParking_postprocess,
'pars':{ }
}
},
'Segweights' : None,###分割模型权重位置
'postProcess':{'function':illParking_postprocess_N, 'pars':{ }},
'models':
[
{
'weight':"../weights/%s/AIlib2/%s/yolov5_%s_fp16.engine"%(opt['gpu'], opt['business'] ,opt['gpu'] ),###检测模型路径
#'weight':'../AIlib2/weights/conf/%s/yolov5.pt'%(opt['business'] ),
'name':'yolov5',
'model':yolov5Model,
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False, "score_byClass":{"0":0.25,"1":0.3,"2":0.3,"3":0.3 } },
}
],
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
'postFile': '../AIlib2/weights/conf/%s/para.json'%(opt['business'] ),###后处理参数文件
'txtFontSize':20,###文本字符的大小
'digitFont': { 'line_thickness':2,'boxLine_thickness':1, 'fontSize':1.0,'waterLineColor':(0,255,255),'waterLineWidth':2},###显示框、线设置
@@ -581,159 +700,47 @@ def det_track_demo(business ):
'testOutPath':'images/results/',###输出测试图像位置
}
par['trtFlag_det']=True if par['Detweights'].endswith('.engine') else False
if par['Segweights']:
par['segPar']['trtFlag_seg']=True if par['Segweights'].endswith('.engine') else False
##使用森林,道路模型,business 控制['forest','road']
##预先设置的参数
#gpuname=par['gpuname']#如果用trt就需要此参数,只能是"3090" "2080Ti"
device_=par['device'] ##选定模型,可选 cpu,'0','1'
device = select_device(device_)
half = device.type != 'cpu' # half precision only supported on CUDA
trtFlag_det=par['trtFlag_det'] ###是否采用TRT模型加速
##以下参数目前不可改
imageW=1080 ####道路模型
digitFont= par['digitFont']
####加载检测模型
if trtFlag_det:
Detweights=par['Detweights']
logger = trt.Logger(trt.Logger.ERROR)
with open(Detweights, "rb") as f, trt.Runtime(logger) as runtime:
model=runtime.deserialize_cuda_engine(f.read())# 输入trt本地文件,返回ICudaEngine对象
print('####load TRT model :%s'%(Detweights))
else:
Detweights=par['Detweights']
model = attempt_load(Detweights, map_location=device) # load FP32 model
if half: model.half()
####加载分割模型
seg_nclass = par['seg_nclass']
segPar=par['segPar']
if par['Segweights']:
if opt['business'] == 'cityMangement2':
segmodel = DMPRModel(weights=par['Segweights'], par = par['segPar'])
else:
segmodel = stdcModel(weights=par['Segweights'], par = par['segPar'])
'''
if par['segPar']['trtFlag_seg']:
Segweights = par['Segweights']
logger = trt.Logger(trt.Logger.ERROR)
with open(Segweights, "rb") as f, trt.Runtime(logger) as runtime:
segmodel=runtime.deserialize_cuda_engine(f.read())# 输入trt本地文件,返回ICudaEngine对象
print('############locad seg model trt success: ',Segweights)
else:
Segweights = par['Segweights']
segmodel = SegModel(nclass=seg_nclass,weights=Segweights,device=device)
print('############locad seg model pth success:',Segweights)
'''
else:
segmodel=None
#第一步加载模型
modelList=[ modelPar['model'](weights=modelPar['weight'],par=modelPar['par']) for modelPar in par['models'] ]
#第二步准备跟踪参数
trackPar=par['trackPar']
sort_tracker = Sort(max_age=trackPar['sort_max_age'],
min_hits=trackPar['sort_min_hits'],
iou_threshold=trackPar['sort_iou_thresh'])
labelnames = par['labelnames']
postFile= par['postFile']
print( Detweights,labelnames )
conf_thres,iou_thres,classes,rainbows=get_postProcess_para(postFile)
detPostPar = get_postProcess_para_dic(postFile)
conf_thres,iou_thres,classes,rainbows = detPostPar["conf_thres"],detPostPar["iou_thres"],detPostPar["classes"],detPostPar["rainbows"]
if 'ovlap_thres_crossCategory' in detPostPar.keys(): iou2nd=detPostPar['ovlap_thres_crossCategory']
else:iou2nd = None
if 'score_byClass' in detPostPar.keys(): score_byClass=detPostPar['score_byClass']
else: score_byClass = None
####模型选择参数用如下:
mode_paras=par['detModelpara']
allowedList,allowedList_string=get_needed_objectsIndex(mode_paras)
#slopeIndex = par['slopeIndex']
##只加载检测模型,准备好显示字符
names=get_labelnames(labelnames)
#imageW=4915;###默认是1920,在森林巡检的高清图像中是4920
outfontsize=int(imageW/1920*40);###
label_arraylist = get_label_arrays(names,rainbows,outfontsize=par['txtFontSize'],fontpath="../AIlib2/conf/platech.ttf")
##图像测试和视频
outpth = par['testOutPath']
impth = par['testImgPath']
imgpaths=[]###获取文件里所有的图像
videopaths=[]###获取文件里所有的视频
img_postfixs = ['.jpg','.JPG','.PNG','.png'];
vides_postfixs= ['.MP4','.mp4','.avi']
if os.path.isdir(impth):
for postfix in img_postfixs:
imgpaths.extend(glob.glob('%s/*%s'%(impth,postfix )) )
for postfix in ['.MP4','.mp4','.avi']:
videopaths.extend(glob.glob('%s/*%s'%(impth,postfix )) )
else:
postfix = os.path.splitext(impth)[-1]
if postfix in img_postfixs: imgpaths=[ impth ]
if postfix in vides_postfixs: videopaths = [impth ]
imgpaths.sort()
modelPar={ 'det_Model': model,'seg_Model':segmodel }
processPar={'half':par['half'],'device':device,'conf_thres':conf_thres,'iou_thres':iou_thres,'trtFlag_det':trtFlag_det,'iou2nd':iou2nd,'score_byClass':score_byClass}
drawPar={'names':names,'label_arraylist':label_arraylist,'rainbows':rainbows,'font': par['digitFont'],'allowedList':allowedList}
#第三步准备画图字体
drawPar = get_drawPar(par)
#第四步获取图像测试及视频
imgpaths,videopaths = get_images_videos( par['testImgPath'])
#第五步开始测试
for i in range(len(imgpaths)):
#for i in range(2):
#imgpath = os.path.join(impth, folders[i])
imgpath = imgpaths[i]
bname = os.path.basename(imgpath )
im0s=[cv2.imread(imgpath)]
time00 = time.time()
retResults,timeOut = AI_det_track_batch(im0s, [i] ,modelPar,processPar,sort_tracker ,trackPar,segPar)
#print('###line627:',retResults[2])
#retResults,timeInfos = AI_det_track_batch(imgarray_list, iframe_list ,par0['modelPar'],par0['processPar'],par0['sort_tracker'] ,par0['trackPar'],segPar=par0['segPar'])
retResults,timeOut = AI_det_track_batch_N(im0s, [i] ,modelList,par['postProcess'],sort_tracker ,trackPar)
time11 = time.time()
if len(retResults[1])>0:
retResults[0][0] = drawBoxTraceSimplied(retResults[1],i, retResults[0][0],rainbows=rainbows,boxFlag=True,traceFlag=False,names=drawPar['names'])
time11 = time.time()
image_array = retResults[0][0]
'''
返回值retResults[2] --list,其中每一个元素为一个list,表示每一帧的检测结果,每一个结果是由多个list构成,每个list表示一个框,格式为[ cls , x0 ,y0 ,x1 ,y1 ,conf,ifrmae,trackId ]
返回值retResults[2] --list,其中每一个元素为一个list,表示每一帧的检测结果,每一个结果是由多个list构成,每个list表示一个框,格式为[ x0 ,y0 ,x1 ,y1 ,conf,cls ,ifrmae,trackId ]
--etc. retResults[2][j][k]表示第j帧的第k个框。
'''
cv2.imwrite( os.path.join( outpth,bname ) ,image_array )
print('----image:%s, process:%s ( %s ),save:%s'%(bname,(time11-time00) * 1000, timeOut,(time.time() - time11) * 1000) )
##process video
cv2.imwrite( os.path.join( par['testOutPath'],bname ) ,image_array )
print('----image:%s, Allprocess:%s %s ,save:%s , objcnt:%d'%(bname,(time11-time00) * 1000, timeOut,(time.time() - time11) * 1000 ,len(retResults[2])) )
##第五步开始测试视频
print('##begin to process videos, total %d videos'%( len(videopaths)))
for i,video in enumerate(videopaths):
print('process video%d :%s '%(i,video))
par0={'modelPar':modelPar,'processPar':processPar,'drawPar':drawPar,'outpth':par['testOutPath'], 'sort_tracker':sort_tracker,'trackPar':trackPar,'segPar':segPar}
process_video(video,par0,mode='track')
par0={'modelList':modelList,'postProcess':par['postProcess'],'drawPar':drawPar,'outpth':par['testOutPath'], 'sort_tracker':sort_tracker,'trackPar':trackPar}
process_video(video,par0,mode='track')
def OCR_demo2(opt):
from ocrUtils2 import crnn_model
from ocrUtils2.ocrUtils import get_cfg,recognition_ocr,strLabelConverter
@@ -943,8 +950,8 @@ def crowd_demo(opt):
if __name__=="__main__":
#jkm_demo()
businessAll=['river', 'river2','highWay2','noParking','drowning','forest2','vehicle','pedestrian','smogfire' , 'AnglerSwimmer','channelEmergency', 'countryRoad','cityMangement','ship2','cityMangement2','cityRoad','illParking',"crowdCounting"]
businessAll = ['crowdCounting']
businessAll=['river', 'river2','highWay2','noParking','drowning','forest2','vehicle','pedestrian','smogfire' , 'AnglerSwimmer','channelEmergency', 'countryRoad','cityMangement','ship2','cityMangement2','cityRoad','illParking',"crowdCounting",'cityMangement3']
businessAll = [ 'cityMangement3' ]
for busi in businessAll:
print('-'*40,'beg to test:',busi,'-'*40)
@@ -955,7 +962,7 @@ if __name__=="__main__":
crowd_demo(opt)
else:
#if opt['business'] in ['river','highWay2','noParking','drowning','']:
det_track_demo(opt )
det_track_demo_N(opt )

二進制
images/cityMangement3/XJRW20231008132531_093.jpg 查看文件

Before After
Width: 1920  |  Height: 1080  |  Size: 442KB

二進制
images/cityMangement3/XJRW20231009084538_166.jpg 查看文件

Before After
Width: 1920  |  Height: 1080  |  Size: 345KB

二進制
images/results/2023-09-19-09-46-46_frame-18507-18787_type_20230919094646113613-2-0-0_OR.jpg 查看文件

Before After
Width: 720  |  Height: 540  |  Size: 138KB

二進制
images/results/DJI_0974_15.jpg 查看文件

Before After
Width: 3840  |  Height: 2160  |  Size: 2.7MB

+ 0
- 3
images/results/DJI_0974_15.txt 查看文件

@@ -1,3 +0,0 @@
4.0,716.0,521.0,1189.0,0.7485809326171875,2.0
1909.0,873.0,3017.0,1341.0,0.9105710983276367,0.0
740.0,803.0,1798.0,1279.0,0.9193859100341797,0.0

二進制
images/results/DJI_0974_15_mask.png 查看文件

Before After
Width: 5  |  Height: 6  |  Size: 102B

二進制
images/results/DJI_0988_20.jpg 查看文件

Before After
Width: 3840  |  Height: 2160  |  Size: 2.0MB

+ 0
- 4
images/results/DJI_0988_20.txt 查看文件

@@ -1,4 +0,0 @@
1494.0,1604.0,2538.0,2068.0,0.9015560150146484,0.0
1579.0,486.0,2501.0,895.0,0.9098825454711914,0.0
775.0,1700.0,1252.0,2159.0,0.9259564876556396,3.0
1510.0,1192.0,2504.0,1622.0,0.9318015575408936,0.0

二進制
images/results/DJI_0988_20_mask.png 查看文件

Before After
Width: 5  |  Height: 11  |  Size: 132B

二進制
images/results/DJI_0996_104.jpg 查看文件

Before After
Width: 3840  |  Height: 2160  |  Size: 2.7MB

二進制
images/results/DJI_20230626104206_0011_S_7.jpg 查看文件

Before After
Width: 1920  |  Height: 1080  |  Size: 937KB

+ 0
- 0
images/results/DJI_20230626104206_0011_S_7.txt 查看文件


二進制
images/results/DJI_20230626104206_0011_S_7_mask.png 查看文件

Before After
Width: 5  |  Height: 10  |  Size: 126B

二進制
images/results/t1.jpg 查看文件

Before After
Width: 800  |  Height: 524  |  Size: 275KB

二進制
images/results/t2.jpg 查看文件

Before After
Width: 500  |  Height: 281  |  Size: 93KB

二進制
images/results/t3.jpg 查看文件

Before After
Width: 800  |  Height: 449  |  Size: 283KB

二進制
images/results/t4.jpg 查看文件

Before After
Width: 4000  |  Height: 2250  |  Size: 3.5MB

二進制
images/results/w1.jpg 查看文件

Before After
Width: 1063  |  Height: 597  |  Size: 362KB

二進制
images/results/w2.jpg 查看文件

Before After
Width: 1050  |  Height: 595  |  Size: 286KB

二進制
images/results/w3.jpg 查看文件

Before After
Width: 1059  |  Height: 597  |  Size: 309KB

二進制
images/results/w4.jpg 查看文件

Before After
Width: 1033  |  Height: 558  |  Size: 266KB

+ 3
- 0
readme.md 查看文件

@@ -1,2 +1,5 @@
2023.07.18
1.demo3.0.py, 3.0版本中加入跟踪,demo.py没有跟踪。

2023.11.06
1.所有demo3.0.py 采用新的架构,模型作为一个输入参数组传入。

Loading…
取消
儲存