qwen_detect.py
@@ -29,26 +29,8 @@
                    value = value.strip()
                    # 将键值对添加到字典中
                    self.config[key] = value
        # 配置日志
        # 确保日志目录存在
        log_dir = "logs"
        os.makedirs(log_dir, exist_ok=True)
        self.threads: Dict[str, threading.Thread] = {}
        self.lock = threading.Lock()
        # 初始化Milvus集合
        connections.connect("default", host=self.config.get("milvusurl"), port=self.config.get("milvusport"))
        # 加载集合
        self.collection = Collection(name="smartobject")
        self.collection.load()
        self.pool = qwen_thread(self.config)
        #是否更新
        self._isupdate = False
        # 初始化共享内存
        get_mem.smem_init()
        # 配置日志
        # 创建实例专属logger
        os.makedirs("logs", exist_ok=True)
        logging.basicConfig(
            level=logging.INFO,
            format='%(asctime)s - %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s: %(message)s',
@@ -56,7 +38,7 @@
            handlers=[
                # 按大小轮转的日志文件(最大10MB,保留3个备份)
                RotatingFileHandler(
                    filename=os.path.join(log_dir, 'start_log.log'),
                    filename=os.path.join("logs", 'qwen_log.log'),
                    maxBytes=10 * 1024 * 1024,  # 10MB
                    backupCount=3,
                    encoding='utf-8'
@@ -65,6 +47,26 @@
                logging.StreamHandler()
            ]
        )
        self.logger = logging.getLogger(f"{self.__class__}_{id(self)}")
        self.logger.setLevel(logging.INFO)
        self.threads: Dict[str, threading.Thread] = {}
        self.lock = threading.Lock()
        # 初始化Milvus集合
        connections.connect("default", host=self.config.get("milvusurl"), port=self.config.get("milvusport"))
        # 加载集合
        self.collection = Collection(name="smartobject")
        self.collection.load()
        #创建qwen线程池
        self.pool = qwen_thread(self.config,self.logger)
        #是否更新
        self._isupdate = False
        # 初始化共享内存
        get_mem.smem_init()
    #启动线程
    def safe_start(self, target_func, camera_id):