Skip to content

Fix/563 eval model dict csv#617

Open
prawnsgupta wants to merge 2 commits into
JdeRobot:masterfrom
prawnsgupta:fix/563-eval-model-dict-csv
Open

Fix/563 eval model dict csv#617
prawnsgupta wants to merge 2 commits into
JdeRobot:masterfrom
prawnsgupta:fix/563-eval-model-dict-csv

Conversation

@prawnsgupta

Copy link
Copy Markdown

Fixes #563.

Problem. pm_evaluate ... --out_fname results.csv crashes with AttributeError: 'dict' object has no attribute 'to_csv' for detection models. model.eval() returns a dict {"metrics_df", "metrics_factory"} for detection (torch_detection.py), while segmentation/other tasks return a DataFrame; cli/eval_model.py called .to_csv() directly on the result. (The issue referenced cli/evaluate.py:197, but the CLI has since been refactored into eval_model.py / eval_preds.py; the bug is now at eval_model.py:209.)

Fix. Extract the metrics DataFrame with results.get("metrics_df") if isinstance(results, dict) else results — the same pattern already used in cli/batch.py — before writing the CSV, and preserve the function's existing return results contract. Also added os.makedirs(os.path.dirname(os.path.abspath(out_fname)), exist_ok=True) to match cli/eval_preds.py, so --out_fname with a non-existent parent directory works.

Scope. cli/eval_preds.py uses a different path (dataset.eval_preds(), which returns a DataFrame) and already creates the directory, so it needs no change; cli/batch.py already handled the dict case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI pm_evaluate detection crashes with AttributeError when --out_fname is used

1 participant