|
1 month ago | |
---|---|---|
scripts | 1 month ago | |
src | 1 month ago | |
tests | 1 month ago | |
.gitignore | 1 month ago | |
README.md | 1 month ago | |
README_NEW.md | 1 month ago | |
inference.py | 1 month ago | |
requirements.txt | 1 month ago | |
run.py | 1 month ago |
基于ONNX的无人机检测系统,采用模块化设计,提供高效的目标检测和结果分析功能。
ModelEvaluator/
├── src/ # 源代码目录
│ ├── config/ # 配置模块
│ │ └── config.py # 配置类定义
│ ├── core/ # 核心模块
│ │ ├── detector.py # 主检测器
│ │ ├── image_processor.py # 图像处理
│ │ ├── model_inference.py # 模型推理
│ │ └── post_processor.py # 后处理
│ ├── utils/ # 工具模块
│ │ ├── file_manager.py # 文件管理
│ │ └── report_generator.py # 报告生成
│ └── main.py # 主入口
├── tests/ # 测试代码
│ └── test_refactored.py # 重构测试
├── data/ # 数据目录
│ ├── models/ # 模型文件
│ └── samples/ # 样本数据
├── docs/ # 文档目录
├── examples/ # 示例代码
├── scripts/ # 脚本目录
├── output/ # 输出目录
├── logs/ # 日志目录
├── run.py # 项目启动入口
├── requirements.txt # 依赖列表
└── README.md # 项目说明
pip install -r requirements.txt
将ONNX模型文件放置在 data/models/
目录下。
# 检测单张图片
python run.py --input image.jpg
# 批量检测目录中的图片
python run.py --input /path/to/images
# 使用GUI选择输入目录
python run.py --gui
# 自定义参数
python run.py --input /path/to/images --threshold 0.6 --output custom_output
python run.py --help
主要参数:
--input
: 输入图像路径或目录--output
: 输出目录路径--model
: ONNX模型文件路径--threshold
: 检测置信度阈值 (默认: 0.5)--iou-threshold
: NMS IoU阈值 (默认: 0.4)--max-bbox-ratio
: 检测框最大面积比例阈值 (默认: 0.5)--save-empty
: 是否保存未检测到目标的图片--gui
: 启用图形界面选择输入目录--verbose
: 显示详细信息import sys
import os
sys.path.insert(0, 'src')
from config.config import AppConfig, ModelConfig, DetectionConfig, OutputConfig
from core.detector import UAVDetector
# 创建配置
model_config = ModelConfig(
model_path='data/models/your_model.onnx',
input_size=(640, 640),
confidence_threshold=0.5
)
detection_config = DetectionConfig(
confidence_threshold=0.5,
iou_threshold=0.4,
max_bbox_ratio=0.5
)
output_config = OutputConfig(
base_output_dir='output',
add_timestamp=True,
save_empty_images=False
)
app_config = AppConfig(
model=model_config,
detection=detection_config,
output=output_config
)
# 初始化检测器
detector = UAVDetector(config=app_config, input_dir='path/to/images')
# 处理单张图片
result = detector.process_image('image.jpg')
# 批量处理
detector.process_batch(['image1.jpg', 'image2.jpg'])
# 生成报告
detector.generate_reports()
# 获取统计信息
stats = detector.get_statistics()
print(f"处理图片数: {stats['total_images']}")
print(f"检测到目标数: {stats['total_detections']}")
output/
├── imgs/ # 检测结果图片
│ ├── image1_detected.jpg
│ └── image2_detected.jpg
├── targets/ # 检测目标ROI
│ ├── image1_target_1.jpg
│ └── image1_target_2.jpg
├── detection_report.csv # CSV格式报告
└── detection_report.xlsx # Excel格式报告
运行测试脚本验证系统功能:
python tests/test_refactored.py
model_path
: ONNX模型文件路径input_size
: 模型输入尺寸 (width, height)mean
: 图像归一化均值std
: 图像归一化标准差use_cuda
: 是否使用CUDA加速confidence_threshold
: 置信度阈值iou_threshold
: NMS IoU阈值max_bbox_ratio
: 检测框最大面积比例base_output_dir
: 基础输出目录add_timestamp
: 是否添加时间戳save_empty_images
: 是否保存空检测图片注意: 这是重构版本,相比原版本具有更好的代码结构和可维护性。建议使用新的 run.py
入口文件启动应用程序。