这个项目用于测试和比较不同的基于YOLOv8的暴力检测模型。目前集成了两个模型:
- V01 (Yasser) - 来自 Violence_detection_YOLOv8
- V02 (Musa) - 来自 Fight-Violence-detection-yolov8
模型性能比较表格:
模型类型 | 加载时间(秒) | 检测时间(秒) | 总时间(秒) |
---|---|---|---|
V01 | 0.07 | 1.07 | 1.13 |
V02-SMALL | 0.06 | 0.28 | 0.34 |
V02-NANO | 0.04 | 0.13 | 0.17 |
===== 检测结果 =====
Violence (置信度: 0.82), 位置: [203, 16, 767, 651]
violence (置信度: 0.66), 位置: [231, 7, 763, 649]
violence (置信度: 0.66), 位置: [235, 28, 763, 645]
项目使用Git子模块来管理依赖的模型:
Violence_Yolo/
├── V01_Yasser_Violence/ # Yasser的暴力检测模型(子模块)
├── V02_Musa_Violence/ # Musa的暴力检测模型(子模块)
├── test_violence.py # 模型测试和比较脚本
└── test_image/ # 测试图像目录
# 克隆主项目和所有子模块
git clone --recurse-submodules https://your-repo-url.git
cd Violence_Yolo
# 或者,如果你已经克隆了项目但没有子模块
git submodule update --init --recursive
# 创建虚拟环境
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# 或 .venv\Scripts\activate # Windows
# 安装依赖
pip install -r requirements.txt
# 测试V01模型
python test_violence.py --v01 [图像路径]
# 测试V02 Small模型
python test_violence.py --v02-small [图像路径]
# 测试V02 Nano模型
python test_violence.py --v02-nano [图像路径]
# 比较所有模型
python test_violence.py --compare [图像路径]
# 比较所有模型但不包括V01
python test_violence.py --compare [图像路径] --no-v01
直接运行脚本将默认执行所有模型的比较:
python test_violence.py
# 更新所有子模块到最新的远程提交
git submodule update --remote
# 更新特定子模块
git submodule update --remote V01_Yasser_Violence
git submodule add [仓库URL] [本地路径]
- 模型文件较大,首次克隆可能需要较长时间。
- V01 模型预期的权重文件位于
V01_Yasser_Violence/weight/best.pt
。 - V02 模型预期的权重文件位于
V02_Musa_Violence/yolo_small_weights.pt
和V02_Musa_Violence/Yolo_nano_weights.pt
。