You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

595 lines
27KB

  1. # -*- coding: utf-8 -*-
  2. import sys
  3. from pickle import dumps, loads
  4. from traceback import format_exc
  5. import time
  6. import cv2
  7. from loguru import logger
  8. from common.Constant import COLOR
  9. from enums.BaiduSdkEnum import VehicleEnum
  10. from enums.ExceptionEnum import ExceptionType
  11. from enums.ModelTypeEnum import ModelType, BAIDU_MODEL_TARGET_CONFIG
  12. from exception.CustomerException import ServiceException
  13. from util.ImgBaiduSdk import AipBodyAnalysisClient, AipImageClassifyClient
  14. from util.PlotsUtils import get_label_arrays, get_label_array_dict
  15. from util.TorchUtils import select_device
  16. sys.path.extend(['..', '../AIlib2'])
  17. from AI import AI_process, AI_process_forest, get_postProcess_para, ocr_process, AI_process_N, AI_process_C
  18. from stdc import stdcModel
  19. from segutils.segmodel import SegModel
  20. from models.experimental import attempt_load
  21. from obbUtils.shipUtils import OBB_infer
  22. from obbUtils.load_obb_model import load_model_decoder_OBB
  23. import torch
  24. import tensorrt as trt
  25. from utilsK.jkmUtils import pre_process, post_process, get_return_data
  26. from DMPR import DMPRModel
  27. FONT_PATH = "../AIlib2/conf/platech.ttf"
  28. # 河道模型、河道检测模型、交通模型、人员落水模型、城市违章公共模型
  29. class OneModel:
  30. __slots__ = "model_conf"
  31. def __init__(self, device, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None, env=None):
  32. try:
  33. logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
  34. requestId)
  35. par = modeType.value[4](str(device), gpu_name)
  36. mode, postPar, segPar = par.get('mode', 'others'), par.get('postPar'), par.get('segPar')
  37. names = par['labelnames']
  38. postFile = par['postFile']
  39. rainbows = postFile["rainbows"]
  40. new_device = select_device(par.get('device'))
  41. half = new_device.type != 'cpu'
  42. Detweights = par['Detweights']
  43. with open(Detweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
  44. model = runtime.deserialize_cuda_engine(f.read())
  45. par['segPar']['seg_nclass'] = par['seg_nclass']
  46. Segweights = par['Segweights']
  47. if Segweights:
  48. if modeType.value[3] == 'cityMangement3':
  49. segmodel = DMPRModel(weights=Segweights, par=par['segPar'])
  50. else:
  51. segmodel = stdcModel(weights=Segweights, par=par['segPar'])
  52. else:
  53. segmodel = None
  54. objectPar = {
  55. 'half': half,
  56. 'device': new_device,
  57. 'conf_thres': postFile["conf_thres"],
  58. 'ovlap_thres_crossCategory': postFile.get("ovlap_thres_crossCategory"),
  59. 'iou_thres': postFile["iou_thres"],
  60. 'allowedList': [],
  61. 'segRegionCnt': par['segRegionCnt'],
  62. 'trtFlag_det': par['trtFlag_det'],
  63. 'trtFlag_seg': par['trtFlag_seg']
  64. }
  65. model_param = {
  66. "model": model,
  67. "segmodel": segmodel,
  68. "objectPar": objectPar,
  69. "segPar": segPar,
  70. "mode": mode,
  71. "postPar": postPar
  72. }
  73. self.model_conf = (modeType, model_param, allowedList, names, rainbows)
  74. except Exception:
  75. logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
  76. raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
  77. ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
  78. class cityManagementModel:
  79. __slots__ = "model_conf"
  80. def __init__(self, device, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None, env=None):
  81. try:
  82. logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
  83. requestId)
  84. par = modeType.value[4](str(device), gpu_name)
  85. postProcess = par['postProcess']
  86. names = par['labelnames']
  87. postFile = par['postFile']
  88. rainbows = postFile["rainbows"]
  89. modelList=[ modelPar['model'](weights=modelPar['weight'],par=modelPar['par']) for modelPar in par['models'] ]
  90. model_param = {
  91. "modelList": modelList,
  92. "postProcess": postProcess,
  93. }
  94. self.model_conf = (modeType, model_param, allowedList, names, rainbows)
  95. except Exception:
  96. logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
  97. raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
  98. ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
  99. def detSeg_demo2(args):
  100. model_conf, frame, request_id = args
  101. modelList, postProcess = model_conf[1]['modelList'], model_conf[1]['postProcess']
  102. try:
  103. return AI_process_N([frame], modelList, postProcess)
  104. except ServiceException as s:
  105. raise s
  106. except Exception:
  107. # self.num += 1
  108. # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
  109. logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
  110. raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
  111. ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
  112. def model_process(args):
  113. model_conf, frame, request_id = args
  114. model_param, names, rainbows = model_conf[1], model_conf[3], model_conf[4]
  115. # modeType, model_param, allowedList, names, rainbows = model_conf
  116. # segmodel, names, label_arraylist, rainbows, objectPar, font, segPar, mode, postPar, requestId = args
  117. # model_param['digitFont'] = digitFont
  118. # model_param['label_arraylist'] = label_arraylist
  119. # model_param['font_config'] = font_config
  120. try:
  121. return AI_process([frame], model_param['model'], model_param['segmodel'], names, model_param['label_arraylist'],
  122. rainbows, objectPar=model_param['objectPar'], font=model_param['digitFont'],
  123. segPar=loads(dumps(model_param['segPar'])), mode=model_param['mode'],
  124. postPar=model_param['postPar'])
  125. except ServiceException as s:
  126. raise s
  127. except Exception:
  128. # self.num += 1
  129. # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
  130. logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
  131. raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
  132. ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
  133. # 森林模型、车辆模型、行人模型、烟火模型、 钓鱼模型、航道模型、乡村模型、城管模型公共模型
  134. class TwoModel:
  135. __slots__ = "model_conf"
  136. def __init__(self, device1, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
  137. env=None):
  138. s = time.time()
  139. try:
  140. logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
  141. requestId)
  142. par = modeType.value[4](str(device1), gpu_name)
  143. device = select_device(par.get('device'))
  144. names = par['labelnames']
  145. half = device.type != 'cpu'
  146. Detweights = par['Detweights']
  147. with open(Detweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
  148. model = runtime.deserialize_cuda_engine(f.read())
  149. segmodel = None
  150. postFile = par['postFile']
  151. conf_thres = postFile["conf_thres"]
  152. iou_thres = postFile["iou_thres"]
  153. rainbows = postFile["rainbows"]
  154. otc = postFile.get("ovlap_thres_crossCategory")
  155. model_param = {
  156. "model": model,
  157. "segmodel": segmodel,
  158. "half": half,
  159. "device": device,
  160. "conf_thres": conf_thres,
  161. "iou_thres": iou_thres,
  162. "trtFlag_det": par['trtFlag_det'],
  163. "otc": otc
  164. }
  165. self.model_conf = (modeType, model_param, allowedList, names, rainbows)
  166. except Exception:
  167. logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
  168. raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
  169. ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
  170. logger.info("模型初始化时间:{}, requestId:{}", time.time() - s, requestId)
  171. def forest_process(args):
  172. model_conf, frame, request_id = args
  173. model_param, names, rainbows = model_conf[1], model_conf[3], model_conf[4]
  174. try:
  175. return AI_process_forest([frame], model_param['model'], model_param['segmodel'], names,
  176. model_param['label_arraylist'], rainbows, model_param['half'], model_param['device'],
  177. model_param['conf_thres'], model_param['iou_thres'], [], font=model_param['digitFont'],
  178. trtFlag_det=model_param['trtFlag_det'], SecNms=model_param['otc'])
  179. except ServiceException as s:
  180. raise s
  181. except Exception:
  182. # self.num += 1
  183. # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
  184. logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
  185. raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
  186. ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
  187. class MultiModel:
  188. __slots__ = "model_conf"
  189. def __init__(self, device1, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
  190. env=None):
  191. s = time.time()
  192. try:
  193. logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
  194. requestId)
  195. par = modeType.value[4](str(device1), gpu_name)
  196. postProcess = par['postProcess']
  197. names = par['labelnames']
  198. postFile = par['postFile']
  199. rainbows = postFile["rainbows"]
  200. modelList=[ modelPar['model'](weights=modelPar['weight'],par=modelPar['par']) for modelPar in par['models'] ]
  201. model_param = {
  202. "modelList": modelList,
  203. "postProcess": postProcess,
  204. }
  205. self.model_conf = (modeType, model_param, allowedList, names, rainbows)
  206. except Exception:
  207. logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
  208. raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
  209. ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
  210. logger.info("模型初始化时间:{}, requestId:{}", time.time() - s, requestId)
  211. def channel2_process(args):
  212. model_conf, frame, request_id = args
  213. modelList, postProcess = model_conf[1]['modelList'], model_conf[1]['postProcess']
  214. try:
  215. start = time.time()
  216. result = [[None, None, AI_process_C([frame], modelList, postProcess)[0]]] # 为了让返回值适配统一的接口而写的shi
  217. # print("AI_process_C use time = {}".format(time.time()-start))
  218. return result
  219. except ServiceException as s:
  220. raise s
  221. except Exception:
  222. logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
  223. raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
  224. ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
  225. def get_label_arraylist(*args):
  226. width, height, names, rainbows = args
  227. # line = int(round(0.002 * (height + width) / 2) + 1)
  228. line = max(1, int(round(width / 1920 * 3)))
  229. label = ' 0.95'
  230. tf = max(line - 1, 1)
  231. fontScale = line * 0.33
  232. text_width, text_height = cv2.getTextSize(label, 0, fontScale=fontScale, thickness=tf)[0]
  233. # fontsize = int(width / 1920 * 40)
  234. numFontSize = float(format(width / 1920 * 1.1, '.1f'))
  235. digitFont = {'line_thickness': line,
  236. 'boxLine_thickness': line,
  237. 'fontSize': numFontSize,
  238. 'waterLineColor': (0, 255, 255),
  239. 'segLineShow': False,
  240. 'waterLineWidth': line,
  241. 'wordSize': text_height,
  242. 'label_location': 'leftTop'}
  243. label_arraylist = get_label_arrays(names, rainbows, fontSize=text_height, fontPath=FONT_PATH)
  244. return digitFont, label_arraylist, (line, text_width, text_height, fontScale, tf)
  245. # 船只模型
  246. class ShipModel:
  247. __slots__ = "model_conf"
  248. def __init__(self, device1, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
  249. env=None):
  250. s = time.time()
  251. try:
  252. logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
  253. requestId)
  254. par = modeType.value[4](str(device1), gpu_name)
  255. model, decoder2 = load_model_decoder_OBB(par)
  256. par['decoder'] = decoder2
  257. names = par['labelnames']
  258. rainbows = par['postFile']["rainbows"]
  259. model_param = {
  260. "model": model,
  261. "par": par
  262. }
  263. self.model_conf = (modeType, model_param, allowedList, names, rainbows)
  264. except Exception:
  265. logger.exception("模型加载异常:{}, requestId:{}", format_exc(), requestId)
  266. raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
  267. ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
  268. logger.info("模型初始化时间:{}, requestId:{}", time.time() - s, requestId)
  269. def obb_process(args):
  270. model_conf, frame, request_id = args
  271. model_param = model_conf[1]
  272. # font_config, frame, names, label_arrays, rainbows, model, par, requestId = args
  273. try:
  274. return OBB_infer(model_param["model"], frame, model_param["par"])
  275. except ServiceException as s:
  276. raise s
  277. except Exception:
  278. # self.num += 1
  279. # cv2.imwrite('/home/th/tuo_heng/dev/img%s.jpg' % str(self.num), frame)
  280. logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
  281. raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
  282. ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
  283. # 车牌分割模型、健康码、行程码分割模型
  284. class IMModel:
  285. __slots__ = "model_conf"
  286. def __init__(self, device, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
  287. env=None):
  288. try:
  289. logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
  290. requestId)
  291. img_type = 'code'
  292. if ModelType.PLATE_MODEL == modeType:
  293. img_type = 'plate'
  294. par = {
  295. 'code': {'weights': '../AIlib2/weights/conf/jkm/health_yolov5s_v3.jit', 'img_type': 'code', 'nc': 10},
  296. 'plate': {'weights': '../AIlib2/weights/conf/jkm/plate_yolov5s_v3.jit', 'img_type': 'plate', 'nc': 1},
  297. 'conf_thres': 0.4,
  298. 'iou_thres': 0.45,
  299. 'device': 'cuda:%s' % device,
  300. 'plate_dilate': (0.5, 0.3)
  301. }
  302. new_device = torch.device(par['device'])
  303. model = torch.jit.load(par[img_type]['weights'])
  304. self.model_conf = (modeType, allowedList, new_device, model, par, img_type)
  305. except Exception:
  306. logger.error("模型加载异常:{}, requestId:{}", format_exc(), requestId)
  307. raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
  308. ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
  309. def im_process(args):
  310. frame, device, model, par, img_type, requestId = args
  311. try:
  312. img, padInfos = pre_process(frame, device)
  313. pred = model(img)
  314. boxes = post_process(pred, padInfos, device, conf_thres=par['conf_thres'],
  315. iou_thres=par['iou_thres'], nc=par[img_type]['nc']) # 后处理
  316. dataBack = get_return_data(frame, boxes, modelType=img_type, plate_dilate=par['plate_dilate'])
  317. return dataBack
  318. except ServiceException as s:
  319. raise s
  320. except Exception:
  321. logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), requestId)
  322. raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
  323. ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
  324. # 百度AI图片识别模型
  325. class BaiduAiImageModel:
  326. __slots__ = "model_conf"
  327. def __init__(self, device=None, allowedList=None, requestId=None, modeType=None, gpu_name=None, base_dir=None,
  328. env=None):
  329. try:
  330. logger.info("########################加载{}########################, requestId:{}", modeType.value[2],
  331. requestId)
  332. # 人体检测与属性识别、 人流量统计客户端
  333. aipBodyAnalysisClient = AipBodyAnalysisClient(base_dir, env)
  334. # 车辆检测检测客户端
  335. aipImageClassifyClient = AipImageClassifyClient(base_dir, env)
  336. rainbows = COLOR
  337. vehicle_names = [VehicleEnum.CAR.value[1], VehicleEnum.TRICYCLE.value[1], VehicleEnum.MOTORBIKE.value[1],
  338. VehicleEnum.CARPLATE.value[1], VehicleEnum.TRUCK.value[1], VehicleEnum.BUS.value[1]]
  339. person_names = ['人']
  340. self.model_conf = (modeType, aipImageClassifyClient, aipBodyAnalysisClient, allowedList, rainbows,
  341. vehicle_names, person_names, requestId)
  342. except Exception:
  343. logger.exception("模型加载异常:{}, requestId:{}", format_exc(), requestId)
  344. raise ServiceException(ExceptionType.MODEL_LOADING_EXCEPTION.value[0],
  345. ExceptionType.MODEL_LOADING_EXCEPTION.value[1])
  346. def get_baidu_label_arraylist(*args):
  347. width, height, vehicle_names, person_names, rainbows = args
  348. # line = int(round(0.002 * (height + width) / 2) + 1)
  349. line = max(1, int(round(width / 1920 * 3) + 1))
  350. label = ' 0.97'
  351. tf = max(line, 1)
  352. fontScale = line * 0.33
  353. text_width, text_height = cv2.getTextSize(label, 0, fontScale=fontScale, thickness=tf)[0]
  354. vehicle_label_arrays = get_label_arrays(vehicle_names, rainbows, fontSize=text_height, fontPath=FONT_PATH)
  355. person_label_arrays = get_label_arrays(person_names, rainbows, fontSize=text_height, fontPath=FONT_PATH)
  356. font_config = (line, text_width, text_height, fontScale, tf)
  357. return vehicle_label_arrays, person_label_arrays, font_config
  358. def baidu_process(args):
  359. target, url, aipImageClassifyClient, aipBodyAnalysisClient, request_id = args
  360. try:
  361. # [target, url, aipImageClassifyClient, aipBodyAnalysisClient, requestId]
  362. baiduEnum = BAIDU_MODEL_TARGET_CONFIG.get(target)
  363. if baiduEnum is None:
  364. raise ServiceException(ExceptionType.DETECTION_TARGET_TYPES_ARE_NOT_SUPPORTED.value[0],
  365. ExceptionType.DETECTION_TARGET_TYPES_ARE_NOT_SUPPORTED.value[1]
  366. + " target: " + target)
  367. return baiduEnum.value[2](aipImageClassifyClient, aipBodyAnalysisClient, url, request_id)
  368. except ServiceException as s:
  369. raise s
  370. except Exception:
  371. logger.error("算法模型分析异常:{}, requestId:{}", format_exc(), request_id)
  372. raise ServiceException(ExceptionType.MODEL_ANALYSE_EXCEPTION.value[0],
  373. ExceptionType.MODEL_ANALYSE_EXCEPTION.value[1])
  374. def one_label(width, height, model_conf):
  375. # modeType, model_param, allowedList, names, rainbows = model_conf
  376. names = model_conf[3]
  377. rainbows = model_conf[4]
  378. model_param = model_conf[1]
  379. digitFont, label_arraylist, font_config = get_label_arraylist(width, height, names, rainbows)
  380. model_param['digitFont'] = digitFont
  381. model_param['label_arraylist'] = label_arraylist
  382. model_param['font_config'] = font_config
  383. def dynamics_label(width, height, model_conf):
  384. # modeType, model_param, allowedList, names, rainbows = model_conf
  385. names = model_conf[3]
  386. rainbows = model_conf[4]
  387. model_param = model_conf[1]
  388. digitFont, label_arraylist, font_config = get_label_arraylist(width, height, names, rainbows)
  389. line = max(1, int(round(width / 1920 * 3)))
  390. label = ' 0.95'
  391. tf = max(line - 1, 1)
  392. fontScale = line * 0.33
  393. _, text_height = cv2.getTextSize(label, 0, fontScale=fontScale, thickness=tf)[0]
  394. label_dict = get_label_array_dict(rainbows, fontSize=text_height, fontPath=FONT_PATH)
  395. model_param['digitFont'] = digitFont
  396. model_param['label_arraylist'] = label_arraylist
  397. model_param['font_config'] = font_config
  398. model_param['label_dict'] = label_dict
  399. def baidu_label(width, height, model_conf):
  400. # modeType, aipImageClassifyClient, aipBodyAnalysisClient, allowedList, rainbows,
  401. # vehicle_names, person_names, requestId
  402. vehicle_names = model_conf[5]
  403. person_names = model_conf[6]
  404. rainbows = model_conf[4]
  405. vehicle_label_arrays, person_label_arrays, font_config = get_baidu_label_arraylist(width, height, vehicle_names,
  406. person_names, rainbows)
  407. return vehicle_label_arrays, person_label_arrays, font_config
  408. MODEL_CONFIG = {
  409. # 加载河道模型
  410. ModelType.WATER_SURFACE_MODEL.value[1]: (
  411. lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.WATER_SURFACE_MODEL, t, z, h),
  412. ModelType.WATER_SURFACE_MODEL,
  413. lambda x, y, z: one_label(x, y, z),
  414. lambda x: model_process(x)
  415. ),
  416. # 加载森林模型
  417. ModelType.FOREST_FARM_MODEL.value[1]: (
  418. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.FOREST_FARM_MODEL, t, z, h),
  419. ModelType.FOREST_FARM_MODEL,
  420. lambda x, y, z: one_label(x, y, z),
  421. lambda x: forest_process(x)
  422. ),
  423. # 加载交通模型
  424. ModelType.TRAFFIC_FARM_MODEL.value[1]: (
  425. lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.TRAFFIC_FARM_MODEL, t, z, h),
  426. ModelType.TRAFFIC_FARM_MODEL,
  427. lambda x, y, z: one_label(x, y, z),
  428. lambda x: model_process(x)
  429. ),
  430. # 加载防疫模型
  431. ModelType.EPIDEMIC_PREVENTION_MODEL.value[1]: (
  432. lambda x, y, r, t, z, h: IMModel(x, y, r, ModelType.EPIDEMIC_PREVENTION_MODEL, t, z, h),
  433. ModelType.EPIDEMIC_PREVENTION_MODEL,
  434. None,
  435. lambda x: im_process(x)),
  436. # 加载车牌模型
  437. ModelType.PLATE_MODEL.value[1]: (
  438. lambda x, y, r, t, z, h: IMModel(x, y, r, ModelType.PLATE_MODEL, t, z, h),
  439. ModelType.PLATE_MODEL,
  440. None,
  441. lambda x: im_process(x)),
  442. # 加载车辆模型
  443. ModelType.VEHICLE_MODEL.value[1]: (
  444. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.VEHICLE_MODEL, t, z, h),
  445. ModelType.VEHICLE_MODEL,
  446. lambda x, y, z: one_label(x, y, z),
  447. lambda x: forest_process(x)
  448. ),
  449. # 加载行人模型
  450. ModelType.PEDESTRIAN_MODEL.value[1]: (
  451. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.PEDESTRIAN_MODEL, t, z, h),
  452. ModelType.PEDESTRIAN_MODEL,
  453. lambda x, y, z: one_label(x, y, z),
  454. lambda x: forest_process(x)),
  455. # 加载烟火模型
  456. ModelType.SMOGFIRE_MODEL.value[1]: (
  457. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.SMOGFIRE_MODEL, t, z, h),
  458. ModelType.SMOGFIRE_MODEL,
  459. lambda x, y, z: one_label(x, y, z),
  460. lambda x: forest_process(x)),
  461. # 加载钓鱼游泳模型
  462. ModelType.ANGLERSWIMMER_MODEL.value[1]: (
  463. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.ANGLERSWIMMER_MODEL, t, z, h),
  464. ModelType.ANGLERSWIMMER_MODEL,
  465. lambda x, y, z: one_label(x, y, z),
  466. lambda x: forest_process(x)),
  467. # 加载乡村模型
  468. ModelType.COUNTRYROAD_MODEL.value[1]: (
  469. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.COUNTRYROAD_MODEL, t, z, h),
  470. ModelType.COUNTRYROAD_MODEL,
  471. lambda x, y, z: one_label(x, y, z),
  472. lambda x: forest_process(x)),
  473. # 加载船只模型
  474. ModelType.SHIP_MODEL.value[1]: (
  475. lambda x, y, r, t, z, h: ShipModel(x, y, r, ModelType.SHIP_MODEL, t, z, h),
  476. ModelType.SHIP_MODEL,
  477. lambda x, y, z: one_label(x, y, z),
  478. lambda x: obb_process(x)),
  479. # 百度AI图片识别模型
  480. ModelType.BAIDU_MODEL.value[1]: (
  481. lambda x, y, r, t, z, h: BaiduAiImageModel(x, y, r, ModelType.BAIDU_MODEL, t, z, h),
  482. ModelType.BAIDU_MODEL,
  483. lambda x, y, z: baidu_label(x, y, z),
  484. lambda x: baidu_process(x)),
  485. # 航道模型
  486. ModelType.CHANNEL_EMERGENCY_MODEL.value[1]: (
  487. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.CHANNEL_EMERGENCY_MODEL, t, z, h),
  488. ModelType.CHANNEL_EMERGENCY_MODEL,
  489. lambda x, y, z: one_label(x, y, z),
  490. lambda x: forest_process(x)),
  491. # 河道检测模型
  492. ModelType.RIVER2_MODEL.value[1]: (
  493. lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.RIVER2_MODEL, t, z, h),
  494. ModelType.RIVER2_MODEL,
  495. lambda x, y, z: one_label(x, y, z),
  496. lambda x: model_process(x)),
  497. # 城管模型
  498. ModelType.CITY_MANGEMENT_MODEL.value[1]: (
  499. lambda x, y, r, t, z, h: cityManagementModel(x, y, r, ModelType.CITY_MANGEMENT_MODEL, t, z, h),
  500. ModelType.CITY_MANGEMENT_MODEL,
  501. lambda x, y, z: one_label(x, y, z),
  502. lambda x: detSeg_demo2(x)
  503. ),
  504. # 人员落水模型
  505. ModelType.DROWING_MODEL.value[1]: (
  506. lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.DROWING_MODEL, t, z, h),
  507. ModelType.DROWING_MODEL,
  508. lambda x, y, z: one_label(x, y, z),
  509. lambda x: model_process(x)
  510. ),
  511. # 城市违章模型
  512. ModelType.NOPARKING_MODEL.value[1]: (
  513. lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.NOPARKING_MODEL, t, z, h),
  514. ModelType.NOPARKING_MODEL,
  515. lambda x, y, z: one_label(x, y, z),
  516. lambda x: model_process(x)
  517. ),
  518. # 车辆违停模型
  519. ModelType.ILLPARKING_MODEL.value[1]: (
  520. lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.ILLPARKING_MODEL, t, z, h),
  521. ModelType.ILLPARKING_MODEL,
  522. lambda x, y, z: one_label(x, y, z),
  523. lambda x: model_process(x)
  524. ),
  525. # 城市公路模型
  526. ModelType.CITYROAD_MODEL.value[1]: (
  527. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.CITYROAD_MODEL, t, z, h),
  528. ModelType.CITYROAD_MODEL,
  529. lambda x, y, z: one_label(x, y, z),
  530. lambda x: forest_process(x)),
  531. # 加载坑槽模型
  532. ModelType.POTHOLE_MODEL.value[1]: (
  533. lambda x, y, r, t, z, h: TwoModel(x, y, r, ModelType.POTHOLE_MODEL, t, z, h),
  534. ModelType.POTHOLE_MODEL,
  535. lambda x, y, z: one_label(x, y, z),
  536. lambda x: forest_process(x)
  537. ),
  538. # 加载船只综合检测模型
  539. ModelType.CHANNEL2_MODEL.value[1]: (
  540. lambda x, y, r, t, z, h: MultiModel(x, y, r, ModelType.CHANNEL2_MODEL, t, z, h),
  541. ModelType.CHANNEL2_MODEL,
  542. lambda x, y, z: dynamics_label(x, y, z),
  543. lambda x: channel2_process(x)
  544. ),
  545. # 河道检测模型
  546. ModelType.RIVERT_MODEL.value[1]: (
  547. lambda x, y, r, t, z, h: OneModel(x, y, r, ModelType.RIVERT_MODEL, t, z, h),
  548. ModelType.RIVERT_MODEL,
  549. lambda x, y, z: one_label(x, y, z),
  550. lambda x: model_process(x)),
  551. }