AI实验室后端
This commit is contained in:
@@ -5,10 +5,13 @@ import config.minIO as minIO
|
||||
import db.postgres as pg
|
||||
from agent.licenseImageAgent import get_license_response
|
||||
from agent.vehicleImageAgent import get_vehicle_response
|
||||
from config.minIO import minio_client
|
||||
from config.minIO import minio_client, get_temp_url
|
||||
from config.yolo import YOLOSingleton
|
||||
from db.postgres import get_dept_id_by_iot_user_name, get_dept_ids_by_dept_id
|
||||
from db.postgres.sentinel import update_sentinel_record
|
||||
from db.postgres import (
|
||||
get_dept_id_by_iot_user_name,
|
||||
get_dept_ids_by_dept_id,
|
||||
)
|
||||
from db.postgres.sentinel import update_sentinel_record, get_sentinel_record_by_id
|
||||
from llm.ticketLLM import *
|
||||
from llm.ticketLLMv2 import get_ticket_response_v2
|
||||
from models.SentinelRecordRequest import SentinelRecordRequest
|
||||
@@ -173,7 +176,7 @@ def process_silkworm_cocoon_image(
|
||||
)
|
||||
return {
|
||||
"resolution": resolution,
|
||||
"size": size_kb,
|
||||
"size": size_kb / 1024,
|
||||
"cocoon_count": results_json.get("total_objects"),
|
||||
"max_confidence": results_json.get("max_confidence"),
|
||||
"min_confidence": results_json.get("min_confidence"),
|
||||
@@ -182,6 +185,7 @@ def process_silkworm_cocoon_image(
|
||||
"inference_time_ms": speed_json.get("inference"),
|
||||
"postprocess_time_ms": speed_json.get("postprocess"),
|
||||
"details": results_json.get("class_counts"),
|
||||
"imageUrl": get_temp_url(bucket_name, "ai/" + after_object_name),
|
||||
}
|
||||
|
||||
|
||||
@@ -190,14 +194,18 @@ async def process_vehicle_animal_image(
|
||||
):
|
||||
# 通过设备id获得组织id
|
||||
dept_id = get_dept_id_by_iot_user_name(data.DeviceId)
|
||||
|
||||
# 得到动物类型
|
||||
oss_url = minIO.get_temp_url("sentinel", "vehicle_image/" + data.VehicleImage)
|
||||
analysis_result = await get_vehicle_response(oss_url)
|
||||
livestock_type = analysis_result.get("livestock_type", "")
|
||||
remark = analysis_result.get("remark", "")
|
||||
|
||||
# 保存到数据库
|
||||
update_sentinel_record(data.Id, livestock_type, remark, dept_id)
|
||||
# 可以通知的部门ids
|
||||
available_departments = get_dept_ids_by_dept_id(dept_id)
|
||||
|
||||
# 通知控制界面
|
||||
await ws_manager.noticeSentinel(
|
||||
{
|
||||
"content": f"载有{livestock_type}的车辆即将进入关卡,请准备检查",
|
||||
@@ -205,5 +213,11 @@ async def process_vehicle_animal_image(
|
||||
},
|
||||
available_departments,
|
||||
)
|
||||
# 保存到数据库
|
||||
return update_sentinel_record(data.Id, livestock_type, remark, dept_id)
|
||||
# 通知大屏界面
|
||||
await ws_manager.noticeSentinelMonitorStatus(
|
||||
{
|
||||
"content": get_sentinel_record_by_id(data.Id),
|
||||
"type": "vehicle_alert",
|
||||
},
|
||||
available_departments,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user