fix: optimize diagnosis output format and fix inconsistency between fault_status and fault_type

1. 输出格式优化:
   - faults中移除冗余的bbox和confidence字段
   - summary中fault_count改名为detection_count

2. fault_status与fault_type逻辑统一:
   - normal状态时fault_type为'none',不再使用'suspect'
   - abnormal状态时才进行故障类型分类(hotspot/local_overheating/overheat)

3. 修复usage_example.py图像通道问题:
   - YOLO检测使用彩色图,温度提取时再转灰度图
This commit is contained in:
SkyLi
2026-03-27 12:03:48 +08:00
parent febd9eea8d
commit 085cbc9950
4 changed files with 16 additions and 17 deletions
+8 -8
View File
@@ -67,13 +67,13 @@ class FaultDiagnoser:
fault_status = self._check_fault(temp_features)
temp_features['fault_status'] = fault_status
temp_features['fault_type'] = self._classify_fault(temp_features)
# abnormal 时才进行故障分类,normal 时类型为 none
if fault_status == 'abnormal':
temp_features['fault_type'] = self._classify_fault(temp_features)
else:
temp_features['fault_type'] = 'none'
result['faults'].append({
'bbox': bbox,
'confidence': det['confidence'],
**temp_features
})
result['faults'].append(temp_features)
else:
raise ValueError("Detector not initialized with model")
@@ -137,14 +137,14 @@ class FaultDiagnoser:
摘要信息
"""
if not faults:
return {'status': 'no_detection', 'fault_count': 0}
return {'status': 'no_detection', 'detection_count': 0}
abnormal_count = sum(1 for f in faults if f.get('fault_status') == 'abnormal')
fault_types = [f.get('fault_type', 'unknown') for f in faults]
return {
'status': 'fault_detected' if abnormal_count > 0 else 'normal',
'fault_count': len(faults),
'detection_count': len(faults),
'abnormal_count': abnormal_count,
'fault_types': list(set(fault_types))
}