Skip to content

Commit d020fac

Browse files
ericspodmarksgrahamKumoLiupre-commit-ci[bot]vgrau98
authored
Merge genaidev Into Dev (#7886)
Fixes #6676 . ### Description This merges the Generative Models code into dev. Everything has been checked by the generative team, tests all pass, and the changes that have been done recently are integrated. This is ready to merge. ### 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). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [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. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Mark Graham <[email protected]> Signed-off-by: KumoLiu <[email protected]> Signed-off-by: YunLiu <[email protected]> Signed-off-by: Mark Graham <[email protected]> Signed-off-by: vgrau98 <[email protected]> Signed-off-by: vgrau98 <[email protected]> Signed-off-by: Wenqi Li <[email protected]> Signed-off-by: dongy <[email protected]> Signed-off-by: myron <[email protected]> Signed-off-by: kaibo <[email protected]> Signed-off-by: monai-bot <[email protected]> Signed-off-by: elitap <[email protected]> Signed-off-by: Felix Schnabel <[email protected]> Signed-off-by: YanxuanLiu <[email protected]> Signed-off-by: ytl0623 <[email protected]> Signed-off-by: Dženan Zukić <[email protected]> Signed-off-by: Ishan Dutta <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: heyufan1995 <[email protected]> Signed-off-by: binliu <[email protected]> Signed-off-by: axel.vlaminck <[email protected]> Signed-off-by: Ibrahim Hadzic <[email protected]> Signed-off-by: Behrooz <[email protected]> Signed-off-by: Timothy Baker <[email protected]> Signed-off-by: Mathijs de Boer <[email protected]> Signed-off-by: Fabian Klopfer <[email protected]> Signed-off-by: Lucas Robinet <[email protected]> Signed-off-by: Lucas Robinet <[email protected]> Signed-off-by: chaoliu <[email protected]> Signed-off-by: cxlcl <[email protected]> Signed-off-by: chaoliu <[email protected]> Signed-off-by: Suraj Pai <[email protected]> Signed-off-by: Juan Pablo de la Cruz Gutiérrez <[email protected]> Signed-off-by: John Zielke <[email protected]> Signed-off-by: Mingxin Zheng <[email protected]> Signed-off-by: Vladimir Chernyi <[email protected]> Signed-off-by: Yiheng Wang <[email protected]> Signed-off-by: Szabolcs Botond Lorincz Molnar <[email protected]> Signed-off-by: Lucas Robinet <[email protected]> Signed-off-by: Mingxin <[email protected]> Signed-off-by: Han Wang <[email protected]> Signed-off-by: Konstantin Sukharev <[email protected]> Signed-off-by: Ben Murray <[email protected]> Signed-off-by: Matthew Vine <[email protected]> Signed-off-by: Peter Kaplinsky <[email protected]> Signed-off-by: Simon Jensen <[email protected]> Signed-off-by: NabJa <[email protected]> Signed-off-by: virginiafdez <[email protected]> Signed-off-by: Eric Kerfoot <[email protected]> Signed-off-by: Eric Kerfoot <[email protected]> Co-authored-by: Mark Graham <[email protected]> Co-authored-by: YunLiu <[email protected]> Co-authored-by: KumoLiu <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: vgrau98 <[email protected]> Co-authored-by: Wenqi Li <[email protected]> Co-authored-by: Dong Yang <[email protected]> Co-authored-by: myron <[email protected]> Co-authored-by: Kaibo Tang <[email protected]> Co-authored-by: monai-bot <[email protected]> Co-authored-by: elitap <[email protected]> Co-authored-by: Felix Schnabel <[email protected]> Co-authored-by: YanxuanLiu <[email protected]> Co-authored-by: ytl0623 <[email protected]> Co-authored-by: Dženan Zukić <[email protected]> Co-authored-by: Ishan Dutta <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kaibo Tang <[email protected]> Co-authored-by: Yufan He <[email protected]> Co-authored-by: binliunls <[email protected]> Co-authored-by: Ben Murray <[email protected]> Co-authored-by: axel.vlaminck <[email protected]> Co-authored-by: Mingxin Zheng <[email protected]> Co-authored-by: Ibrahim Hadzic <[email protected]> Co-authored-by: Dr. Behrooz Hashemian <[email protected]> Co-authored-by: Timothy J. Baker <[email protected]> Co-authored-by: Mathijs de Boer <[email protected]> Co-authored-by: Mathijs de Boer <[email protected]> Co-authored-by: Fabian Klopfer <[email protected]> Co-authored-by: Yiheng Wang <[email protected]> Co-authored-by: Lucas Robinet <[email protected]> Co-authored-by: Lucas Robinet <[email protected]> Co-authored-by: cxlcl <[email protected]> Co-authored-by: Suraj Pai <[email protected]> Co-authored-by: Juampa <[email protected]> Co-authored-by: johnzielke <[email protected]> Co-authored-by: Vladimir Chernyi <[email protected]> Co-authored-by: Lőrincz-Molnár Szabolcs-Botond <[email protected]> Co-authored-by: Nic Ma <[email protected]> Co-authored-by: Lucas Robinet <[email protected]> Co-authored-by: Han Wang <[email protected]> Co-authored-by: Konstantin Sukharev <[email protected]> Co-authored-by: Matthew Vine <[email protected]> Co-authored-by: Pkaps25 <[email protected]> Co-authored-by: Peter Kaplinsky <[email protected]> Co-authored-by: Simon Jensen <[email protected]> Co-authored-by: NabJa <[email protected]> Co-authored-by: Virginia Fernandez <[email protected]> Co-authored-by: virginiafdez <[email protected]> Co-authored-by: Yu <[email protected]>
1 parent 46e2b0e commit d020fac

File tree

86 files changed

+16359
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+16359
-178
lines changed

docs/source/engines.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ Workflows
3030
.. autoclass:: GanTrainer
3131
:members:
3232

33+
`AdversarialTrainer`
34+
~~~~~~~~~~~~~~~~~~~~
35+
.. autoclass:: AdversarialTrainer
36+
:members:
37+
3338
`Evaluator`
3439
~~~~~~~~~~~
3540
.. autoclass:: Evaluator

docs/source/inferers.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,29 @@ Inferers
4949
:members:
5050
:special-members: __call__
5151

52+
`DiffusionInferer`
53+
~~~~~~~~~~~~~~~~~~
54+
.. autoclass:: DiffusionInferer
55+
:members:
56+
:special-members: __call__
57+
58+
`LatentDiffusionInferer`
59+
~~~~~~~~~~~~~~~~~~~~~~~~
60+
.. autoclass:: LatentDiffusionInferer
61+
:members:
62+
:special-members: __call__
63+
64+
`ControlNetDiffusionInferer`
65+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66+
.. autoclass:: ControlNetDiffusionInferer
67+
:members:
68+
:special-members: __call__
69+
70+
`ControlNetLatentDiffusionInferer`
71+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72+
.. autoclass:: ControlNetLatentDiffusionInferer
73+
:members:
74+
:special-members: __call__
5275

5376
Splitters
5477
---------

docs/source/utils.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,8 @@ Component store
8181
---------------
8282
.. autoclass:: monai.utils.component_store.ComponentStore
8383
:members:
84+
85+
Ordering
86+
--------
87+
.. automodule:: monai.utils.ordering
88+
:members:

monai/apps/detection/utils/anchor_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def generate_anchors(
189189
w_ratios = 1 / area_scale
190190
h_ratios = area_scale
191191
# if 3d, w:h:d = 1:aspect_ratios[:,0]:aspect_ratios[:,1]
192-
elif self.spatial_dims == 3:
192+
else:
193193
area_scale = torch.pow(aspect_ratios_t[:, 0] * aspect_ratios_t[:, 1], 1 / 3.0)
194194
w_ratios = 1 / area_scale
195195
h_ratios = aspect_ratios_t[:, 0] / area_scale
@@ -199,7 +199,7 @@ def generate_anchors(
199199
hs = (h_ratios[:, None] * scales_t[None, :]).view(-1)
200200
if self.spatial_dims == 2:
201201
base_anchors = torch.stack([-ws, -hs, ws, hs], dim=1) / 2.0
202-
elif self.spatial_dims == 3:
202+
else: # elif self.spatial_dims == 3:
203203
ds = (d_ratios[:, None] * scales_t[None, :]).view(-1)
204204
base_anchors = torch.stack([-ws, -hs, -ds, ws, hs, ds], dim=1) / 2.0
205205

monai/apps/pathology/transforms/post/array.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ def _generate_contour_coord(self, current: np.ndarray, previous: np.ndarray) ->
379379
"""
380380

381381
p_delta = (current[0] - previous[0], current[1] - previous[1])
382+
row, col = -1, -1
382383

383384
if p_delta in ((0.0, 1.0), (0.5, 0.5), (1.0, 0.0)):
384385
row = int(current[0] + 0.5)

monai/bundle/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def load_bundle_config(bundle_path: str, *config_names: str, **load_kw_args: Any
221221
raise ValueError(f"Cannot find config file '{full_cname}'")
222222

223223
ardata = archive.read(full_cname)
224+
cdata = {}
224225

225226
if full_cname.lower().endswith("json"):
226227
cdata = json.loads(ardata, **load_kw_args)

monai/data/dataset_summary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def collect_meta_data(self):
8484
"""
8585

8686
for data in self.data_loader:
87+
meta_dict = {}
8788
if isinstance(data[self.image_key], MetaTensor):
8889
meta_dict = data[self.image_key].meta
8990
elif self.meta_key in data:

monai/data/utils.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
pytorch_after,
5454
)
5555

56-
if pytorch_after(1, 13):
57-
# import private code for reuse purposes, comment in case things break in the future
58-
from torch.utils.data._utils.collate import collate_tensor_fn, default_collate_fn_map
59-
6056
pd, _ = optional_import("pandas")
6157
DataFrame, _ = optional_import("pandas", name="DataFrame")
6258
nib, _ = optional_import("nibabel")
@@ -454,8 +450,13 @@ def collate_meta_tensor_fn(batch, *, collate_fn_map=None):
454450
Collate a sequence of meta tensor into a single batched metatensor. This is called by `collage_meta_tensor`
455451
and so should not be used as a collate function directly in dataloaders.
456452
"""
457-
collate_fn = collate_tensor_fn if pytorch_after(1, 13) else default_collate
458-
collated = collate_fn(batch) # type: ignore
453+
if pytorch_after(1, 13):
454+
from torch.utils.data._utils.collate import collate_tensor_fn # imported here for pylint/mypy issues
455+
456+
collated = collate_tensor_fn(batch)
457+
else:
458+
collated = default_collate(batch)
459+
459460
meta_dicts = [i.meta or TraceKeys.NONE for i in batch]
460461
common_ = set.intersection(*[set(d.keys()) for d in meta_dicts if isinstance(d, dict)])
461462
if common_:
@@ -496,6 +497,8 @@ def list_data_collate(batch: Sequence):
496497

497498
if pytorch_after(1, 13):
498499
# needs to go here to avoid circular import
500+
from torch.utils.data._utils.collate import default_collate_fn_map
501+
499502
from monai.data.meta_tensor import MetaTensor
500503

501504
default_collate_fn_map.update({MetaTensor: collate_meta_tensor_fn})

monai/engines/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
from __future__ import annotations
1313

1414
from .evaluator import EnsembleEvaluator, Evaluator, SupervisedEvaluator
15-
from .trainer import GanTrainer, SupervisedTrainer, Trainer
15+
from .trainer import AdversarialTrainer, GanTrainer, SupervisedTrainer, Trainer
1616
from .utils import (
17+
DiffusionPrepareBatch,
1718
IterationEvents,
1819
PrepareBatch,
1920
PrepareBatchDefault,
2021
PrepareBatchExtraInput,
22+
VPredictionPrepareBatch,
2123
default_make_latent,
2224
default_metric_cmp_fn,
2325
default_prepare_batch,

0 commit comments

Comments
 (0)