|
- # -*- coding: utf-8 -*-
- import sys
- from pickle import dumps, loads
- from traceback import format_exc
- import time
-
- import cv2
- from loguru import logger
-
- from common.Constant import COLOR
- from enums.BaiduSdkEnum import VehicleEnum
- from enums.ExceptionEnum import ExceptionType
- from enums.ModelTypeEnum import ModelType, BAIDU_MODEL_TARGET_CONFIG
- from exception.CustomerException import ServiceException
- from util.ImgBaiduSdk import AipBodyAnalysisClient, AipImageClassifyClient
- from util.PlotsUtils import get_label_arrays, get_label_array_dict
- from util.TorchUtils import select_device
-
- sys.path.extend(['..', '../AIlib2'])
- from AI import AI_process, AI_process_forest, get_postProcess_para, ocr_process, AI_process_N, AI_process_C
- from stdc import stdcModel
- from segutils.segmodel import SegModel
- from models.experimental import attempt_load
- from obbUtils.shipUtils import OBB_infer
- from obbUtils.load_obb_model import load_model_decoder_OBB
- import torch
- import tensorrt as trt
- from utilsK.jkmUtils import pre_process, post_process, get_return_data
- from DMPR import DMPRModel
- FONT_PATH = "../AIlib2/conf/platech.ttf"
-
-
- # 河道模型、河道检测模型、交通模型、人员落水模型、城市违章公共模型
- class OneModel:
- __slots__ = "model_conf"
-
- def __init__(self, device, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None, env=None):
- try:
- logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
- requestId)
- par = modeType.value[4](str(device), gpu_name)
- mode, postPar, segPar = par.get('mode', 'others'), par.get('postPar'), par.get('segPar')
- names = par['labelnames']
- postFile = par['postFile']
- rainbows = postFile["rainbows"]
- new_device = select_device(par.get('device'))
- half = new_device.type != 'cpu'
- Detweights = par['Detweights']
- with open(Detweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
- model = runtime.deserialize_cuda_engine(f.read())
- par['segPar']['seg_nclass'] = par['seg_nclass']
- Segweights = par['Segweights']
- if Segweights:
- if modeType.value[3] == 'cityMangement3':
- segmodel = DMPRModel(weights=Segweights, par=par['segPar'])
- else:
- segmodel = stdcModel(weights=Segweights, par=par['segPar'])
- else:
- segmodel = None
- objectPar = {
- 'half': half,
- 'device': new_device,
- 'conf_thres': postFile["conf_thres"],
- 'ovlap_thres_crossCategory': postFile.get("ovlap_thres_crossCategory"),
- 'iou_thres': postFile["iou_thres"],
- 'allowedList': [],
- 'segRegionCnt': par['segRegionCnt'],
- 'trtFlag_det': par['trtFlag_det'],
- 'trtFlag_seg': par['trtFlag_seg']
- }
- model_param = {
- "model": model,
- "segmodel": segmodel,
- "objectPar": objectPar,
- "segPar": segPar,
- "mode": mode,
- "postPar": postPar
- }
- self.model_conf = (modeType, model_param, allowedList, names, rainbows)
- except Exception:
- logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
- ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
-
- class cityManagementModel:
- __slots__ = "model_conf"
-
- def __init__(self, device, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None, env=None):
- try:
- logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
- requestId)
- par = modeType.value[4](str(device), gpu_name)
- postProcess = par['postProcess']
- names = par['labelnames']
- postFile = par['postFile']
- rainbows = postFile["rainbows"]
- modelList=[ modelPar['model'](weights=modelPar['weight'],par=modelPar['par']) for modelPar in par['models'] ]
- model_param = {
- "modelList": modelList,
- "postProcess": postProcess,
- }
- self.model_conf = (modeType, model_param, allowedList, names, rainbows)
- except Exception:
- logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
- ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
-
- def detSeg_demo2(args):
- model_conf, frame, request_id = args
- modelList, postProcess = model_conf[1]['modelList'], model_conf[1]['postProcess']
- try:
- return AI_process_N([frame], modelList, postProcess)
- except ServiceException as s:
- raise s
- except Exception:
- # self.num += 1
- # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
- logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
- raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
- ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
-
-
- def model_process(args):
- model_conf, frame, request_id = args
- model_param, names, rainbows = model_conf[1], model_conf[3], model_conf[4]
- # modeType, model_param, allowedList, names, rainbows = model_conf
- # segmodel, names, label_arraylist, rainbows, objectPar, font, segPar, mode, postPar, requestId = args
- # model_param['digitFont'] = digitFont
- # model_param['label_arraylist'] = label_arraylist
- # model_param['font_config'] = font_config
- try:
- return AI_process([frame], model_param['model'], model_param['segmodel'], names, model_param['label_arraylist'],
- rainbows, objectPar=model_param['objectPar'], font=model_param['digitFont'],
- segPar=loads(dumps(model_param['segPar'])), mode=model_param['mode'],
- postPar=model_param['postPar'])
- except ServiceException as s:
- raise s
- except Exception:
- # self.num += 1
- # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
- logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
- raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
- ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
-
-
- # 森林模型、车辆模型、行人模型、烟火模型、 钓鱼模型、航道模型、乡村模型、城管模型公共模型
- class TwoModel:
- __slots__ = "model_conf"
-
- def __init__(self, device1, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
- env=None):
- s = time.time()
- try:
- logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
- requestId)
- par = modeType.value[4](str(device1), gpu_name)
- device = select_device(par.get('device'))
- names = par['labelnames']
- half = device.type != 'cpu'
- Detweights = par['Detweights']
- with open(Detweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
- model = runtime.deserialize_cuda_engine(f.read())
- segmodel = None
- postFile = par['postFile']
- conf_thres = postFile["conf_thres"]
- iou_thres = postFile["iou_thres"]
- rainbows = postFile["rainbows"]
- otc = postFile.get("ovlap_thres_crossCategory")
- model_param = {
- "model": model,
- "segmodel": segmodel,
- "half": half,
- "device": device,
- "conf_thres": conf_thres,
- "iou_thres": iou_thres,
- "trtFlag_det": par['trtFlag_det'],
- "otc": otc
- }
- self.model_conf = (modeType, model_param, allowedList, names, rainbows)
- except Exception:
- logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
- ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
- logger.info("模型初始化时间:{}, requestId:{}", time.time() - s, requestId)
-
-
- def forest_process(args):
- model_conf, frame, request_id = args
- model_param, names, rainbows = model_conf[1], model_conf[3], model_conf[4]
- try:
- return AI_process_forest([frame], model_param['model'], model_param['segmodel'], names,
- model_param['label_arraylist'], rainbows, model_param['half'], model_param['device'],
- model_param['conf_thres'], model_param['iou_thres'], [], font=model_param['digitFont'],
- trtFlag_det=model_param['trtFlag_det'], SecNms=model_param['otc'])
- except ServiceException as s:
- raise s
- except Exception:
- # self.num += 1
- # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
- logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
- raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
- ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
-
- class MultiModel:
- __slots__ = "model_conf"
-
- def __init__(self, device1, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
- env=None):
- s = time.time()
- try:
- logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
- requestId)
- par = modeType.value[4](str(device1), gpu_name)
- postProcess = par['postProcess']
- names = par['labelnames']
- postFile = par['postFile']
- rainbows = postFile["rainbows"]
- modelList=[ modelPar['model'](weights=modelPar['weight'],par=modelPar['par']) for modelPar in par['models'] ]
- model_param = {
- "modelList": modelList,
- "postProcess": postProcess,
- }
- self.model_conf = (modeType, model_param, allowedList, names, rainbows)
- except Exception:
- logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
- ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
- logger.info("模型初始化时间:{}, requestId:{}", time.time() - s, requestId)
-
- def channel2_process(args):
- model_conf, frame, request_id = args
- modelList, postProcess = model_conf[1]['modelList'], model_conf[1]['postProcess']
- try:
- start = time.time()
- result = [[None, None, AI_process_C([frame], modelList, postProcess)[0]]] # 为了让返回值适配统一的接口而写的shi
- # print("AI_process_C use time = {}".format(time.time()-start))
- return result
- except ServiceException as s:
- raise s
- except Exception:
- logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
- raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
- ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
-
- def get_label_arraylist(*args):
- width, height, names, rainbows = args
- # line = int(round(0.002 * (height + width) / 2) + 1)
- line = max(1, int(round(width / 1920 * 3)))
- label = ' 0.95'
- tf = max(line - 1, 1)
- fontScale = line * 0.33
- text_width, text_height = cv2.getTextSize(label, 0, fontScale=fontScale, thickness=tf)[0]
- # fontsize = int(width / 1920 * 40)
- numFontSize = float(format(width / 1920 * 1.1, '.1f'))
- digitFont = {'line_thickness': line,
- 'boxLine_thickness': line,
- 'fontSize': numFontSize,
- 'waterLineColor': (0, 255, 255),
- 'segLineShow': False,
- 'waterLineWidth': line,
- 'wordSize': text_height,
- 'label_location': 'leftTop'}
- label_arraylist = get_label_arrays(names, rainbows, fontSize=text_height, fontPath=FONT_PATH)
- return digitFont, label_arraylist, (line, text_width, text_height, fontScale, tf)
-
-
- # 船只模型
- class ShipModel:
- __slots__ = "model_conf"
-
- def __init__(self, device1, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
- env=None):
- s = time.time()
- try:
- logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
- requestId)
- par = modeType.value[4](str(device1), gpu_name)
- model, decoder2 = load_model_decoder_OBB(par)
- par['decoder'] = decoder2
- names = par['labelnames']
- rainbows = par['postFile']["rainbows"]
- model_param = {
- "model": model,
- "par": par
- }
- self.model_conf = (modeType, model_param, allowedList, names, rainbows)
- except Exception:
- logger.exception("模型加载异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
- ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
- logger.info("模型初始化时间:{}, requestId:{}", time.time() - s, requestId)
-
-
- def obb_process(args):
- model_conf, frame, request_id = args
- model_param = model_conf[1]
- # font_config, frame, names, label_arrays, rainbows, model, par, requestId = args
- try:
- return OBB_infer(model_param["model"], frame, model_param["par"])
- except ServiceException as s:
- raise s
- except Exception:
- # self.num += 1
- # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
- logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
- raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
- ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
-
-
- # 车牌分割模型、健康码、行程码分割模型
- class IMModel:
- __slots__ = "model_conf"
-
- def __init__(self, device, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
- env=None):
- try:
- logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
- requestId)
- img_type = 'code'
- if ModelType.PLATE_MODEL == modeType:
- img_type = 'plate'
- par = {
- 'code': {'weights': '../AIlib2/weights/conf/jkm/health_yolov5s_v3.jit', 'img_type': 'code', 'nc': 10},
- 'plate': {'weights': '../AIlib2/weights/conf/jkm/plate_yolov5s_v3.jit', 'img_type': 'plate', 'nc': 1},
- 'conf_thres': 0.4,
- 'iou_thres': 0.45,
- 'device': 'cuda:%s' % device,
- 'plate_dilate': (0.5, 0.3)
- }
-
- new_device = torch.device(par['device'])
- model = torch.jit.load(par[img_type]['weights'])
- self.model_conf = (modeType, allowedList, new_device, model, par, img_type)
- except Exception:
- logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
- ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
-
-
- def im_process(args):
- frame, device, model, par, img_type, requestId = args
- try:
- img, padInfos = pre_process(frame, device)
- pred = model(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(frame, boxes, modelType=img_type, plate_dilate=par['plate_dilate'])
- return dataBack
- except ServiceException as s:
- raise s
- except Exception:
- logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
- ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
-
-
- # 百度AI图片识别模型
- class BaiduAiImageModel:
- __slots__ = "model_conf"
-
- def __init__(self, device=None, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
- env=None):
- try:
- logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
- requestId)
- # 人体检测与属性识别、 人流量统计客户端
- aipBodyAnalysisClient = AipBodyAnalysisClient(base_dir, env)
- # 车辆检测检测客户端
- aipImageClassifyClient = AipImageClassifyClient(base_dir, env)
- rainbows = COLOR
- vehicle_names = [VehicleEnum.CAR.value[1], VehicleEnum.TRICYCLE.value[1], VehicleEnum.MOTORBIKE.value[1],
- VehicleEnum.CARPLATE.value[1], VehicleEnum.TRUCK.value[1], VehicleEnum.BUS.value[1]]
- person_names = ['人']
- self.model_conf = (modeType, aipImageClassifyClient, aipBodyAnalysisClient, allowedList, rainbows,
- vehicle_names, person_names, requestId)
- except Exception:
- logger.exception("模型加载异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
- ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
-
-
- def get_baidu_label_arraylist(*args):
- width, height, vehicle_names, person_names, rainbows = args
- # line = int(round(0.002 * (height + width) / 2) + 1)
- line = max(1, int(round(width / 1920 * 3) + 1))
- label = ' 0.97'
- tf = max(line, 1)
- fontScale = line * 0.33
- text_width, text_height = cv2.getTextSize(label, 0, fontScale=fontScale, thickness=tf)[0]
- vehicle_label_arrays = get_label_arrays(vehicle_names, rainbows, fontSize=text_height, fontPath=FONT_PATH)
- person_label_arrays = get_label_arrays(person_names, rainbows, fontSize=text_height, fontPath=FONT_PATH)
- font_config = (line, text_width, text_height, fontScale, tf)
- return vehicle_label_arrays, person_label_arrays, font_config
-
-
- def baidu_process(args):
- target, url, aipImageClassifyClient, aipBodyAnalysisClient, request_id = args
- try:
- # [target, url, aipImageClassifyClient, aipBodyAnalysisClient, requestId]
- baiduEnum = BAIDU_MODEL_TARGET_CONFIG.get(target)
- if baiduEnum is None:
- raise ServiceException(ExceptionType.DETECTION_TARGET_TYPES_ARE_NOT_SUPPORTED.value[0],
- ExceptionType.DETECTION_TARGET_TYPES_ARE_NOT_SUPPORTED.value[1]
- + " target: " + target)
- return baiduEnum.value[2](aipImageClassifyClient, aipBodyAnalysisClient, url, request_id)
- except ServiceException as s:
- raise s
- except Exception:
- logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
- raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
- ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
-
-
- def one_label(width, height, model_conf):
- # modeType, model_param, allowedList, names, rainbows = model_conf
- names = model_conf[3]
- rainbows = model_conf[4]
- model_param = model_conf[1]
- digitFont, label_arraylist, font_config = get_label_arraylist(width, height, names, rainbows)
- model_param['digitFont'] = digitFont
- model_param['label_arraylist'] = label_arraylist
- model_param['font_config'] = font_config
-
- def dynamics_label(width, height, model_conf):
- # modeType, model_param, allowedList, names, rainbows = model_conf
- names = model_conf[3]
- rainbows = model_conf[4]
- model_param = model_conf[1]
- digitFont, label_arraylist, font_config = get_label_arraylist(width, height, names, rainbows)
- line = max(1, int(round(width / 1920 * 3)))
- label = ' 0.95'
- tf = max(line - 1, 1)
- fontScale = line * 0.33
- _, text_height = cv2.getTextSize(label, 0, fontScale=fontScale, thickness=tf)[0]
- label_dict = get_label_array_dict(rainbows, fontSize=text_height, fontPath=FONT_PATH)
- model_param['digitFont'] = digitFont
- model_param['label_arraylist'] = label_arraylist
- model_param['font_config'] = font_config
- model_param['label_dict'] = label_dict
- def baidu_label(width, height, model_conf):
- # modeType, aipImageClassifyClient, aipBodyAnalysisClient, allowedList, rainbows,
- # vehicle_names, person_names, requestId
- vehicle_names = model_conf[5]
- person_names = model_conf[6]
- rainbows = model_conf[4]
- vehicle_label_arrays, person_label_arrays, font_config = get_baidu_label_arraylist(width, height, vehicle_names,
- person_names, rainbows)
- return vehicle_label_arrays, person_label_arrays, font_config
-
-
- MODEL_CONFIG = {
- # 加载河道模型
- ModelType.WATER_SURFACE_MODEL.value[1]: (
- lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.WATER_SURFACE_MODEL, t, z, h),
- ModelType.WATER_SURFACE_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: model_process(x)
- ),
- # 加载森林模型
- ModelType.FOREST_FARM_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.FOREST_FARM_MODEL, t, z, h),
- ModelType.FOREST_FARM_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)
- ),
- # 加载交通模型
- ModelType.TRAFFIC_FARM_MODEL.value[1]: (
- lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.TRAFFIC_FARM_MODEL, t, z, h),
- ModelType.TRAFFIC_FARM_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: model_process(x)
- ),
- # 加载防疫模型
- ModelType.EPIDEMIC_PREVENTION_MODEL.value[1]: (
- lambda x, y, r, t, z, h: IMModel(x, y, r, ModelType.EPIDEMIC_PREVENTION_MODEL, t, z, h),
- ModelType.EPIDEMIC_PREVENTION_MODEL,
- None,
- lambda x: im_process(x)),
- # 加载车牌模型
- ModelType.PLATE_MODEL.value[1]: (
- lambda x, y, r, t, z, h: IMModel(x, y, r, ModelType.PLATE_MODEL, t, z, h),
- ModelType.PLATE_MODEL,
- None,
- lambda x: im_process(x)),
- # 加载车辆模型
- ModelType.VEHICLE_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.VEHICLE_MODEL, t, z, h),
- ModelType.VEHICLE_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)
- ),
- # 加载行人模型
- ModelType.PEDESTRIAN_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.PEDESTRIAN_MODEL, t, z, h),
- ModelType.PEDESTRIAN_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)),
- # 加载烟火模型
- ModelType.SMOGFIRE_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.SMOGFIRE_MODEL, t, z, h),
- ModelType.SMOGFIRE_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)),
- # 加载钓鱼游泳模型
- ModelType.ANGLERSWIMMER_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.ANGLERSWIMMER_MODEL, t, z, h),
- ModelType.ANGLERSWIMMER_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)),
- # 加载乡村模型
- ModelType.COUNTRYROAD_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.COUNTRYROAD_MODEL, t, z, h),
- ModelType.COUNTRYROAD_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)),
- # 加载船只模型
- ModelType.SHIP_MODEL.value[1]: (
- lambda x, y, r, t, z, h: ShipModel(x, y, r, ModelType.SHIP_MODEL, t, z, h),
- ModelType.SHIP_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: obb_process(x)),
- # 百度AI图片识别模型
- ModelType.BAIDU_MODEL.value[1]: (
- lambda x, y, r, t, z, h: BaiduAiImageModel(x, y, r, ModelType.BAIDU_MODEL, t, z, h),
- ModelType.BAIDU_MODEL,
- lambda x, y, z: baidu_label(x, y, z),
- lambda x: baidu_process(x)),
- # 航道模型
- ModelType.CHANNEL_EMERGENCY_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.CHANNEL_EMERGENCY_MODEL, t, z, h),
- ModelType.CHANNEL_EMERGENCY_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)),
- # 河道检测模型
- ModelType.RIVER2_MODEL.value[1]: (
- lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.RIVER2_MODEL, t, z, h),
- ModelType.RIVER2_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: model_process(x)),
- # 城管模型
- ModelType.CITY_MANGEMENT_MODEL.value[1]: (
- lambda x, y, r, t, z, h: cityManagementModel(x, y, r, ModelType.CITY_MANGEMENT_MODEL, t, z, h),
- ModelType.CITY_MANGEMENT_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: detSeg_demo2(x)
- ),
- # 人员落水模型
- ModelType.DROWING_MODEL.value[1]: (
- lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.DROWING_MODEL, t, z, h),
- ModelType.DROWING_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: model_process(x)
- ),
- # 城市违章模型
- ModelType.NOPARKING_MODEL.value[1]: (
- lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.NOPARKING_MODEL, t, z, h),
- ModelType.NOPARKING_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: model_process(x)
- ),
- # 车辆违停模型
- ModelType.ILLPARKING_MODEL.value[1]: (
- lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.ILLPARKING_MODEL, t, z, h),
- ModelType.ILLPARKING_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: model_process(x)
- ),
- # 城市公路模型
- ModelType.CITYROAD_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.CITYROAD_MODEL, t, z, h),
- ModelType.CITYROAD_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)),
- # 加载坑槽模型
- ModelType.POTHOLE_MODEL.value[1]: (
- lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.POTHOLE_MODEL, t, z, h),
- ModelType.POTHOLE_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: forest_process(x)
- ),
- # 加载船只综合检测模型
- ModelType.CHANNEL2_MODEL.value[1]: (
- lambda x, y, r, t, z, h: MultiModel(x, y, r, ModelType.CHANNEL2_MODEL, t, z, h),
- ModelType.CHANNEL2_MODEL,
- lambda x, y, z: dynamics_label(x, y, z),
- lambda x: channel2_process(x)
- ),
- # 河道检测模型
- ModelType.RIVERT_MODEL.value[1]: (
- lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.RIVERT_MODEL, t, z, h),
- ModelType.RIVERT_MODEL,
- lambda x, y, z: one_label(x, y, z),
- lambda x: model_process(x)),
- }
|