From 7472a128dd9d8e36f1fe4ed84f07ee8a8e407b0d Mon Sep 17 00:00:00 2001 From: frasu Date: Mon, 3 Nov 2025 16:34:15 +0000 Subject: [PATCH 1/2] src/dopt_sensor_anomalies/detection.py aktualisiert --- src/dopt_sensor_anomalies/detection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dopt_sensor_anomalies/detection.py b/src/dopt_sensor_anomalies/detection.py index f74d133..1a2b981 100644 --- a/src/dopt_sensor_anomalies/detection.py +++ b/src/dopt_sensor_anomalies/detection.py @@ -140,9 +140,9 @@ def measure_length( f"expected value: count = {num_contours}, expected = {const.NUM_VALID_ELECTRODES}" ) - x_min = min(np.min(c[:, 0, 0]) for c in filtered_cnts) - 20 + x_min = max(min(np.min(c[:, 0, 0]) for c in filtered_cnts) - 20, 0) x_max = max(np.max(c[:, 0, 0]) for c in filtered_cnts) + 20 - y_min = min(np.min(c[:, 0, 1]) for c in filtered_cnts) - 20 + y_min = max(min(np.min(c[:, 0, 1]) for c in filtered_cnts) - 20, 0) y_max = max(np.max(c[:, 0, 1]) for c in filtered_cnts) + 20 rightmost_x_third = max(filtered_cnts[2][:, 0, 0]) -- 2.34.1 From 346b905a86a8a2aaa9979b719cd2d6b5f6849ccc Mon Sep 17 00:00:00 2001 From: frasu Date: Tue, 4 Nov 2025 10:24:53 +0000 Subject: [PATCH 2/2] src/dopt_sensor_anomalies/detection.py aktualisiert --- src/dopt_sensor_anomalies/detection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dopt_sensor_anomalies/detection.py b/src/dopt_sensor_anomalies/detection.py index 1a2b981..cfb4ce3 100644 --- a/src/dopt_sensor_anomalies/detection.py +++ b/src/dopt_sensor_anomalies/detection.py @@ -141,9 +141,9 @@ def measure_length( ) x_min = max(min(np.min(c[:, 0, 0]) for c in filtered_cnts) - 20, 0) - x_max = max(np.max(c[:, 0, 0]) for c in filtered_cnts) + 20 + x_max = min(max(np.max(c[:, 0, 0]) for c in filtered_cnts) + 20, orig.shape[1]) y_min = max(min(np.min(c[:, 0, 1]) for c in filtered_cnts) - 20, 0) - y_max = max(np.max(c[:, 0, 1]) for c in filtered_cnts) + 20 + y_max = min(max(np.max(c[:, 0, 1]) for c in filtered_cnts) + 20, orig.shape[0]) rightmost_x_third = max(filtered_cnts[2][:, 0, 0]) leftmost_x_fourth = min(filtered_cnts[3][:, 0, 0]) @@ -176,7 +176,7 @@ def infer_image( output = model(input_tensor) anomaly_score = output.pred_score.item() - anomaly_label = output.pred_label.item() + anomaly_label = 1 if anomaly_score >= .2 else 0 anomaly_map = output.anomaly_map.squeeze().cpu().numpy() img_np = np.array(pil_image) -- 2.34.1