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

direct predict option for inference and minor fixes #151

Merged
merged 8 commits into from
Dec 18, 2021

Conversation

georgeyiasemis
Copy link
Contributor

  • Implement direct predict option for inference from cli
  • Other minor fixes

@georgeyiasemis georgeyiasemis linked an issue Dec 17, 2021 that may be closed by this pull request
No longer needed. Funcionality now covered by `direct predict`.
Comment on lines +28 to +71
common_parser = Args(add_help=False)
predict_parser = parser.add_parser(
"predict",
help="Run inference using direct.",
parents=[common_parser],
epilog=epilog,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
predict_parser.add_argument("data_root", type=pathlib.Path, help="Path to the inference data directory.")
predict_parser.add_argument("output_directory", type=pathlib.Path, help="Path to the output directory.")
predict_parser.add_argument(
"experiment_directory",
type=pathlib.Path,
help="Path to the directory with checkpoints and config.",
)
predict_parser.add_argument(
"--checkpoint",
type=int,
required=True,
help="Number of an existing checkpoint in experiment directory.",
)
predict_parser.add_argument(
"--filenames-filter",
type=pathlib.Path,
help="Path to list of filenames to parse.",
)
predict_parser.add_argument(
"--name",
dest="name",
help="Run name if this is different than the experiment directory.",
required=False,
type=str,
default="",
)
predict_parser.add_argument(
"--cfg",
dest="cfg_file",
help="Config file for inference. Can be either a local file or a remote URL."
"Only use it to overwrite the standard loading of the config in the project directory.",
required=False,
type=file_or_url,
)

predict_parser.set_defaults(subcommand=predict_from_argparse)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this all required for a predict script? Ideally shouldn't you ingest a file (or a number of files)? That'd be more useful, so don't use filenames_filter, but take a filename or a regex. Would that work? The --checkpoint can be replaced by --checkpoint-no and --checkpoint-path where the latter accepts a full path. We can additionally use environmental variables to do it.

setup.py Outdated
@@ -46,6 +46,7 @@
"ismrmrd==1.9.1",
"tensorboard>=2.5.0",
"tqdm",
"sewar",
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps don't add sewar, it's only for the VIF. You can use a mechanism such as https://github.com/NKI-AI/dlup/blob/main/dlup/utils/imports.py to check if it is there and otherwise give a RunTimeError when you try to run the Calgary Campinas or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I don't really agree as you may want to run C-C but withouf VIF. Maybe if "calgary_campinas_vif_metric" is requested as an evaluation metric.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. But then it must crash before it is at the validation step. E.g. when building metrics.

@codecov
Copy link

codecov bot commented Dec 17, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@2f0c6ac). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #151   +/-   ##
=======================================
  Coverage        ?   28.28%           
=======================================
  Files           ?       80           
  Lines           ?     6647           
  Branches        ?        0           
=======================================
  Hits            ?     1880           
  Misses          ?     4767           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f0c6ac...87aac10. Read the comment docs.

@jonasteuwen jonasteuwen merged commit 7585ab9 into main Dec 18, 2021
@jonasteuwen jonasteuwen deleted the cli-predict-feature branch December 18, 2021 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

direct predict from cli
2 participants