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

Override inference parameters (model architecture, num bands, num classes) from checkpoint #298

Merged
merged 20 commits into from
Mar 29, 2022

Conversation

remtav
Copy link
Collaborator

@remtav remtav commented Mar 24, 2022

fixes #183

This feature will make it possible once again to launch an inference from 2 simple arguments:

path/url to image
path/url to model checkpoint

remtav added 19 commits March 22, 2022 14:15
add tests for optimizer instantiation in test_optimizers.py
adapt our unet models (models/unet.py) to expect same parameter names as smp models
…handling for checkpoints from different gdl versions

fixes NRCan#183
…handling for checkpoints from different gdl versions

fixes NRCan#183
…to 183-inference-model-override

# Conflicts:
#	inference_segmentation.py
add tests for optimizer instantiation in test_optimizers.py
adapt our unet models (models/unet.py) to expect same parameter names as smp models
add tests for optimizer instantiation in test_optimizers.py
adapt our unet models (models/unet.py) to expect same parameter names as smp models
# Conflicts:
#	config/model/smp_unet.yaml
#	inference_segmentation.py
#	models/model_choice.py
#	train_segmentation.py
@remtav remtav changed the title 183 inference model override Override inference parameters (model architecture, num bands, num classes) from checkpoint Mar 24, 2022
@remtav remtav marked this pull request as ready for review March 24, 2022 18:50
GDL.py Outdated
@@ -32,6 +36,11 @@ def run_gdl(cfg: DictConfig) -> None:
"""
cfg = OmegaConf.create(cfg)

# Couldn't find a better way to do this. Ideally a return_hydra_config could be set in @hydra.main decorator...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are already in the yaml under general.config_name and general.config_path


if model_ckpt != params.model or classes_ckpt != classes or modalities_ckpt != modalities:
logging.warning(f"\nParameters from checkpoint will override inputted parameters."
f"\n\t\t\t Inputted | Overriden"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a parameter read from the hydra config is overridden on the commandline, that will still be overridden by the checkpoint right ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep!

@remtav remtav merged commit aafaa17 into NRCan:develop Mar 29, 2022
@remtav remtav deleted the 183-inference-model-override branch March 29, 2022 16:31
remtav added a commit to remtav/geo-deep-learning that referenced this pull request Jul 5, 2022
…sses) from checkpoint (NRCan#298)

* fixes NRCan#293 NRCan#246
add tests for optimizer instantiation in test_optimizers.py
adapt our unet models (models/unet.py) to expect same parameter names as smp models

* minor typo fixes

* implement overriding model params from checkpoint with minimal error handling for checkpoints from different gdl versions
fixes NRCan#183

* name model yamls as close as possible to upcoming naming convention

* fix model name

* implement overriding model params from checkpoint with minimal error handling for checkpoints from different gdl versions
fixes NRCan#183

* small bugfix for pointing to parameters inside checkpoint

* model_choice.py: add update checkpoint utility

* fixes NRCan#293 NRCan#246
add tests for optimizer instantiation in test_optimizers.py
adapt our unet models (models/unet.py) to expect same parameter names as smp models

* minor typo fixes

* name model yamls as close as possible to upcoming naming convention

* small bugfix for pointing to parameters inside checkpoint

* remove deeplabv3 dualhead warning and add link for deeplabv3_dualhead.py

* fixes NRCan#293 NRCan#246
add tests for optimizer instantiation in test_optimizers.py
adapt our unet models (models/unet.py) to expect same parameter names as smp models

* name model yamls as close as possible to upcoming naming convention

* minor typo fixes

* update to PR 295

* GDL.py: restore to previous commit based on cauthier's comment
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.

Inference: run inference without yaml
4 participants