Skip to content

Commit 54ed425

Browse files
feat: Refactor the CLI arguments of 'evaluate' to accept optional input and ouput dirs
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
1 parent 3525b83 commit 54ed425

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

docling_eval/cli/main.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def get_prediction_provider(
324324

325325
layout_options: LayoutOptions = LayoutOptions()
326326
if docling_layout_model_spec is not None:
327-
layout_options.model = docling_layout_model_spec
327+
layout_options.model_spec = docling_layout_model_spec
328328
if docling_layout_create_orphan_clusters is not None:
329329
layout_options.create_orphan_clusters = (
330330
docling_layout_create_orphan_clusters
@@ -1222,13 +1222,39 @@ def create(
12221222
@app.command(name="evaluate")
12231223
def evaluate_cmd(
12241224
modality: Annotated[EvaluationModality, typer.Option(help="Evaluation modality")],
1225-
benchmark: Annotated[BenchMarkNames, typer.Option(help="Benchmark name")],
1226-
output_dir: Annotated[Path, typer.Option(help="Base output directory")],
1225+
benchmark: Annotated[
1226+
BenchMarkNames,
1227+
typer.Option(
1228+
help="Benchmark name. It is used only to set the filename of the evaluation json file."
1229+
),
1230+
],
1231+
input_dir: Annotated[
1232+
Optional[Path],
1233+
typer.Option(
1234+
help="Directory with evaluation dataset. If not provided, the input directory will be derived from the output directory."
1235+
),
1236+
] = None,
1237+
output_dir: Annotated[
1238+
Optional[Path],
1239+
typer.Option(
1240+
help="Base output directory. If not provided, the output directory will be derived from the input directory."
1241+
),
1242+
] = None,
12271243
split: Annotated[str, typer.Option(help="Dataset split")] = "test",
12281244
):
12291245
"""Evaluate predictions against ground truth."""
1230-
# Derive input and output paths based on the directory structure in test_dataset_builder.py
1231-
input_dir = output_dir / "eval_dataset"
1246+
if not input_dir and not output_dir:
1247+
raise ValueError("Either input_dir or output_dir must be provided")
1248+
1249+
if not input_dir and output_dir:
1250+
# Derive input and output paths based on the directory structure in test_dataset_builder.py
1251+
input_dir = output_dir / "eval_dataset" / benchmark.value / modality.value
1252+
1253+
if not output_dir and input_dir:
1254+
output_dir = input_dir
1255+
1256+
assert input_dir is not None
1257+
assert output_dir is not None
12321258
eval_output_dir = output_dir / "evaluations" / modality.value
12331259

12341260
# Create output directory

0 commit comments

Comments
 (0)