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
This commit is contained in:
43
models/README.md
Normal file
43
models/README.md
Normal file
@@ -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 仓库中。请从原始位置复制或创建符号链接。
|
||||||
83
scripts/setup-models.sh
Normal file
83
scripts/setup-models.sh
Normal file
@@ -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/*/
|
||||||
Reference in New Issue
Block a user