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

Modify MeanEnsemble to accumulate results in-place #8140

Closed
wants to merge 58 commits into from
Closed
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
afae503
Fixes #7557
May 14, 2024
542a77d
Fixes #7557
May 14, 2024
e9f7565
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 14, 2024
7969d21
Fixes #7557
May 14, 2024
3ce5f30
Fixes #7557
May 14, 2024
0699eeb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 14, 2024
274cd04
fix-issue-7557
Jun 1, 2024
d4fb0b7
fix-issue-7557
Jun 1, 2024
bfb6d58
Fixes #7557
Jun 1, 2024
5ab2521
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 1, 2024
894854d
Fixes #7557
Jun 1, 2024
c372225
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 1, 2024
682379b
Fixes #7557
Jun 3, 2024
56d8df5
Fixes #7557
Jun 3, 2024
8bab11b
Fixes #7557
Jun 3, 2024
ca48fec
fix-issue-7557
Jun 3, 2024
117dd78
fix-issue-7557
Jun 13, 2024
3908cdd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 13, 2024
36e5af0
fix-issue-7557
Jun 13, 2024
1a3da38
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 13, 2024
37d19ed
fix-issue-7557
Jun 13, 2024
cff2926
fix-issue-7557
Jul 15, 2024
33c078b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2024
40b3e21
fix-issue-7557
Jul 21, 2024
36047a2
fix-issue-7557
Jul 21, 2024
b385288
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 21, 2024
3937448
fix-issue-7557
Jul 21, 2024
dc8645f
Merge branch 'dev' into fix-issue-7557
staydelight Jul 21, 2024
44307fc
fix-issue-7557
Jul 22, 2024
cdf4a1b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 22, 2024
5dd268e
fix-issue-7557
Jul 25, 2024
401557a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2024
476e15e
Merge branch 'dev' into fix-issue-7557
staydelight Jul 31, 2024
4adb87d
fix-issue-7557
Aug 6, 2024
f073c64
Merge branch 'dev' into fix-issue-7557
staydelight Aug 6, 2024
0c14f4f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 6, 2024
8fafc05
fix-issue-7557
Aug 6, 2024
b238987
fix-issue-7557
Aug 6, 2024
5c75990
fix-issue-7557
Aug 7, 2024
8a5e7f1
Merge branch 'Project-MONAI:dev' into fix-issue-7557
staydelight Aug 19, 2024
f7deb86
fix-issue-7557
Aug 19, 2024
3607b18
fix-issue-7557
Aug 19, 2024
130eaa1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 19, 2024
b1475be
fix-issue-7557
Aug 19, 2024
05a00fc
Merge branch 'Project-MONAI:dev' into fix-issue-7557
staydelight Aug 27, 2024
ca15156
fix-issue-7557
Aug 27, 2024
3dc9f49
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 27, 2024
3ea0df2
fix-issue-7557
Aug 27, 2024
8ad9808
fix-issue-7557
Aug 27, 2024
802e554
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 27, 2024
60f5b79
fix-issue-7557
Aug 27, 2024
b7957b6
fix-issue-7557
Aug 27, 2024
773a218
fix-issue-7557
Aug 27, 2024
b28b184
fix-issue-7557
Aug 28, 2024
6f9e440
fix-issue-6366
Oct 11, 2024
6432c00
'fix-issue-6366'
Oct 11, 2024
2fd93eb
fix-issue-6366
Oct 11, 2024
020720d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions monai/transforms/post/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,18 +679,22 @@ def __init__(self, weights: Sequence[float] | NdarrayOrTensor | None = None) ->
self.weights = torch.as_tensor(weights, dtype=torch.float) if weights is not None else None

def __call__(self, img: Sequence[NdarrayOrTensor] | NdarrayOrTensor) -> NdarrayOrTensor:
img_ = self.get_stacked_torch(img)
if self.weights is not None:
self.weights = self.weights.to(img_.device)
shape = tuple(self.weights.shape)
for _ in range(img_.ndimension() - self.weights.ndimension()):
shape += (1,)
weights = self.weights.reshape(*shape)
out_pt = None
total_weight = 0.0

img_ = img_ * weights / weights.mean(dim=0, keepdim=True)
for i, pred in enumerate(img):
pred = torch.as_tensor(pred)
if out_pt is None:
out_pt = torch.zeros_like(pred)

out_pt = torch.mean(img_, dim=0)
return self.post_convert(out_pt, img)
if self.weights is not None:
weight = self.weights[i].to(pred.device)

out_pt += pred * weight
total_weight += weight

out_pt /= total_weight
return post_convert(out_pt, img)


class VoteEnsemble(Ensemble, Transform):
Expand Down
Loading