| | |
| | | from operator import itemgetter |
| | | import torch |
| | | import threading |
| | | import time as time_sel |
| | | from typing import Dict |
| | |
| | | import requests |
| | | import os |
| | | import logging |
| | | from transformers import AutoProcessor, AutoModelForVision2Seq |
| | | from pymilvus import connections, Collection |
| | | from logging.handlers import RotatingFileHandler |
| | | import get_mem |
| | |
| | | # 加载集合 |
| | | self.collection = Collection(name="smartobject") |
| | | self.collection.load() |
| | | self.pool = qwen_thread(int(self.config.get("threadnum")), self.config,self.config.get("qwenaddr")) |
| | | self.pool = qwen_thread(self.config) |
| | | #是否更新 |
| | | self._isupdate = False |
| | | |
| | |
| | | output_fields=["id", "zh_desc_class", "text_vector", "bounding_box", "video_point_name", "task_id", |
| | | "task_name", "event_level_id", "event_level_name", |
| | | "video_point_id", "detect_num", "is_waning", "is_desc", "waning_value", "rule_id", |
| | | "detect_id","knowledge_id", |
| | | "detect_id","knowledge_id","suggestion", |
| | | "detect_time", "image_path", "image_desc_path", "video_path"], |
| | | consistency_level="Strong", |
| | | order_by_field="id", # 按id字段排序 |
| | | order_by_type="desc" # 降序排列 |
| | | ) |
| | | |
| | | # 读取共享内存中的图片 |
| | | # image_id = get_mem.smem_read_frame_qianwen(camera_id) |
| | | if len(res_a) > 0: |
| | |
| | | "image_desc_path": res['image_desc_path'], # image_desc_path |
| | | "video_path": res['video_path'], |
| | | "text_vector": res['text_vector'], |
| | | "knowledge_id": res['knowledge_id'] |
| | | "knowledge_id": res['knowledge_id'], |
| | | "suggestion": res['suggestion'], |
| | | } |
| | | # logging.info(f"读取图像成功: {res['id']}") |
| | | # 保存到milvus |
| | | image_id = self.collection.upsert(data).primary_keys |
| | | res['id'] = image_id[0] |
| | | # logging.info(f"读取图像成功: {image_id}") |
| | | image_id = self.pool.submit(res) |
| | | # image_id = pool.tark_do(image_id,self.config.get("ragurl"),self.config.get("ragmode"),self.config.get("max_tokens")) |
| | | # logging.info(f"处理图像成功: {image_id}") |
| | | sorted_results = None |
| | | self.pool.submit(res) |
| | | except Exception as e: |
| | | logging.info(f"{camera_id}线程错误:{e}") |
| | | time_sel.sleep(0.01) |
| | | |
| | | #调用是否需要更新 |
| | | def isUpdate(self): |