Skip to content

[WIP] Add inspect_ckpt CLI command to monai.bundle (fixes #5537)#8830

Draft
Zeesejo wants to merge 8 commits intoProject-MONAI:devfrom
Zeesejo:5537-bundle-inspect-ckpt
Draft

[WIP] Add inspect_ckpt CLI command to monai.bundle (fixes #5537)#8830
Zeesejo wants to merge 8 commits intoProject-MONAI:devfrom
Zeesejo:5537-bundle-inspect-ckpt

Conversation

@Zeesejo
Copy link
Copy Markdown
Contributor

@Zeesejo Zeesejo commented Apr 17, 2026

Fixes #5537

Description

Adds python -m monai.bundle inspect_ckpt CLI command as requested in #5537.

The new function inspect_ckpt in monai/bundle/scripts.py:

  • Loads a .pt checkpoint file and prints tensor names, shapes, and dtypes
  • Optionally computes the file hash (md5 or sha256), useful when creating large_files.yml for model-zoo bundles
  • Follows the same patterns and conventions as all existing bundle CLI commands (download, verify_metadata, etc.)
  • Uses _log_input_summary for consistent CLI logging

Files changed:

  • monai/bundle/scripts.py — added inspect_ckpt function
  • monai/bundle/__init__.py — exported inspect_ckpt
  • monai/bundle/__main__.py — registered inspect_ckpt in fire CLI
  • tests/bundle/test_bundle_inspect_ckpt.py — 6 unit tests covering: key names, shapes, dtypes, md5/sha256 hashing, print_all_vars

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Zeesejo and others added 8 commits April 11, 2026 20:11
Fixes Project-MONAI#8820 - input_amplitude was incorrectly computed from `target` and target_amplitude from `input`. Corrected to match semantic meaning and standard forward(input, target) convention.

Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com>
Fixes Project-MONAI#8822 - The forward() docstring examples used `print(1-SSIMLoss()(x,y))`, but SSIMLoss already computes 1-ssim internally. The `1-` prefix made examples return ssim (not loss), misleading users into training with inverted loss.

Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com>
Adds inspect_ckpt function to analImplements the `python -m monai.bundle inspect_ckpt` CLI command
requested in issue Project-MONAI#5537.

The new `inspect_ckpt` function in `monai/bundle/scripts.py`:
- Loads a checkpoint file and displays tensor names, shapes, and dtypes
- Optionally computes the file hash (md5 or sha256), useful for
  creating large_files.yml entries in model-zoo bundles
- Follows the same patterns as other bundle CLI commands

Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com>yze checkpoint files.

Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com>
Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com>
Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com>
Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 17, 2026

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (2)
  • WIP
  • DO NOT MERGE

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e24c0949-e97a-406b-a7e9-b1fc767b1dcb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

CLI command for inspecting checkpoints

2 participants