pm_eval_model crashes with TypeError after the evaluation when --out_fname is not given (regression from #617)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- machine-learning, testing
Research direction
Start in perceptionmetrics/cli/eval_model.py at the command’s output handling after model.eval() returns. Check the existing tests for segmentation and detection output handling, then add coverage for invoking the command without --out_fname. Done means both return types complete successfully without that option while the existing output behavior remains covered.
Written by the indexing model from the issue text.
Description
Problem
pm_eval_model declares --out_fname as optional, but since #617 the end of the command does os.makedirs(os.path.dirname(os.path.abspath(out_fname)), exist_ok=True) without checking for None. A run without --out_fname (for example one that only wants per-sample outputs through --predictions_outdir) now spends the whole evaluation, writes the per-sample predictions, and then ends with:
TypeError: expected str, bytes or os.PathLike object, not NoneType
In v3.1.0 the same call finished normally: the last line was results.to_csv(out_fname), which writes nothing when the path is None. The regression comes from b10bf7d (#617, the fix for #563) and is not in any release yet.
Reproduction
from click.testing import CliRunner
from perceptionmetrics import cli
from perceptionmetrics.cli.eval_model import eval_model
# any model/dataset: the error happens after model.eval() returns
# (model, ontology and cfg files must exist; fake get_model/get_dataset keep it short)
result = CliRunner().invoke(eval_model, ["segmentation", "image",
"--model", "model.pt",
"--model_ontology", "ontology.json",
"--model_cfg", "cfg.json"])
print(repr(result.exception))
On master (4a1ae41) this prints TypeError('expected str, bytes or os.PathLike object, not NoneType') for both the segmentation (DataFrame) and detection (dict) return types.
Proposed fix
Only create the directory and write the CSV when --out_fname is given. This keeps what #617 added (directory creation and the detection dict handling) and restores the v3.1.0 behavior for runs without --out_fname. I am not proposing to make the option required: it was made optional on purpose when --predictions_outdir was introduced, and eval_preds / computational_cost are separate commands.
I would like to work on this. It is a two-line change plus tests, and I have it ready locally, so I can open a small PR if that works for you.
- Dominant language
- Python
- Stars
- 114
- Forks
- 116
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JdeRobot/PerceptionMetrics
-
Micro accuracy in segmentation is always the same as macro accuracyPossibly taken @guptakaran20 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JdeRobot/PerceptionMetrics#674 · 1 comment ·
Maintainers usually reply within 1 day
-
Segmentation metrics give wrong results or crash for invalid predicted classesPossibly taken @soujasK claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
JdeRobot/PerceptionMetrics#659 · 4 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
[Bug] Inference tab renders normalized tensors without inverse normalization.Possibly taken @divyanshAgarwal123 claimed this 62 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
JdeRobot/PerceptionMetrics#524 · 8 comments ·
Maintainers usually reply within 1 day
-
Detection AUC-PR is underestimated: the curve is not anchored at recall 0, so a perfect detector scores (N-1)/NPossibly taken @Siddhanthguptaa claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 20/100
JdeRobot/PerceptionMetrics#672 ·
Maintainers usually reply within 1 day
-
YOLO TorchScript model fails to load on Apple Silicon (MPS float64 error)Possibly taken @guptakaran20 claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 65/100
JdeRobot/PerceptionMetrics#671 · 1 comment ·
Maintainers usually reply within 1 day
All issues in JdeRobot/PerceptionMetrics
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
huggingface/accelerate#4511 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pylint-dev/pylint#11791 ·
Maintainers usually reply within 1 day
-
Rasterio granule reads never retry, so one 503 (Service Unavailable) fails the whole requestPossibly taken @chuckwondo claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
developmentseed/titiler-cmr#305 ·
Maintainers usually reply within 1 day
-
community enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day