feat: 配置写死与 baked 模块,Alembic 建表,百度仅 BAIDU_*

- 新增 app/baked/algorithm|pipeline,非部署参数不再走 env;Settings 保留 DB/HTTP/RTSP/海康/百度/MinIO/Demo
- 移除 init_db_schema 与 reload 配置;main 仅 check_database;start*.sh 在 uvicorn 前执行 alembic upgrade head
- 依赖 psycopg[binary] 供 Alembic 同步 URL;alembic/env 注释与预发清单更新
- 撕段门控消费管线、各视频/语音/归档调用改为 baked
- 百度环境变量仅 BAIDU_APP_ID、BAIDU_API_KEY、BAIDU_SECRET_KEY 与 BAIDU_* 超时/ASR;人脸脚本与 baidu_speech 文案同步
- 全量单测与 .env.example 更新;.gitignore 忽略 refs/(本地权重/视频不入库)

Made-with: Cursor
This commit is contained in:
Kevin
2026-04-24 15:33:22 +08:00
parent b651364877
commit 8a4bad99d3
47 changed files with 1333 additions and 648 deletions

View File

@@ -0,0 +1,47 @@
"""与离线 demo main.py 同结构的段级文本报告(可选落盘)。"""
from __future__ import annotations
from pathlib import Path
from app.services.tear_gated_segment_consumption.runner import TearGatedSegmentRecord
def write_tear_segment_txt(
*,
path: Path,
surgery_id: str,
camera_id: str,
labels_source: str,
records: list[TearGatedSegmentRecord],
) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
lines: list[str] = []
lines.append("耗材消耗推断(撕段模式 / FastAPI")
lines.append(f"手术: {surgery_id} camera: {camera_id}")
lines.append(f"类名→label_id YAML: {labels_source}")
lines.append(
"说明: 人手检测 -> 撕二分类 -> 好帧门控(坏帧不判耗材) -> 41 类; "
"段内为概率向量平均; 众数作展示对照"
)
lines.append("")
for rec in records:
line = "\t".join(
[
f"{rec.segment_index}",
f"时间戳(秒)={rec.mid_stream_sec:.3f};范围={rec.start_sec:.2f}~{rec.end_sec:.2f}",
f"物品id={rec.item_id}",
f"物品名称(模型top1)={rec.item_name}",
f"top1置信度(段内平均)={rec.top1_conf:.4f}",
f"top2={rec.top2_name}",
f"top2_conf={rec.top2_conf:.4f}",
f"top3={rec.top3_name}",
f"top3_conf={rec.top3_conf:.4f}",
f"段内众数(参考)={rec.majority_ref}",
f"消耗数量=1",
f"医生id=暂无",
]
)
lines.append(line)
lines.append("")
path.write_text("\n".join(lines) + "\n", encoding="utf-8")