chore: update project docs and scripts for new dataset

- 更新README.md数据集描述(12类,6735训练图+765验证图)
- 更新模型性能指标(新12类模型结果)
- 删除已过时的download_dataset.py和retry_download.py脚本
- 更新usage_example.py使用正确的路径和模型名
This commit is contained in:
SkyLi
2026-03-27 00:56:10 +08:00
parent 11c5e062c2
commit 787d17a870
4 changed files with 56 additions and 358 deletions
+17 -14
View File
@@ -19,8 +19,8 @@ def example1_basic_detection():
"""示例1:基础目标检测"""
print("\n【示例1】基础目标检测")
detector = InfraredDetector("weights/infrared_yolov8n.pt", conf=0.25)
detections = detector.detect("data/infrared/images/val/FLIR0166.jpg")
detector = InfraredDetector("weights/best.pt", conf=0.25)
detections = detector.detect("data/valid/images/20230907095711003_jpg.rf.0e14e8b4344dce21114683dc3f3e7e2e.jpg")
print(f"检测到 {len(detections)} 个目标:")
for i, det in enumerate(detections):
@@ -34,9 +34,9 @@ def example2_detect_and_draw():
output_dir = Path(__file__).parent.parent / "output"
output_dir.mkdir(exist_ok=True)
detector = InfraredDetector("weights/infrared_yolov8n.pt")
detector = InfraredDetector("weights/best.pt")
detector.detect_and_draw(
"data/infrared/images/val/FLIR0166.jpg",
"data/valid/images/20230907095711003_jpg.rf.0e14e8b4344dce21114683dc3f3e7e2e.jpg",
output_path=str(output_dir / "detection_result.jpg")
)
print(f"结果已保存至: {output_dir / 'detection_result.jpg'}")
@@ -46,14 +46,15 @@ def example3_temperature_extraction():
"""示例3:温度特征提取"""
print("\n【示例3】温度特征提取")
extractor = TempFeatureExtractor("weights/infrared_yolov8n.pt")
detector = InfraredDetector("weights/infrared_yolov8n.pt")
sample_image = "data/valid/images/20230907095711003_jpg.rf.0e14e8b4344dce21114683dc3f3e7e2e.jpg"
extractor = TempFeatureExtractor("weights/best.pt")
detector = InfraredDetector("weights/best.pt")
# 读取图像
gray_img = cv2.imread("data/infrared/images/val/FLIR0166.jpg", cv2.IMREAD_GRAYSCALE)
gray_img = cv2.imread(sample_image, cv2.IMREAD_GRAYSCALE)
# 检测目标
detections = detector.detect("data/infrared/images/val/FLIR0166.jpg")
detections = detector.detect(sample_image)
# 提取第一个检测框的温度特征
if detections:
@@ -71,8 +72,9 @@ def example4_fault_diagnosis():
"""示例4:故障诊断"""
print("\n【示例4】故障诊断")
diagnoser = FaultDiagnoser("weights/infrared_yolov8n.pt")
result = diagnoser.diagnose("data/infrared/images/val/FLIR0166.jpg")
sample_image = "data/valid/images/20230907095711003_jpg.rf.0e14e8b4344dce21114683dc3f3e7e2e.jpg"
diagnoser = FaultDiagnoser("weights/best.pt")
result = diagnoser.diagnose(sample_image)
print(f"诊断状态: {result['summary']['status']}")
print(f"故障类型: {result['summary']['fault_types']}")
@@ -88,9 +90,9 @@ def example5_batch_diagnosis():
output_dir = Path(__file__).parent.parent / "output"
output_dir.mkdir(exist_ok=True)
diagnoser = FaultDiagnoser("weights/infrared_yolov8n.pt")
diagnoser = FaultDiagnoser("weights/best.pt")
diagnoser.batch_diagnose(
"data/infrared/images/val",
"data/valid/images",
str(output_dir / "batch_results.json")
)
print(f"批量诊断完成,结果已保存至: {output_dir / 'batch_results.json'}")
@@ -100,14 +102,15 @@ def example6_custom_threshold():
"""示例6:自定义温度阈值"""
print("\n【示例6】自定义温度阈值")
sample_image = "data/valid/images/20230907095711003_jpg.rf.0e14e8b4344dce21114683dc3f3e7e2e.jpg"
# 自定义温度阈值
threshold = {
"max_temp": 200, # 最高温度阈值
"std_temp": 40 # 标准差阈值
}
diagnoser = FaultDiagnoser("weights/infrared_yolov8n.pt", temp_threshold=threshold)
result = diagnoser.diagnose("data/infrared/images/val/FLIR0166.jpg")
diagnoser = FaultDiagnoser("weights/best.pt", temp_threshold=threshold)
result = diagnoser.diagnose(sample_image)
print(f"使用自定义阈值: max_temp={threshold['max_temp']}, std_temp={threshold['std_temp']}")
print(f"诊断结果: {result['summary']['status']}")