fix: Update production API base URL in documentation and configuration files. Correct the URL in the desktop app README, migration documentation, and Vite configuration. Enhance ONNX model feature handling in the processing pipeline to align with the updated feature set, ensuring compatibility with the latest model version. Add tests for feature extraction to validate changes.
This commit is contained in:
@@ -9,8 +9,15 @@ import joblib
|
||||
from skl2onnx import convert_sklearn
|
||||
from skl2onnx.common.data_types import FloatTensorType
|
||||
|
||||
# Alineado con services-count-facturas-medicas-ml v1.1.0 y pipeline Go.
|
||||
FEATURE_COLUMNS = [
|
||||
"first_token_is_code",
|
||||
"first_token_is_service_code",
|
||||
"has_service_table_pattern",
|
||||
"has_header_keyword",
|
||||
"currency_at_row_end",
|
||||
"first_token_x_norm",
|
||||
"is_likely_continuation",
|
||||
"currency_count",
|
||||
"integer_count",
|
||||
"x_span_norm",
|
||||
@@ -31,7 +38,7 @@ def parse_args() -> argparse.Namespace:
|
||||
"--joblib",
|
||||
type=Path,
|
||||
required=True,
|
||||
help="Ruta al model.joblib (ej. ../services-count/models/latest/model.joblib)",
|
||||
help="Ruta al model.joblib (ej. models/v1.1.0/model.joblib)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--out",
|
||||
@@ -64,6 +71,21 @@ def main() -> None:
|
||||
threshold = float(bundle.get("threshold", 0.5))
|
||||
meta = load_metadata(args.metadata)
|
||||
|
||||
bundle_columns = list(bundle.get("feature_columns") or FEATURE_COLUMNS)
|
||||
if bundle_columns != FEATURE_COLUMNS:
|
||||
raise SystemExit(
|
||||
f"feature_columns del joblib no coinciden con el pipeline Go.\n"
|
||||
f" joblib: {bundle_columns}\n"
|
||||
f" esperado: {FEATURE_COLUMNS}"
|
||||
)
|
||||
|
||||
n_features = int(getattr(model, "n_features_in_", len(FEATURE_COLUMNS)))
|
||||
if n_features != len(FEATURE_COLUMNS):
|
||||
raise SystemExit(
|
||||
f"El model.joblib tiene {n_features} features pero el pipeline Go produce "
|
||||
f"{len(FEATURE_COLUMNS)}. Reentrena o usa un joblib compatible."
|
||||
)
|
||||
|
||||
initial_type = [("float_input", FloatTensorType([None, len(FEATURE_COLUMNS)]))]
|
||||
options = {id(model): {"zipmap": False}}
|
||||
onnx_model = convert_sklearn(
|
||||
@@ -84,7 +106,7 @@ def main() -> None:
|
||||
inference = {
|
||||
"threshold": threshold,
|
||||
"feature_columns": FEATURE_COLUMNS,
|
||||
"pipeline_version": meta.get("pipeline_version", "unknown"),
|
||||
"pipeline_version": meta.get("pipeline_version", bundle.get("pipeline_version", "unknown")),
|
||||
"ocr": meta.get("ocr", DEFAULT_OCR),
|
||||
"dbscan": meta.get("dbscan", DEFAULT_DBSCAN),
|
||||
}
|
||||
@@ -93,6 +115,7 @@ def main() -> None:
|
||||
print(f"ONNX: {onnx_path}")
|
||||
print(f"Meta: {meta_path}")
|
||||
print(f"Umbral: {threshold}")
|
||||
print(f"Features: {len(FEATURE_COLUMNS)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user