From e06f30d9225040ed4ec64c33ef08c411e4775bfb Mon Sep 17 00:00:00 2001
From: shidong <shidong@jhsoft.cc>
Date: 星期四, 10 七月 2025 20:11:54 +0800
Subject: [PATCH] #2025/7/10 #完善知识库部分,按配置的知识库从rag中获取数据;优化生成安全隐患和处理建议的提示语
---
qwen_detect.py | 17 ++++++-----------
1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/qwen_detect.py b/qwen_detect.py
index 6ade8ad..75249d0 100644
--- a/qwen_detect.py
+++ b/qwen_detect.py
@@ -1,5 +1,4 @@
from operator import itemgetter
-import torch
import threading
import time as time_sel
from typing import Dict
@@ -7,7 +6,6 @@
import requests
import os
import logging
-from transformers import AutoProcessor, AutoModelForVision2Seq
from pymilvus import connections, Collection
from logging.handlers import RotatingFileHandler
import get_mem
@@ -43,7 +41,7 @@
# 鍔犺浇闆嗗悎
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
@@ -96,13 +94,12 @@
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", # 鎸塱d瀛楁鎺掑簭
order_by_type="desc" # 闄嶅簭鎺掑垪
)
-
# 璇诲彇鍏变韩鍐呭瓨涓殑鍥剧墖
# image_id = get_mem.smem_read_frame_qianwen(camera_id)
if len(res_a) > 0:
@@ -132,19 +129,17 @@
"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']}")
# 淇濆瓨鍒癿ilvus
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):
--
Gitblit v1.8.0