From 54ac7546608470a77495c1c0fd48ea311a1a3827 Mon Sep 17 00:00:00 2001 From: wwh <496479012@qq.com> Date: Mon, 18 May 2026 10:56:40 +0800 Subject: [PATCH] docs: Add model setup documentation and script - Add models/README.md with model file information - Add scripts/setup-models.sh for easy model linking - Document how to obtain and setup model files --- models/README.md | 43 +++++++++++++++++++++ scripts/setup-models.sh | 83 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 models/README.md create mode 100644 scripts/setup-models.sh diff --git a/models/README.md b/models/README.md new file mode 100644 index 0000000..e0f1010 --- /dev/null +++ b/models/README.md @@ -0,0 +1,43 @@ +# 模型文件目录 + +此目录用于存放 AI 检测模型文件。 + +## 模型清单 + +| 模型 | 文件名 | 来源 | 大小 | +|------|--------|------|------| +| 火灾检测 | `fire_detection/best.pt` | fire_detection/models/best.pt | ~61MB | +| 安全帽检测 | `helmet_detection/yolov8n.pt` | yolov/yolov8n.pt | ~6MB | +| 人群检测 | `crowd_detection/yolov8l.pt` | behavior_detection/Crowd-Gathering/models/yolov8l.pt | ~100MB | +| 抽烟检测 | `smoking_detection/smoking_yolov8n.pt` | behavior_detection/smoker-detection/models/smoking_yolov8n.pt | ~6MB | +| 徘徊检测 | `loitering_detection/yolov8n.pt` | behavior_detection/Loitering-Detection/yolov8n.pt | ~6MB | + +## 设置模型 + +### 方式1: 符号链接(开发环境) +```bash +# 在项目根目录执行 +ln -sf /path/to/fire_detection/models/best.pt models/fire_detection/ +ln -sf /path/to/yolov/yolov8n.pt models/helmet_detection/ +ln -sf /path/to/behavior_detection/Crowd-Gathering/models/yolov8l.pt models/crowd_detection/ +ln -sf /path/to/behavior_detection/smoker-detection/models/smoking_yolov8n.pt models/smoking_detection/ +ln -sf /path/to/behavior_detection/Loitering-Detection/yolov8n.pt models/loitering_detection/ +``` + +### 方式2: 复制文件 +```bash +cp /path/to/fire_detection/models/best.pt models/fire_detection/ +cp /path/to/yolov/yolov8n.pt models/helmet_detection/ +cp /path/to/behavior_detection/Crowd-Gathering/models/yolov8l.pt models/crowd_detection/ +cp /path/to/behavior_detection/smoker-detection/models/smoking_yolov8n.pt models/smoking_detection/ +cp /path/to/behavior_detection/Loitering-Detection/yolov8n.pt models/loitering_detection/ +``` + +### 方式3: 使用初始化脚本 +```bash +bash scripts/setup-models.sh +``` + +## 注意 + +模型文件较大,未包含在 Git 仓库中。请从原始位置复制或创建符号链接。 diff --git a/scripts/setup-models.sh b/scripts/setup-models.sh new file mode 100644 index 0000000..29b77ff --- /dev/null +++ b/scripts/setup-models.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# 模型文件设置脚本 + +set -e + +echo "🔗 设置模型文件链接..." + +cd "$(dirname "$0")/.." + +# 创建模型目录 +mkdir -p models/{fire_detection,helmet_detection,crowd_detection,smoking_detection,loitering_detection} + +# 获取项目根目录的父目录(video-model) +PARENT_DIR="$(cd .. && pwd)" + +echo "📁 父目录: $PARENT_DIR" + +# 火灾检测模型 +if [ ! -L "models/fire_detection/best.pt" ]; then + if [ -f "$PARENT_DIR/fire_detection/models/best.pt" ]; then + ln -sf "$PARENT_DIR/fire_detection/models/best.pt" models/fire_detection/ + echo "✅ 火灾检测模型链接已创建" + else + echo "⚠️ 火灾检测模型未找到: $PARENT_DIR/fire_detection/models/best.pt" + fi +else + echo "✓ 火灾检测模型链接已存在" +fi + +# 安全帽检测模型 +if [ ! -L "models/helmet_detection/yolov8n.pt" ]; then + if [ -f "$PARENT_DIR/yolov/yolov8n.pt" ]; then + ln -sf "$PARENT_DIR/yolov/yolov8n.pt" models/helmet_detection/ + echo "✅ 安全帽检测模型链接已创建" + else + echo "⚠️ 安全帽检测模型未找到: $PARENT_DIR/yolov/yolov8n.pt" + fi +else + echo "✓ 安全帽检测模型链接已存在" +fi + +# 人群检测模型 +if [ ! -L "models/crowd_detection/yolov8l.pt" ]; then + if [ -f "$PARENT_DIR/behavior_detection/Crowd-Gathering/models/yolov8l.pt" ]; then + ln -sf "$PARENT_DIR/behavior_detection/Crowd-Gathering/models/yolov8l.pt" models/crowd_detection/ + echo "✅ 人群检测模型链接已创建" + else + echo "⚠️ 人群检测模型未找到: $PARENT_DIR/behavior_detection/Crowd-Gathering/models/yolov8l.pt" + fi +else + echo "✓ 人群检测模型链接已存在" +fi + +# 抽烟检测模型 +if [ ! -L "models/smoking_detection/smoking_yolov8n.pt" ]; then + if [ -f "$PARENT_DIR/behavior_detection/smoker-detection/models/smoking_yolov8n.pt" ]; then + ln -sf "$PARENT_DIR/behavior_detection/smoker-detection/models/smoking_yolov8n.pt" models/smoking_detection/ + echo "✅ 抽烟检测模型链接已创建" + else + echo "⚠️ 抽烟检测模型未找到: $PARENT_DIR/behavior_detection/smoker-detection/models/smoking_yolov8n.pt" + fi +else + echo "✓ 抽烟检测模型链接已存在" +fi + +# 徘徊检测模型 +if [ ! -L "models/loitering_detection/yolov8n.pt" ]; then + if [ -f "$PARENT_DIR/behavior_detection/Loitering-Detection/yolov8n.pt" ]; then + ln -sf "$PARENT_DIR/behavior_detection/Loitering-Detection/yolov8n.pt" models/loitering_detection/ + echo "✅ 徘徊检测模型链接已创建" + else + echo "⚠️ 徘徊检测模型未找到: $PARENT_DIR/behavior_detection/Loitering-Detection/yolov8n.pt" + fi +else + echo "✓ 徘徊检测模型链接已存在" +fi + +echo "" +echo "✅ 模型设置完成!" +echo "" +echo "📋 模型状态:" +ls -la models/*/