| | |
| | | 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", |
| | | "detect_id","knowledge_id", |
| | | "detect_time", "image_path", "image_desc_path", "video_path"], |
| | | consistency_level="Strong", |
| | | order_by_field="id", # 按id字段排序 |
| | |
| | | if len(res_a) > 0: |
| | | sorted_results = sorted(res_a, key=itemgetter("id"), reverse=True) |
| | | # 查询前N个最大的ID |
| | | res_a = sorted_results[:int(self.config.get("detectnum"))-1] |
| | | res_a = sorted_results[:int(self.config.get("detectnum"))] |
| | | res_data = [] |
| | | for res in res_a: |
| | | data = { |
| | |
| | | "image_path": res['image_path'], # image_path |
| | | "image_desc_path": res['image_desc_path'], # image_desc_path |
| | | "video_path": res['video_path'], |
| | | "text_vector": res['text_vector'] |
| | | "text_vector": res['text_vector'], |
| | | "knowledge_id": res['knowledge_id'] |
| | | } |
| | | # logging.info(f"读取图像成功: {res['id']}") |
| | | # 保存到milvus |
| | | image_id = self.collection.upsert(data).primary_keys |
| | | res['id'] = image_id[0] |
| | | res_data.append(res) |
| | | # logging.info(f"读取图像成功: {image_id}") |
| | | self.pool.submit(res_data) |
| | | # 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}") |