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

Feature: Add predict command to CLI #281

Merged
merged 10 commits into from
Dec 2, 2024
Merged

Feature: Add predict command to CLI #281

merged 10 commits into from
Dec 2, 2024

Conversation

melisande-c
Copy link
Member

@melisande-c melisande-c commented Nov 26, 2024

Description

  • What: Implement CLI predict command.
  • Why: Previously calling the CLI predict command would raise NotImplementedError.
  • How: A given checkpoint is loaded, then the CAREamist.predict_to_disk is called with optional parameters. Using Typer.

Changes Made

  • Added:
    • CLI predict command in careamics/cli/main.py.
    • Tests for CLI predict command.
  • Modified:
    • CAREamist.predict_to_disk: fixed bug relating to prediction output directory structure for a single file + some reorganisation.
    • For CLI replaced patch_size_callback with handle_2D_3D_callback, moved to careamics/cli/utils.py. (Typer can only handle fixed sized inputs so this callback is used for a parameter like tile_size that can be 2D or 3D).
    • predict_to_disk tests. Predictions are saved directly to the selected predictions output directory (Not in a second level internal directory).

Additional Notes and Examples

Calling the train and predict command (for a N2V config) is as follows

$ careamics train <CONFIG PATH> -ts <TRAIN DATA PATH>
$ careamics predict checkpoints/<EXPERIMENT NAME>.ckpt <TEST DATA PATH>

Also, please note that CAREamist.predict_to_disk is quite messy but it should be replaced soon when the `PredictionWriterCallback is complete.


  • Code builds and passes tests locally, including doctests
  • New tests have been added (for bug fixes/features)
  • Pre-commit passes
  • PR to the documentation exists (for bug fixes / features)

@melisande-c melisande-c marked this pull request as draft November 26, 2024 17:40
@melisande-c melisande-c marked this pull request as ready for review November 27, 2024 16:46
@melisande-c melisande-c requested a review from a team November 27, 2024 16:46
@jdeschamps jdeschamps merged commit 19d9203 into main Dec 2, 2024
18 checks passed
@jdeschamps jdeschamps deleted the mc/feat/cli-predict branch December 2, 2024 10:45
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.

2 participants