Implement SlidingWindowHoVerNetInferer#5531
Conversation
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
myron
left a comment
There was a problem hiding this comment.
@drbeh thanks for the PR, but this adds a lot of extra code to cover some special edge case. I don't think it should be inside of SlidingWindowInferrer (which job should be just to slide over image, and return the result)
I suggest to either a) create a subclass/another-class for hovernet b) or add an options to SlidingWindowInferrer e.g. callback: callable = None. and if that function is provided, it'll be applied to every patch, then from hover net you can define that callback to do your padding.
@myron thanks for your comment. I see your point but the current The weird design of this class (implementing everything in one single function and then calling it) does not allow any subclassing or modular use of it, so all the code should be copies for any extension, which will create a lot of duplicity and make the maintenance hard. Regarding the use of handlers, as we want to use this in a bundle, it seems that they way that bundles are consumed by MONAI Label [and MOANI Deploy] does not like use of handlers and they will be ignored: https://github.com/Project-MONAI/MONAILabel/blob/809b8d20168ef5043490d55b53f284c15aeadedb/monailabel/tasks/infer/bundle.py |
Signed-off-by: Behrooz <[email protected]>
@drbeh I understand what you mean, thank you. that case, when the output is corrected by scaling is also in the wrong place IMHO, and should be removed. it seems everyone just keep adding special new options (to satisfy their edge case). I agree we should refactor this class SlidingWindowInference to simplify it and to allow subclasses to add functionality without copying code) for your PR, if sub-classing/refactor is not possible, I recommend to use callback/handlers for your edge case. You can minimally modify the SlidingWindowInference to accept a callback function (as an optional input), then create another new small class SlidingForHovernet (could be inside of HoVerNet file actually) - which will call SlidingWindowInference with provided callback. Then you can provide this SlidingForHovernet for inference for MONAI Label. Let me know if you think of a better way |
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
…nto update-slidingwindowinfere
|
@myron I totally agree with you that we should separate the functionalities and a refactoring is definitely needed. I made some changes that I think it is aligned with that you said. I have created another class |
SlidingWindowInferenceSlidingWindowHoVerNetInference
SlidingWindowHoVerNetInferenceSlidingWindowHoVerNetInferer
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
…nto update-slidingwindowinfere
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
…nto update-slidingwindowinfere
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
wyli
left a comment
There was a problem hiding this comment.
thanks, I put some comments inline, I haven't checked this PR as part of any inference pipeline.
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
|
/build |
Fixes Project-MONAI#5521 ### Description This PR implement `SlidingWindowHoVerNetInferer` that with HoVerNet model, where the output size is different than the input but cannot be scaled and should be padded and then cropped. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [x] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. Signed-off-by: Behrooz <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Signed-off-by: Behrooz <[email protected]>
Fixes #5521
Description
This PR implement
SlidingWindowHoVerNetInfererthat with HoVerNet model, where the output size is different than the input but cannot be scaled and should be padded and then cropped.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.