打架斗殴模型集成
This commit is contained in:
@@ -109,6 +109,15 @@ class ModelService:
|
||||
'size': '200MB',
|
||||
'description': '基于PaddlePaddle PP-YOLOE-l的违停检测模型,支持车牌识别',
|
||||
'name': '违停检测 (Paddle)'
|
||||
},
|
||||
'action_detection': {
|
||||
'path': 'docker_api',
|
||||
'type': 'docker_api',
|
||||
'classes': ['fight', 'normal'],
|
||||
'labels': {'fight': '打架', 'normal': '正常'},
|
||||
'size': 'Docker',
|
||||
'description': '基于PaddleVideo ppTSM的打架检测模型(通过Docker API调用)',
|
||||
'name': '打架检测 (Docker)'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +126,12 @@ class ModelService:
|
||||
for model_id, config in self.model_configs.items():
|
||||
model_path = config['path']
|
||||
|
||||
# 检查模型是否存在(Paddle模型检查目录,YOLO模型检查文件)
|
||||
# 检查模型是否存在
|
||||
model_exists = False
|
||||
if config['type'] == 'paddle':
|
||||
if config['type'] == 'docker_api':
|
||||
# Docker API 类型的模型不需要检查文件,总是可用
|
||||
model_exists = True
|
||||
elif config['type'] == 'paddle':
|
||||
model_dir = os.path.dirname(model_path)
|
||||
required_files = ['model.pdmodel', 'model.pdiparams', 'infer_cfg.yml']
|
||||
model_exists = all(
|
||||
@@ -153,6 +165,24 @@ class ModelService:
|
||||
|
||||
config = self.model_configs[model_id]
|
||||
|
||||
# 处理 Docker API 模型
|
||||
if config['type'] == 'docker_api':
|
||||
try:
|
||||
if model_id == 'action_detection':
|
||||
from .action_detection_service import ActionDetectionModel
|
||||
logger.info(f"正在加载 Docker API 行为识别服务: {model_id}")
|
||||
model = ActionDetectionModel()
|
||||
else:
|
||||
logger.error(f"未知的 Docker API 模型类型: {model_id}")
|
||||
return None
|
||||
|
||||
self.models[model_id] = model
|
||||
logger.info(f"Docker API 服务加载成功: {model_id}")
|
||||
return model
|
||||
except Exception as e:
|
||||
logger.error(f"Docker API 服务加载失败: {model_id}, 错误: {e}")
|
||||
return None
|
||||
|
||||
# 处理 PaddleDetection 模型
|
||||
if config['type'] == 'paddle':
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user