fix: fix image duplicate loading in diagnose function

将cv2.imread从循环内移至循环前,避免对同一张图片重复加载
This commit is contained in:
SkyLi
2026-03-27 08:51:59 +08:00
parent 70d624ac1d
commit 10fb804c14
+6 -6
View File
@@ -50,16 +50,16 @@ class FaultDiagnoser:
detections = self.detector.detect(image)
result['detections'] = detections
import cv2
if isinstance(image, str):
img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
else:
img = image
for det in detections:
bbox = det['bbox']
x1, y1, x2, y2 = map(int, bbox)
if isinstance(image, str):
import cv2
img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
else:
img = image
roi = img[y1:y2, x1:x2]
temp_features = self.extractor.extract_from_roi(roi)