diff --git a/pipeline/stages/04_frame_extract.py b/pipeline/stages/04_frame_extract.py index a939188..064815e 100644 --- a/pipeline/stages/04_frame_extract.py +++ b/pipeline/stages/04_frame_extract.py @@ -18,6 +18,7 @@ from __future__ import annotations import argparse import json import os +import yaml as _yaml import subprocess import sys import time @@ -32,7 +33,18 @@ from orchestrator.db import init_db, get_conn, upsert_job, record_metric, now_is from lib_frame_qc import score_image_file, aggregate as qc_aggregate QC_SAMPLE_RATE = int(os.environ.get("COSMA_QC_SAMPLE_RATE", "5")) -QC_BOTTOM_OK_PCT = float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50")) + +def _load_bottom_ok_pct() -> float: + cfg_path = Path(__file__).parent.parent / "config" / "thresholds.yaml" + try: + with open(cfg_path) as _f: + _cfg = _yaml.safe_load(_f) + return float(_cfg["frame_extract"]["bottom_visible_pct_min"]) + except Exception: + pass + return float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50")) + +QC_BOTTOM_OK_PCT = _load_bottom_ok_pct() PIPELINE_BASE = Path(os.environ.get("COSMA_PIPELINE_BASE", "/home/cosma/cosma-pipeline")) SSD_BASE = Path(os.environ.get("COSMA_SSD_BASE", "/mnt/ssd")) diff --git a/pipeline/stages/04b_trim_water.py b/pipeline/stages/04b_trim_water.py index ebdb6d3..bcc01e6 100644 --- a/pipeline/stages/04b_trim_water.py +++ b/pipeline/stages/04b_trim_water.py @@ -21,6 +21,7 @@ from __future__ import annotations import argparse import json import os +import yaml as _yaml import subprocess import sys import time @@ -35,7 +36,18 @@ from lib_frame_qc import score_image_file, aggregate as qc_aggregate PIPELINE_BASE = Path(os.environ.get("COSMA_PIPELINE_BASE", "/home/cosma/cosma-pipeline")) QC_SAMPLE_RATE = int(os.environ.get("COSMA_QC_SAMPLE_RATE", "5")) -QC_BOTTOM_OK_PCT = float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50")) + +def _load_bottom_ok_pct() -> float: + cfg_path = Path(__file__).parent.parent / "config" / "thresholds.yaml" + try: + with open(cfg_path) as _f: + _cfg = _yaml.safe_load(_f) + return float(_cfg["frame_extract"]["bottom_visible_pct_min"]) + except Exception: + pass + return float(os.environ.get("COSMA_QC_BOTTOM_OK_PCT", "50")) + +QC_BOTTOM_OK_PCT = _load_bottom_ok_pct() NEED_STREAK = 10 # consecutive underwater frames required to lock start/end