-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
allow bbox in occ sens constructor #5169
Open
rijobro
wants to merge
1
commit into
Project-MONAI:dev
Choose a base branch
from
rijobro:occ_sens_bbox
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -152,6 +152,7 @@ def __init__( | |||||
per_channel: bool = True, | ||||||
upsampler: Optional[Callable] = default_upsampler, | ||||||
verbose: bool = True, | ||||||
bbox: Optional[Sequence] = None | ||||||
) -> None: | ||||||
"""Occlusion sensitivity constructor. | ||||||
|
||||||
|
@@ -172,6 +173,12 @@ def __init__( | |||||
N-dimensional linear (bilinear, trilinear, etc.) depending on num spatial | ||||||
dimensions of input. | ||||||
verbose: Use ``tqdm.trange`` output (if available). | ||||||
b_box: Bounding box on which to perform the analysis. The output image will be limited to this size. | ||||||
There should be a minimum and maximum for all dimensions except batch: ``[min1, max1, min2, max2,...]``. | ||||||
* By default, the whole image will be used. Decreasing the size will speed the analysis up, which might | ||||||
be useful for larger images. | ||||||
* Min and max are inclusive, so ``[0, 63, ...]`` will have size ``(64, ...)``. | ||||||
* Use -ve to use ``min=0`` and ``max=im.shape[x]-1`` for xth dimension. | ||||||
""" | ||||||
|
||||||
self.nn_module = nn_module | ||||||
|
@@ -182,6 +189,7 @@ def __init__( | |||||
self.stride = stride | ||||||
self.per_channel = per_channel | ||||||
self.verbose = verbose | ||||||
self.bbox = bbox | ||||||
|
||||||
def _compute_occlusion_sensitivity(self, x, b_box): | ||||||
|
||||||
|
@@ -298,6 +306,7 @@ def __call__(self, x: torch.Tensor, b_box: Optional[Sequence] = None) -> Tuple[t | |||||
* The most probable class when the corresponding part of the image is occluded (``argmax(dim=-1)``). | ||||||
Both images will be cropped if a bounding box used, but voxel sizes will always match the input. | ||||||
""" | ||||||
bbox = bbox if bbox is not None else self.bbox | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the method is currently using
Suggested change
|
||||||
|
||||||
with eval_mode(self.nn_module): | ||||||
|
||||||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the doc-string and code in consistent: "bbox" vs "b_box".
I would suggest
b_box
as the existing arg isb_box
.Thanks.