This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
fix for loading class names when using convert (and class names are property) #1096
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.
This is to fix the bug described in issue #1076
The error occurs because when running convert, the _saved_config_file_path function will retrieve the
config.py
file, and it will try to accessclasses
property of the dataset class. However, the dataset hasn't been instantiated, so it can't access the class names.One way around it is to create a dummy dataset, and use the
classes
property of that. But it adds a few lines of code, and creating a dummy dataset only for this purpose is not ideal.Another way (the way in this PR), is to prefer to load
config.yaml
, rather thanconfig.py
. Theconfig.yaml
has the full class names directly listed because of this existing code, which is run when doing training.The implementation is very simple, just swapping
config.py
andconfig.yaml
in one line changes the order of preference for which one to use (only one is used, not both).p.s. "'config.yaml' is duplication of python config file as yaml." so it seems fine to prefer
config.yaml
overconfig.py
when running the conversion.I tested it by doing training and converting a model similar to
lm_resnet.py
, for Ilsvrc2012 dataset. By doing the change shown in this PR, it could convert.p.s. the original issue mentions DarknetQuantize. However, after doing the fix in this PR, I still get an error when converting it
AssertionError: Pooling operator pool_1_MaxPool does not match the height: 224 vs 112.
I am pretty sure it is a different error, not related to the issue of loading class names.