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:
wwh
2026-05-18 10:56:40 +08:00
parent 8fb58c75fe
commit 54ac754660
2 changed files with 126 additions and 0 deletions

83
scripts/setup-models.sh Normal file
View 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/*/