Fix/563 eval model dict csv#617
Open
prawnsgupta wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #563.
Problem.
pm_evaluate ... --out_fname results.csvcrashes withAttributeError: '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 aDataFrame;cli/eval_model.pycalled.to_csv()directly on the result. (The issue referencedcli/evaluate.py:197, but the CLI has since been refactored intoeval_model.py/eval_preds.py; the bug is now ateval_model.py:209.)Fix. Extract the metrics DataFrame with
results.get("metrics_df") if isinstance(results, dict) else results— the same pattern already used incli/batch.py— before writing the CSV, and preserve the function's existingreturn resultscontract. Also addedos.makedirs(os.path.dirname(os.path.abspath(out_fname)), exist_ok=True)to matchcli/eval_preds.py, so--out_fnamewith a non-existent parent directory works.Scope.
cli/eval_preds.pyuses a different path (dataset.eval_preds(), which returns a DataFrame) and already creates the directory, so it needs no change;cli/batch.pyalready handled the dict case.