Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When testing my model with tools/test.py, my config will be messed up by the "--save-preds" option. #2052

Merged
merged 3 commits into from
Jun 2, 2024

Conversation

shiyunalex
Copy link

Motivation

To improve the test tool, when testing model with tools/test.py and "--save-preds" option.

Modification

When the test_evaluator config is a dict and --save-preds is in tools/test.py's option, the runner cannot correctly buid the evaluator.For example:
My config file

test_evaluator = dict(
    type='MultiDatasetsEvaluator',
    metrics=[
        dict(
            type='WordMetric',
            mode=['exact', 'ignore_case', 'ignore_case_symbol']),
        dict(type='CharMetric')
    ],
    dataset_prefixes=None)

My test script

python tools/test.py \
work_dirs/master_resnet31_12e.py \
work_dirs/best_ocr_rec_1_recog_char_f1_epoch_980.pth \
--save-preds

the --save-preds option will concat the evaluator with a DumpResults instance in a wrong way,the new evaluator is like:

test_evaluator = [
dict(type='MultiDatasetsEvaluator',
    metrics=[
        dict(
            type='WordMetric',
            mode=['exact', 'ignore_case', 'ignore_case_symbol']),
        dict(type='CharMetric')
    ],
    dataset_prefixes=None),
dict(
    type='DumpResults',
    out_file_path='my_work_dir')
]

This new test_evaluator cannot be built by program.

After updating the tools/test.py, using the same config and test scripts, the new test_evaluator will be:

test_evaluator = [
dict(type='MultiDatasetsEvaluator',
    metrics=[
        dict(
            type='WordMetric',
            mode=['exact', 'ignore_case', 'ignore_case_symbol']),
        dict(type='CharMetric'),
        dict(
            type='DumpResults',
            out_file_path='my_work_dir')
    ],
    dataset_prefixes=None)
]

This new test_evaluator can be built correctly by program.

Checklist

Before PR:

  • I have read and followed the workflow indicated in the CONTRIBUTING.md to create this PR.
  • Pre-commit or linting tools indicated in CONTRIBUTING.md are used to fix the potential lint issues.
  • Bug fixes are covered by unit tests, the case that causes the bug should be added in the unit tests.
  • New functionalities are covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, including docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with some of those projects.
  • CLA has been signed and all committers have signed the CLA in this PR.

@CLAassistant
Copy link

CLAassistant commented May 31, 2024

CLA assistant check
All committers have signed the CLA.

tools/test.py Outdated Show resolved Hide resolved
@gaotongxiao gaotongxiao merged commit e9d5b46 into open-mmlab:dev-1.x Jun 2, 2024
3 of 10 checks passed
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.

3 participants