From 2841ef3873dace6fa45b2789ab4074f474c93780 Mon Sep 17 00:00:00 2001 From: sfmig <33267254+sfmig@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:14:53 +0000 Subject: [PATCH 1/2] Small additions --- crabs/detector/evaluate_model.py | 11 +++++++---- crabs/detector/utils/evaluate.py | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crabs/detector/evaluate_model.py b/crabs/detector/evaluate_model.py index 3c0d5f73..5719e059 100644 --- a/crabs/detector/evaluate_model.py +++ b/crabs/detector/evaluate_model.py @@ -75,6 +75,12 @@ def __init__(self, args: argparse.Namespace) -> None: ) self.evaluation_split = "test" if self.args.use_test_set else "val" + # output directory for frames + self.frames_output_dir_root = str( + Path(self.args.frames_output_dir) + / f"evaluation_output_{self.evaluation_split}" + ) + # Hardware self.accelerator = args.accelerator @@ -172,10 +178,7 @@ def evaluate_model(self) -> None: save_images_with_boxes( dataloader=eval_dataloader, trained_model=trained_model, - output_dir=str( - Path(self.args.frames_output_dir) - / f"evaluation_output_{self.evaluation_split}" - ), + output_dir=self.frames_output_dir_root, score_threshold=self.args.frames_score_threshold, ) diff --git a/crabs/detector/utils/evaluate.py b/crabs/detector/utils/evaluate.py index 3b0d25cc..5944a2a5 100644 --- a/crabs/detector/utils/evaluate.py +++ b/crabs/detector/utils/evaluate.py @@ -4,6 +4,7 @@ import ast import sys from pathlib import Path +from typing import Optional import torchvision import yaml # type: ignore @@ -145,7 +146,9 @@ def get_mlflow_parameters_from_ckpt(trained_model_path: str) -> dict: return params -def get_config_from_ckpt(config_file: str, trained_model_path: str) -> dict: +def get_config_from_ckpt( + config_file: Optional[str], trained_model_path: str +) -> dict: """Get config from checkpoint if config is not passed as a CLI argument.""" # If config in CLI arguments: used passed config if config_file: From 849940ff7367f4159ae5669679623659467d00b4 Mon Sep 17 00:00:00 2001 From: sfmig <33267254+sfmig@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:18:13 +0000 Subject: [PATCH 2/2] Update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e149f4fd..f785b246 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,8 @@ If a file with ground-truth annotations is passed to the command (with the `--an To see the full list of possible arguments to the `evaluate-detector` command, run it with the `--help` flag. - +## Task-specific guides +For further information on specific tasks, such as launching a training job or evaluating a set of models in the HPC cluster, please see [our guides](guides).