【AI 可读的低质图像检测项目工程蓝图】
(面向“不会编码”的项目负责人,可直接投喂给任何大模型或低代码平台,由其按图施工)
────────────────────────
项目元信息
────────────────────────
• 项目名称:LQDet(Low-Quality Image Detection & Enhancement Pipeline)
• 目标:在边缘设备(Jetson Orin Nano)上,对 720p 低质图像实现 ≥30 FPS 的实时检测,mAP ≥ 0.75。
• 低质类型:运动模糊、低光照、JPEG 压缩伪影。
• 交付物:
① 一键启动的 Docker 镜像(含模型、服务、Web UI)
② 可导入低代码平台(如 n8n、Flowise)的 JSON 工作流
③ 部署脚本(bash + YAML)
────────────────────────
2. 系统架构(Mermaid 图,AI 可直接解析)
────────────────────────
mermaid Copy code
graph TD
A[RTSP/文件输入] -->|720p| B[Preprocess Service]
B --> C{Quality Gate}
C -->|低质| D[Enhance Service]
C -->|正常| E[Detect Service]
D --> E
E --> F[Postprocess Service]
F --> G[Web UI / API / MQTT]
H[(Model Registry)] -.-> D & E
I[(Metrics DB)] -.-> F
────────────────────────
3. 模块清单(AI 生成代码的“任务卡”)
────────────────────────
模块 技术栈 输入 输出 关键参数 备注 Preprocess Service Python + OpenCV CUDA 图像帧 去噪/拉伸后帧 denoise_strength=10, gamma=1.2 GPU 加速 Quality Gate MobileNetV3-Small 分类 图像帧 低质/正常标签 阈值 0.5 模型文件 quality_gate.onnx Enhance Service Real-ESRGAN-lite INT8 低质帧 2×超分帧 tile=256, pad=10 TensorRT 引擎 Detect Service YOLOv8n-seg INT8 帧 bbox+mask JSON conf=0.4, iou=0.5 TensorRT 引擎 Postprocess Service Python JSON 去重、跟踪、告警 max_age=30 DeepSort 可选 Web UI Streamlit 所有数据 实时播放+图表 端口 8501 支持暂停/回放 Model Registry MLflow 版本管理 URL — 自动下载缺失模型 Metrics DB SQLite 延迟、mAP Grafana 面板 采样间隔 1s 本地持久化
────────────────────────
4. 数据流与接口(OpenAPI 片段,AI 可生成代码)
────────────────────────
yaml Copy code
# openapi.yaml 片段
paths:
/inference:
post:
summary: 单帧推理
requestBody:
content:
image/jpeg: {}
responses:
'200':
content:
application/json:
schema:
type: object
properties:
detections: {type: array}
latency_ms: {type: number}
────────────────────────
5. 环境 & 依赖(AI 可据此生成 Dockerfile)
────────────────────────
dockerfile Copy code
# Dockerfile
FROM nvcr.io/nvidia/l4t-tensorflow:r36.1.0-tf2.12-py3
RUN apt update && apt install -y libgl1-mesa-glx libglib2.0-0
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY src/ /app
CMD ["python", "-m", "main"]
requirements.txt(AI 自动补全版本号)
code Copy code
opencv-python-headless==4.8.*
ultralytics==8.0.*
onnxruntime-gpu==1.16.*
streamlit==1.28.*
paho-mqtt==1.6.*
────────────────────────
6. 一键部署脚本(bash,AI 可直接执行)
────────────────────────
bash Copy code
#!/bin/bash
# deploy.sh
docker build -t lqdet:latest .
docker run --gpus all -p 8554:8554 -p 8501:8501 \
-v $(pwd)/models:/models \
-e MODEL_REGISTRY_URL=https://myserver.com/models \
lqdet:latest
────────────────────────
7. 低代码工作流(Flowise JSON,可直接导入)
────────────────────────
json Copy code
{
"nodes": [
{"id": "input", "type": "File"},
{"id": "pre", "type": "OpenCVNode", "params": {"denoise": true}},
{"id": "gate", "type": "ONNXNode", "model": "quality_gate.onnx"},
{"id": "enhance", "type": "TensorRTNode", "model": "esrgan_lite.engine"},
{"id": "detect", "type": "YOLONode", "model": "yolov8n-seg.engine"},
{"id": "output", "type": "Webhook", "url": "http://localhost:8080/result"}
],
"edges": [
{"source": "input", "target": "pre"},
{"source": "pre", "target": "gate"},
{"source": "gate", "target": "enhance", "condition": "low_quality"},
{"source": "enhance", "target": "detect"},
{"source": "detect", "target": "output"}
]
}
────────────────────────
8. 训练/微调脚本(AI 自动生成)
────────────────────────
python Copy code
# train_quality_gate.py
from ultralytics import YOLO
model = YOLO('yolov8n-cls.yaml')
model.train(data='low_quality_dataset', epochs=50, imgsz=224, device=0)
model.export(format='onnx', int8=True, data='low_quality_dataset')
────────────────────────
9. 测试用例(AI 可自动运行)
────────────────────────
yaml Copy code
# tests/test_pipeline.yaml
cases:
- name: "motion_blur_720p"
input: "assets/motion_blur_001.jpg"
expect:
detections_count: 3
latency_ms: "< 33"
────────────────────────
10. 交付清单(给 AI 的“验收表”)
────────────────────────
────────────────────────
使用方式
把本蓝图全文复制给任意大模型,说:
“请按此蓝图生成完整代码仓库,包含 Dockerfile、Python 源码、YAML、测试脚本。”
将生成的仓库 git clone 到 Jetson 设备,执行 ./deploy.sh 即可。