floorplan rec: fix regex rule + filter out extreme values

This commit is contained in:
Kadir 2024-08-25 12:11:55 +02:00
parent 2e94bda7fa
commit 4dfbcc64c1

View file

@ -18,12 +18,13 @@ def inference(image_path):
def extract_total_sqm(input_str: str):
sqmregex = r"(\d+\.\d*) ?(sq ?m|sq. ?m)"
sqmregex = r"(\d+\.?\d*) ?(sq ?m|sq. ?m)"
matches = re.findall(sqmregex, input_str.lower())
if len(matches) == 0:
return None
sqms = [float(m[0]) for m in matches]
return max(sqms)
filtered = [sqm for sqm in sqms if 30 < sqm < 160]
if len(filtered) == 0:
return None
return max(filtered)
def calculate_model(image_path):