diff --git a/src/diagnose.py b/src/diagnose.py index 1b0f266..c2d2dcd 100644 --- a/src/diagnose.py +++ b/src/diagnose.py @@ -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)