763 lines
33 KiB
Python
763 lines
33 KiB
Python
import sys
|
||
from enum import Enum, unique
|
||
|
||
from common.Constant import COLOR
|
||
|
||
sys.path.extend(['..', '../AIlib2'])
|
||
from segutils.segmodel import SegModel
|
||
from utilsK.queRiver import riverDetSegMixProcess_N
|
||
from segutils.trafficUtils import tracfficAccidentMixFunction_N
|
||
from utilsK.drownUtils import mixDrowing_water_postprocess_N
|
||
from utilsK.noParkingUtils import mixNoParking_road_postprocess_N
|
||
from utilsK.illParkingUtils import illParking_postprocess
|
||
from DMPR import DMPRModel
|
||
from DMPRUtils.jointUtil import dmpr_yolo
|
||
from yolov5 import yolov5Model
|
||
from stdc import stdcModel
|
||
from AI import default_mix
|
||
from DMPRUtils.jointUtil import dmpr_yolo_stdc
|
||
|
||
'''
|
||
参数说明
|
||
1. 编号
|
||
2. 模型编号
|
||
3. 模型名称
|
||
4. 选用的模型名称
|
||
'''
|
||
|
||
|
||
@unique
|
||
class ModelType2(Enum):
|
||
WATER_SURFACE_MODEL = ("1", "001", "河道模型", 'river', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["排口", "水生植被", "其它", "漂浮物", "污染排口", "菜地", "违建", "岸坡垃圾"],
|
||
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,4,5,6,7] ],###控制哪些检测类别显示、输出
|
||
'trackPar': {
|
||
'sort_max_age': 2, # 跟踪链断裂时允许目标消失最大的次数。超过之后,会认为是新的目标。
|
||
'sort_min_hits': 3, # 每隔目标连续出现的次数,超过这个次数才认为是一个目标。
|
||
'sort_iou_thresh': 0.2, # 检测最小的置信度。
|
||
'det_cnt': 10, # 每隔几次做一个跟踪和检测,默认10。
|
||
'windowsize': 29, # 轨迹平滑长度,一定是奇数,表示每隔几帧做一平滑,默认29。一个目标在多个帧中出现,每一帧中都有一个位置,这些位置的连线交轨迹。
|
||
'patchCnt': 100, # 每次送入图像的数量,不宜少于100帧。
|
||
},
|
||
'postProcess':{'function':riverDetSegMixProcess_N,'pars':{'slopeIndex':[1,3,4,7], 'riverIou':0.1}}, #分割和检测混合处理的函数
|
||
'postFile': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 80,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/river/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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':'../AIlib2/weights/conf/river/stdc_360X640.pth',
|
||
'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'
|
||
}
|
||
|
||
],
|
||
})
|
||
|
||
FOREST_FARM_MODEL = ("2", "002", "森林模型", 'forest2', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["林斑", "病死树", "行人", "火焰", "烟雾"],
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/forest2/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'postFile': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 80,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
TRAFFIC_FARM_MODEL = ("3", "003", "交通模型", 'highWay2', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["行人", "车辆", "纵向裂缝", "横向裂缝", "修补", "网状裂纹", "坑槽", "块状裂纹", "积水", "事故"],
|
||
'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,
|
||
'modelSize':(640,360),
|
||
}
|
||
},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/highWay2/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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':'../AIlib2/weights/conf/highWay2/stdc_360X640.pth',
|
||
'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'
|
||
}
|
||
],
|
||
'detModelpara':[{"id":str(x),"config":{"k1":"v1","k2":"v2"}} for x in [0,1,2,3,5,6,7,8,9] ],###控制哪些检测类别显示、输出
|
||
'postFile': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.25,
|
||
"classes": 9,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 20,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'waterLineColor': (0, 255, 255),
|
||
'segLineShow': False,
|
||
'waterLineWidth': 2
|
||
}
|
||
})
|
||
|
||
EPIDEMIC_PREVENTION_MODEL = ("4", "004", "防疫模型", None, None)
|
||
|
||
PLATE_MODEL = ("5", "005", "车牌模型", None, None)
|
||
|
||
VEHICLE_MODEL = ("6", "006", "车辆模型", 'vehicle', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["车辆"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/vehicle/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 40,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'waterLineColor': (0, 255, 255),
|
||
'segLineShow': False,
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
PEDESTRIAN_MODEL = ("7", "007", "行人模型", 'pedestrian', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["行人"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/pedestrian/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
SMOGFIRE_MODEL = ("8", "008", "烟火模型", 'smogfire', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["烟雾", "火焰"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/smogfire/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
#'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 40,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
ANGLERSWIMMER_MODEL = ("9", "009", "钓鱼游泳模型", 'AnglerSwimmer', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["钓鱼", "游泳"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/AnglerSwimmer/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 40,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
},
|
||
})
|
||
|
||
COUNTRYROAD_MODEL = ("10", "010", "乡村模型", 'countryRoad', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["违法种植"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/countryRoad/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 40,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
SHIP_MODEL = ("11", "011", "船只模型", 'ship2', lambda device, gpuName: {
|
||
'obbModelPar': {
|
||
'labelnames': ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "船只"],
|
||
'model_size': (608, 608),
|
||
'K': 100,
|
||
'conf_thresh': 0.3,
|
||
'down_ratio': 4,
|
||
'num_classes': 15,
|
||
'dataset': 'dota',
|
||
'heads': {
|
||
'hm': None,
|
||
'wh': 10,
|
||
'reg': 2,
|
||
'cls_theta': 1
|
||
},
|
||
'mean': (0.5, 0.5, 0.5),
|
||
'std': (1, 1, 1),
|
||
'half': False,
|
||
'test_flag': True,
|
||
'decoder': None,
|
||
'weights': '../AIlib2/weights/ship2/obb_608X608_%s_fp16.engine' % gpuName
|
||
},
|
||
'trackPar': {
|
||
'sort_max_age': 2, # 跟踪链断裂时允许目标消失最大的次数。超过之后,会认为是新的目标。
|
||
'sort_min_hits': 3, # 每隔目标连续出现的次数,超过这个次数才认为是一个目标。
|
||
'sort_iou_thresh': 0.2, # 检测最小的置信度。
|
||
'det_cnt': 10, # 每隔几次做一个跟踪和检测,默认10。
|
||
'windowsize': 29, # 轨迹平滑长度,一定是奇数,表示每隔几帧做一平滑,默认29。一个目标在多个帧中出现,每一帧中都有一个位置,这些位置的连线交轨迹。
|
||
'patchCnt': 100, # 每次送入图像的数量,不宜少于100帧。
|
||
},
|
||
'device': "cuda:%s" % device,
|
||
'postFile': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'drawBox': False,
|
||
'drawPar': {
|
||
"rainbows": COLOR,
|
||
'digitWordFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'wordSize': 40,
|
||
'fontSize': 1.0,
|
||
'label_location': 'leftTop'
|
||
}
|
||
},
|
||
'labelnames': ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "船只"]
|
||
})
|
||
|
||
BAIDU_MODEL = ("12", "012", "百度AI图片识别模型", None, None)
|
||
|
||
CHANNEL_EMERGENCY_MODEL = ("13", "013", "航道模型", 'channelEmergency', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["人"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/channelEmergency/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
#'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 40,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
RIVER2_MODEL = ("15", "015", "河道检测模型", 'river2', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["漂浮物", "岸坡垃圾", "排口", "违建", "菜地", "水生植物", "河湖人员", "钓鱼人员", "船只",
|
||
"蓝藻"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':riverDetSegMixProcess_N,'pars':{'slopeIndex':[1,3,4,7], 'riverIou':0.1}}, #分割和检测混合处理的函数
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/river2/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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':'../AIlib2/weights/conf/river2/stdc_360X640.pth',
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.3,
|
||
"ovlap_thres_crossCategory": 0.65,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 80,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
CITY_MANGEMENT_MODEL = ("16", "016", "城管模型", 'cityMangement2', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["车辆", "垃圾", "商贩", "违停"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':5,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{
|
||
'function':dmpr_yolo_stdc,
|
||
'pars':{'carCls':0 ,'illCls':3,'scaleRatio':0.5,'border':80}
|
||
},
|
||
'models':[
|
||
{
|
||
'weight':"../AIlib2/weights/cityMangement3/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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.8,"1":0.5,"2":0.5,"3":0.5 } }
|
||
|
||
},
|
||
{
|
||
'weight':"../AIlib2/weights/cityMangement3/dmpr_%s.engine"% gpuName,###DMPR模型路径
|
||
'par':{
|
||
'depth_factor':32,'NUM_FEATURE_MAP_CHANNEL':6,'dmpr_thresh':0.3, 'dmprimg_size':640,
|
||
'name':'dmpr'
|
||
},
|
||
'model':DMPRModel,
|
||
'name':'dmpr'
|
||
},
|
||
{
|
||
'weight':"../AIlib2/weights/cityMangement3/stdc_360X640_%s_fp16.engine"% gpuName,###分割模型路径
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 20,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 2
|
||
}
|
||
})
|
||
|
||
DROWING_MODEL = ("17", "017", "人员落水模型", 'drowning', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["人头", "人", "船只"],
|
||
'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':"../AIlib2/weights/drowning/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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':'../AIlib2/weights/conf/drowning/stdc_360X640.pth',
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.25,
|
||
"classes": 9,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 20,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'waterLineColor': (0, 255, 255),
|
||
'segLineShow': False,
|
||
'waterLineWidth': 2
|
||
}
|
||
})
|
||
|
||
NOPARKING_MODEL = (
|
||
"18", "018", "城市违章模型", 'noParking', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["车辆", "违停"],
|
||
'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, 'modelSize':(640,360)}
|
||
} ,
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/noParking/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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':'../AIlib2/weights/conf/noParking/stdc_360X640.pth',
|
||
'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.25,
|
||
"classes": 9,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 20,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'waterLineColor': (0, 255, 255),
|
||
'segLineShow': False,
|
||
'waterLineWidth': 2
|
||
}
|
||
}
|
||
)
|
||
|
||
CITYROAD_MODEL = ("20", "020", "城市公路模型", 'cityRoad', lambda device, gpuName: {
|
||
'device': device,
|
||
'labelnames': ["护栏", "交通标志", "非交通标志", "施工", "施工"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':10,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/cityRoad/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'name':'yolov5',
|
||
'model':yolov5Model,
|
||
'par':{ 'half':True,'device':'cuda:0' ,'conf_thres':0.8,'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': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.8,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 40,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
}
|
||
})
|
||
|
||
POTHOLE_MODEL = ("23", "023", "坑槽检测模型", 'pothole', lambda device, gpuName: { # 目前集成到另外的模型中去了 不单独使用
|
||
'device': device,
|
||
'labelnames': ["坑槽"],
|
||
'trackPar':{'sort_max_age':2,'sort_min_hits':3,'sort_iou_thresh':0.2,'det_cnt':3,'windowsize':29,'patchCnt':100},
|
||
'postProcess':{'function':default_mix,'pars':{ }},
|
||
'models':
|
||
[
|
||
{
|
||
'weight':"../AIlib2/weights/pothole/yolov5_%s_fp16.engine"% gpuName,###检测模型路径
|
||
'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]],###控制哪些检测类别显示、输出
|
||
'postFile': {
|
||
"name": "post_process",
|
||
"conf_thres": 0.25,
|
||
"iou_thres": 0.45,
|
||
"classes": 5,
|
||
"rainbows": COLOR
|
||
},
|
||
'txtFontSize': 40,
|
||
'digitFont': {
|
||
'line_thickness': 2,
|
||
'boxLine_thickness': 1,
|
||
'fontSize': 1.0,
|
||
'segLineShow': False,
|
||
'waterLineColor': (0, 255, 255),
|
||
'waterLineWidth': 3
|
||
},
|
||
})
|
||
|
||
|
||
@staticmethod
|
||
def checkCode(code):
|
||
for model in ModelType2:
|
||
if model.value[1] == code:
|
||
return True
|
||
return False
|
||
|
||
|
||
'''
|
||
参数1: 检测目标名称
|
||
参数2: 检测目标
|
||
参数3: 初始化百度检测客户端
|
||
'''
|
||
|
||
|
||
@unique
|
||
class BaiduModelTarget2(Enum):
|
||
VEHICLE_DETECTION = (
|
||
"车辆检测", 0, lambda client0, client1, url, request_id: client0.vehicleDetectUrl(url, request_id))
|
||
|
||
HUMAN_DETECTION = (
|
||
"人体检测与属性识别", 1, lambda client0, client1, url, request_id: client1.bodyAttr(url, request_id))
|
||
|
||
PEOPLE_COUNTING = ("人流量统计", 2, lambda client0, client1, url, request_id: client1.bodyNum(url, request_id))
|
||
|
||
|
||
BAIDU_MODEL_TARGET_CONFIG2 = {
|
||
BaiduModelTarget2.VEHICLE_DETECTION.value[1]: BaiduModelTarget2.VEHICLE_DETECTION,
|
||
BaiduModelTarget2.HUMAN_DETECTION.value[1]: BaiduModelTarget2.HUMAN_DETECTION,
|
||
BaiduModelTarget2.PEOPLE_COUNTING.value[1]: BaiduModelTarget2.PEOPLE_COUNTING
|
||
}
|
||
|
||
EPIDEMIC_PREVENTION_CONFIG = {1: "行程码", 2: "健康码"}
|
||
|
||
|
||
# 模型分析方式
|
||
@unique
|
||
class ModelMethodTypeEnum2(Enum):
|
||
# 方式一: 正常识别方式
|
||
NORMAL = 1
|
||
|
||
# 方式二: 追踪识别方式
|
||
TRACE = 2
|