@@ -148,12 +148,11 @@ def build_image_name(*args): | |||
class ImageTypeImageFileUpload(Thread): | |||
__slots__ = ('_fb_queue', '_context', '_image_queue', '_analyse_type', '_msg', 'ex') | |||
__slots__ = ('_fb_queue', '_context', '_image_queue', '_analyse_type', '_msg') | |||
def __init__(self, *args): | |||
super().__init__() | |||
self._fb_queue, self._context, self._msg, self._image_queue, self._analyse_type = args | |||
self.ex = None | |||
@staticmethod | |||
def handle_image(det_xywh, copy_frame, font_config): | |||
@@ -168,13 +167,10 @@ class ImageTypeImageFileUpload(Thread): | |||
""" | |||
model_info = [] | |||
# 更加模型编码解析数据 | |||
for code in list(det_xywh.keys()): | |||
# 模型编号下面的检测目标对象 | |||
det_info = det_xywh[code] | |||
if len(det_info) > 0: | |||
for cls in list(det_info.keys()): | |||
target_list = det_info.get(cls) | |||
if len(target_list) > 0: | |||
for code, det_info in det_xywh.items(): | |||
if det_info is not None and len(det_info) > 0: | |||
for cls, target_list in det_info.items(): | |||
if target_list is not None and len(target_list) > 0: | |||
aiFrame = copy_frame.copy() | |||
for target in target_list: | |||
draw_painting_joint(target[1], aiFrame, target[3], target[2], target[4], font_config) | |||
@@ -274,7 +270,6 @@ class ImageTypeImageFileUpload(Thread): | |||
sleep(1) | |||
except Exception as e: | |||
logger.error("图片上传异常:{}, requestId:{}", format_exc(), request_id) | |||
self.ex = e | |||
finally: | |||
clear_queue(image_queue) | |||
logger.info("停止图片识别图片上传线程, requestId:{}", request_id) |
@@ -3,6 +3,7 @@ import base64 | |||
import os | |||
from concurrent.futures import ThreadPoolExecutor | |||
from os.path import join, exists, getsize | |||
from profile import Profile | |||
from time import time, sleep | |||
from traceback import format_exc | |||
@@ -1054,8 +1055,6 @@ class PhotosIntelligentRecognitionProcess(Process): | |||
for r in task_list: | |||
r.result(60) | |||
if image_thread and not image_thread.is_alive(): | |||
if image_thread.ex: | |||
raise image_thread.ex | |||
raise Exception("图片识别图片上传线程异常停止!!!") | |||
if image_thread and image_thread.is_alive(): | |||
put_queue(image_queue, (2, 'stop'), timeout=2) |
@@ -461,13 +461,13 @@ class OfflineIntelligentRecognitionProcess2(IntelligentRecognitionProcess2): | |||
# (modeType, model_param, allowedList, names, rainbows) | |||
MODEL_CONFIG2[code][2](frame_list[0].shape[1], frame_list[0].shape[0], | |||
model_conf) | |||
if draw_config.get("font_config") is None: | |||
draw_config["font_config"] = model_param['font_config'] | |||
if draw_config.get(code) is None: | |||
draw_config[code] = {} | |||
draw_config[code]["allowedList"] = model_conf[2] | |||
draw_config[code]["rainbows"] = model_conf[4] | |||
draw_config[code]["label_arrays"] = model_param['label_arraylist'] | |||
if draw_config.get("font_config") is None: | |||
draw_config["font_config"] = model_param['font_config'] | |||
if draw_config.get(code) is None: | |||
draw_config[code] = {} | |||
draw_config[code]["allowedList"] = model_conf[2] | |||
draw_config[code]["rainbows"] = model_conf[4] | |||
draw_config[code]["label_arrays"] = model_param['label_arraylist'] | |||
# 多线程并发处理, 经过测试两个线程最优 | |||
det_array = [] | |||
for model in model_array: | |||
@@ -991,8 +991,6 @@ class PhotosIntelligentRecognitionProcess2(Process): | |||
for r in task_list: | |||
r.result(timeout=60) | |||
if image_thread and not image_thread.is_alive(): | |||
if image_thread.ex: | |||
raise image_thread.ex | |||
raise Exception("图片识别图片上传线程异常停止!!!") | |||
if image_thread and image_thread.is_alive(): | |||
put_queue(image_queue, (2, 'stop'), timeout=10, is_ex=True) |
@@ -8,7 +8,6 @@ from torch import multiprocessing | |||
from service.Dispatcher import DispatcherService | |||
from util.LogUtils import init_log | |||
''' | |||
dsp主程序入口 | |||
''' |