change folder name to match package name

This commit is contained in:
Florian Förster 2025-10-08 11:20:21 +02:00
parent 1d5ab6ad00
commit 9d72004c9a
3 changed files with 19 additions and 8 deletions

View File

@ -0,0 +1,10 @@
from typing import Final
THRESHOLD_BW: Final[int] = 63 # threshold to distringuish black (electrodes) and white areas
# model_path = [
# r"C:\Users\demon\Documents\EKF\Modelle\patchcore_model_links.pth",
# r"C:\Users\demon\Documents\EKF\Modelle\patchcore_model_rechts.pth",
# ] # path to anomaly detection models
BACKBONE: Final[str] = "resnet18" # parameters for AI model
LAYERS: Final[tuple[str, str]] = ("layer1", "layer2")
RATIO: Final[float] = 0.05

View File

@ -19,21 +19,20 @@ from scipy.spatial import distance as dist
from torch import as_tensor, cuda, device, float32, load, no_grad
from torchvision.transforms.v2.functional import to_dtype, to_image
# input parameters
from dopt_sensor_anomalies import constants as const
# input parameters: user-defined
file_path = r"C:\Users\demon\Documents\EKF\Analyse_fuer_Florian\bild2.bmp"
pixelsPerMetricX = 0.251
pixelsPerMetricY = 0.251
# internal parameters
schwellwert = 63 # threshold to distringuish black (electrodes) and white areas
# internal parameters - configuration
schwellwert = 63 # threshold to distinguish black (electrodes) and white areas
model_path = [
r"C:\Users\demon\Documents\EKF\Modelle\patchcore_model_links.pth",
r"C:\Users\demon\Documents\EKF\Modelle\patchcore_model_rechts.pth",
] # path to anomaly detection models
backbone = "resnet18" # parameters for AI model
layers = ["layer1", "layer2"]
ratio = 0.05
# measuring
@ -114,7 +113,7 @@ def measure_length(file_path, pixelsPerMetricX, pixelsPerMetricY):
# change colours in the image to black and white
gray = cv2.cvtColor(cropped, cv2.COLOR_BGR2GRAY)
_, binary = cv2.threshold(gray, schwellwert, 255, cv2.THRESH_BINARY)
_, binary = cv2.threshold(gray, const.THRESHOLD_BW, 255, cv2.THRESH_BINARY)
# perform edge detection, identify rectangular shapes
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5))
@ -350,7 +349,9 @@ def anomaly_detection(file_path, data_csv, sensor_images):
folder_path = path.dirname(file_path)
# reconstruct the model and initialize the engine
model = Patchcore(backbone=backbone, layers=layers, coreset_sampling_ratio=ratio)
model = Patchcore(
backbone=const.BACKBONE, layers=const.LAYERS, coreset_sampling_ratio=const.RATIO
)
engine = Engine()
# preparation for plot