GANDLF 0.1.4__py3-none-any.whl → 0.1.6.dev20251109__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of GANDLF might be problematic. Click here for more details.

@@ -34,7 +34,7 @@ class DefaultParameters(BaseModel):
34
34
  default=10, description="Number of samples per volume."
35
35
  )
36
36
  q_num_workers: int = Field(
37
- default=4, description="Number of worker threads to use."
37
+ default=0, description="Number of worker threads to use."
38
38
  )
39
39
  num_epochs: int = Field(default=100, description="Total number of epochs to train.")
40
40
  patience: int = Field(
@@ -84,7 +84,9 @@ schedulers_dict_config = {
84
84
  "reduce-on-plateau": ReduceOnPlateauConfig,
85
85
  "plateau": ReduceOnPlateauConfig,
86
86
  "reduceonplateau": ReduceOnPlateauConfig,
87
+ "cosineannealingwarmrestarts": CosineannealingConfig,
87
88
  "cosineannealing": CosineannealingConfig,
89
+ "cosineannealinglr": CosineannealingConfig,
88
90
  "warmupcosineschedule": WarmupcosinescheduleConfig,
89
91
  "wcs": WarmupcosinescheduleConfig,
90
92
  }
@@ -1713,7 +1713,7 @@ class GandlfLightningModule(pl.LightningModule):
1713
1713
  print(f"Previous latest model loaded from {self.model_paths['latest']}.")
1714
1714
  else:
1715
1715
  raise RuntimeError(
1716
- "No model found to load. Please train the model before running inference."
1716
+ f"Best/latest models not found to load: {self.model_paths}"
1717
1717
  )
1718
1718
 
1719
1719
  @rank_zero_only
@@ -6,7 +6,8 @@ from .wrap_torch import (
6
6
  exp,
7
7
  step,
8
8
  reduce_on_plateau,
9
- cosineannealing,
9
+ cosineannealingwarmrestarts,
10
+ cosineannealingLR,
10
11
  )
11
12
 
12
13
  from .wrap_monai import warmupcosineschedule
@@ -24,7 +25,9 @@ global_schedulers_dict = {
24
25
  "reduce-on-plateau": reduce_on_plateau,
25
26
  "plateau": reduce_on_plateau,
26
27
  "reduceonplateau": reduce_on_plateau,
27
- "cosineannealing": cosineannealing,
28
+ "cosineannealing": cosineannealingwarmrestarts,
29
+ "cosineannealingwarmrestarts": cosineannealingwarmrestarts,
30
+ "cosineannealinglr": cosineannealingLR,
28
31
  "warmupcosineschedule": warmupcosineschedule,
29
32
  "wcs": warmupcosineschedule,
30
33
  }
@@ -5,6 +5,7 @@ from torch.optim.lr_scheduler import (
5
5
  StepLR,
6
6
  ReduceLROnPlateau,
7
7
  CosineAnnealingWarmRestarts,
8
+ CosineAnnealingLR,
8
9
  )
9
10
  import math
10
11
 
@@ -169,14 +170,25 @@ def reduce_on_plateau(parameters):
169
170
  )
170
171
 
171
172
 
172
- def cosineannealing(parameters):
173
+ def cosineannealingwarmrestarts(parameters):
173
174
  parameters["scheduler"]["T_0"] = parameters["scheduler"].get("T_0", 5)
174
175
  parameters["scheduler"]["T_mult"] = parameters["scheduler"].get("T_mult", 1)
175
- parameters["scheduler"]["min_lr"] = parameters["scheduler"].get("min_lr", 0.001)
176
+ parameters["scheduler"]["eta_min"] = parameters["scheduler"].get("eta_min", 0.001)
176
177
 
177
178
  return CosineAnnealingWarmRestarts(
178
179
  parameters["optimizer_object"],
179
180
  T_0=parameters["scheduler"]["T_0"],
180
181
  T_mult=parameters["scheduler"]["T_mult"],
181
- eta_min=parameters["scheduler"]["min_lr"],
182
+ eta_min=parameters["scheduler"]["eta_min"],
183
+ )
184
+
185
+
186
+ def cosineannealingLR(parameters):
187
+ parameters["scheduler"]["T_max"] = parameters["scheduler"].get("T_max", 50)
188
+ parameters["scheduler"]["eta_min"] = parameters["scheduler"].get("eta_min", 0.001)
189
+
190
+ return CosineAnnealingLR(
191
+ parameters["optimizer_object"],
192
+ T_max=parameters["scheduler"]["T_max"],
193
+ eta_min=parameters["scheduler"]["eta_min"],
182
194
  )
GANDLF/utils/modelio.py CHANGED
@@ -175,7 +175,9 @@ def load_model(
175
175
  Returns:
176
176
  dict: Model dictionary containing model parameters and metadata.
177
177
  """
178
- model_dict = torch.load(path, map_location=device)
178
+ # For PyTorch 2.7+, use weights_only=False to maintain backward compatibility
179
+ # This prevents the new security warning in PyTorch 2.7+
180
+ model_dict = torch.load(path, map_location=device, weights_only=False)
179
181
 
180
182
  # check if the model dictionary is complete
181
183
  if full_sanity_check:
GANDLF/utils/tensor.py CHANGED
@@ -290,7 +290,8 @@ def get_class_imbalance_weights_classification(
290
290
  np.fromiter(penalty_dict.values(), dtype=np.float64).sum()
291
291
  + sys.float_info.epsilon
292
292
  )
293
- for i in range(params["model"]["num_classes"]):
293
+ # Only normalize penalties for classes that actually exist in penalty_dict
294
+ for i in penalty_dict.keys():
294
295
  penalty_dict[i] /= penalty_sum
295
296
 
296
297
  # passing None for sampling_weights because there is no clear way to calculate this for classification tasks which do not have a label
GANDLF/version.py CHANGED
@@ -1,5 +1 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: UTF-8 -*-
3
-
4
- # check GaNDLF wiki for versioning and release guidelines: https://github.com/mlcommons/GaNDLF/wiki
5
- __version__ = "0.1.4"
1
+ __version__ = "0.1.6-dev20251109"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GANDLF
3
- Version: 0.1.4
3
+ Version: 0.1.6.dev20251109
4
4
  Summary: PyTorch-based framework that handles segmentation/regression/classification using various DL architectures for medical imaging.
5
5
  Author: MLCommons
6
6
  Author-email: gandlf@mlcommons.org
@@ -18,9 +18,9 @@ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
18
18
  Requires-Python: >3.9, <3.13
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
- Requires-Dist: torch==2.5.0
21
+ Requires-Dist: torch==2.7.1
22
22
  Requires-Dist: black==23.11.0
23
- Requires-Dist: lightning==2.4.0
23
+ Requires-Dist: lightning==2.5.2
24
24
  Requires-Dist: numpy==1.26.4
25
25
  Requires-Dist: scipy
26
26
  Requires-Dist: SimpleITK!=2.0.*
@@ -5,7 +5,7 @@ GANDLF/logger.py,sha256=oamQ1SOTTpAnC8vQ67o211Q6_bExGg_hAuqlHGlJfAI,2951
5
5
  GANDLF/logging_config.yaml,sha256=9XxRxAKtLn5ehT1khpR8wEiJGW64sx1lylAspM5KaWk,1337
6
6
  GANDLF/parseConfig.py,sha256=jO-ybIPxLw23OWDvFdTukbft0ZM8UOofGnoL2C5CEps,754
7
7
  GANDLF/training_manager.py,sha256=AZlf-fl7KAwZgyre8-0M5lAyma6NvtiGX6XT51AJdxU,11436
8
- GANDLF/version.py,sha256=M1zbN1EmLVtrLi5zYCd_nLaggSzKXNthBUWrc42uHo0,170
8
+ GANDLF/version.py,sha256=T_UNbVsixOTPH9NDpzIMB22zTro3LXJA38K5KwO3KJI,34
9
9
  GANDLF/anonymize/__init__.py,sha256=Nxig-jM-a-aKlK09PNi1zhNulEpLTyjnsY_oGQKdjhQ,1953
10
10
  GANDLF/anonymize/convert_to_nifti.py,sha256=MOfSDncFGJGb-EQP9sFGn0yuKpX010Ioi2KNwttaex8,1339
11
11
  GANDLF/cli/__init__.py,sha256=F05eyL2HKyWkHczRZuPE_Z2Yg685P9ARYxTwz6njGeQ,784
@@ -27,7 +27,7 @@ GANDLF/compute/loss_and_metric.py,sha256=vKta--M_2cvsqDfeGLFcE5UZNyfHYkOyjqxlc3x
27
27
  GANDLF/compute/step.py,sha256=di8zk8EgRKu5y0-Aq0aBTgrKo30SWM8wdLsnVeDaZqU,4765
28
28
  GANDLF/compute/training_loop.py,sha256=TI0aDov1K2OjbmB1LxDVtuZzbB99_wIiTu22tsH4GS0,24871
29
29
  GANDLF/configuration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- GANDLF/configuration/default_config.py,sha256=utmsmxTzyNSOz_E7SNQCxXMjbQ3H9RII-e9iBFALrb8,3069
30
+ GANDLF/configuration/default_config.py,sha256=S2h1SI2gHJbKdYtfc8fQBsB1dMIfLmYLRIcbus7p3GE,3069
31
31
  GANDLF/configuration/differential_privacy_config.py,sha256=nvLoBt11VTD_pGsQD8cmmgv-XMVZR5s0I-dkKrLhRXE,584
32
32
  GANDLF/configuration/exclude_parameters.py,sha256=rg754BoaWBMmdKVgrmFSmtsw9uw7V9Yi-VXcXPp1edY,46
33
33
  GANDLF/configuration/model_config.py,sha256=CFlTU7ypX5FzPDj-UMDDQXThHkgLeqvPEtPy79dZwdU,3313
@@ -37,7 +37,7 @@ GANDLF/configuration/parameters_config.py,sha256=p31KVVwWVjOSifWoXPuUKynzyeeUoTS
37
37
  GANDLF/configuration/patch_sampler_config.py,sha256=1CFjhB7Idfdw0ckXlyVwK-dDBKYlcuXrDi-uRdJjPA4,357
38
38
  GANDLF/configuration/post_processing_config.py,sha256=Wx1YYuKnuxP0bgN5j9rQWUk3cD4-XJ_hE3cB-7xvTpg,349
39
39
  GANDLF/configuration/pre_processing_config.py,sha256=qjaSzdsDn3M5W5j4eUN21GknTTPSFlR8b9_69dbl-m8,3322
40
- GANDLF/configuration/scheduler_config.py,sha256=OKhXBrDKAM1YFROnrDy7H_V5Zs2GRkUWzaVkWTVfEu0,3308
40
+ GANDLF/configuration/scheduler_config.py,sha256=QLuXbgpdeJrDmW5sgku2f1Qn4Q0AQtCSTeK6JQBjBno,3414
41
41
  GANDLF/configuration/user_defined_config.py,sha256=_-OejzxteociR4NM7xrtOKfWBfUmjRvNr_SMmdcZCYc,5179
42
42
  GANDLF/configuration/utils.py,sha256=p0bzaOKRvGi-beB99dBfkfl4rTDJ1F9xar78YJbii4U,3247
43
43
  GANDLF/configuration/validators.py,sha256=Mz0SmVQhF2cTyUs5Otxn_7T6L0MoaPRHPoOYimks96o,19875
@@ -125,7 +125,7 @@ GANDLF/models/imagenet_unet.py,sha256=vTAuckJ0Bs9nfe2G0nKISqgxWArIYdM4poGpTk56QY
125
125
  GANDLF/models/imagenet_vgg.py,sha256=FrMNLIxCtaMHWZ9JO7pWtoXTT1f8eVDuREx9108Aw2g,10367
126
126
  GANDLF/models/light_unet.py,sha256=jzcTHH7kv_ikriYxIe7fbQJkmwOQZzePW4KLCW2FGWM,6645
127
127
  GANDLF/models/light_unet_multilayer.py,sha256=xrKy--lljbCX7U2eYjpFZA69C6qlHmA5W-fEckPBll4,4534
128
- GANDLF/models/lightning_module.py,sha256=kZhlCSD_JLJFFqVRGUEz1CgvENWHqVgc418_fvbQdkk,83347
128
+ GANDLF/models/lightning_module.py,sha256=QLBL-QKp5DADHn8PpGjAJO4l3J7M4WI95kymPFvfGOk,83332
129
129
  GANDLF/models/modelBase.py,sha256=NFmKcEylNchm0LVqwRoD_iIMFj36IsaKwVCPJPLux3g,5752
130
130
  GANDLF/models/resnet.py,sha256=0PB7sGSLHUq2F6tyHYqxepmU1eBccSwCzBrD7Qmc280,16987
131
131
  GANDLF/models/sdnet.py,sha256=uhHvOHRTAx4ANxv2lKXfBn6Bg4Broqzb77qekVjXeFI,14528
@@ -166,9 +166,9 @@ GANDLF/privacy/opacus/config_parsing.py,sha256=1x9XTrRA-zVJI8dieVDECL-RWd4SlOsk6
166
166
  GANDLF/privacy/opacus/model_handling.py,sha256=LSFo_TtCHwFhThJ9i7agWFjxVx1aABHC3bIUVLReFPs,6437
167
167
  GANDLF/privacy/opacus/opacus_anonymization_manager.py,sha256=8VzMtezagKlkaI6x-UL7NPiXIIFQ014Iw9atsCy_46w,9549
168
168
  GANDLF/privacy/opacus/training_utils.py,sha256=ejXUIhLNjRzTebF-7uCYUluK7jyINDOpLe2yhOKacJg,3683
169
- GANDLF/schedulers/__init__.py,sha256=jMTea7kX7zawFrtjVDKHDLIfBgt7GD-G2z9_eKjI1_A,1320
169
+ GANDLF/schedulers/__init__.py,sha256=2Uni-hJKqzoRoo7B_4hhbGW1nvudhGBZc6EPBVYJnn8,1475
170
170
  GANDLF/schedulers/wrap_monai.py,sha256=_kP3ArUIFK3x3u0nQV8Gi2oPruMIGGTSZxa4bSygGPs,400
171
- GANDLF/schedulers/wrap_torch.py,sha256=NuCAmYMKgYeFzO1PEiHfnFaHpzuQU0DsK5NOi-gVxOo,6746
171
+ GANDLF/schedulers/wrap_torch.py,sha256=S0Aoo3vHEYlumgngANKGlM86fE3W15ReaWxmb4KthD8,7165
172
172
  GANDLF/utils/__init__.py,sha256=F74QIQ6dZL8cOIsZkU-VfDdcHewUW959GXRvDfphGCk,1725
173
173
  GANDLF/utils/data_splitter.py,sha256=IBVsLYo4y28G6LedbLPYWyiAUiaLxD4wWZD4EZC2D6I,10174
174
174
  GANDLF/utils/exceptions.py,sha256=SmEGzCbc5mXxjylmA9XE4PXZdmkkfOjrEh473cWTAvA,100
@@ -177,14 +177,14 @@ GANDLF/utils/generic.py,sha256=NyJgaeCdryBlHMziPPLmWtIk450u042NWQgs_qh7knw,11744
177
177
  GANDLF/utils/handle_collisions.py,sha256=UFgfrddQqeipOdpKk0Mo-wwJ-TYTESNZyXzEyQeaLdI,3082
178
178
  GANDLF/utils/imaging.py,sha256=_qCgvIXHZW_k_IUYLU95G5L5yoozxCRCYxo65TI-95U,15983
179
179
  GANDLF/utils/modelbase.py,sha256=MJ1ufJGQ-ZgfYWTg7o4f-Iz78d7SYiyxN7MT8bnNDaw,950
180
- GANDLF/utils/modelio.py,sha256=9koLUn3wCODtNOYA2abtxkqxfLgEG07Bhh-NYIrtWOc,8084
180
+ GANDLF/utils/modelio.py,sha256=xmzAn7P0kqJd_Gcf17nMcV784poW2qpi3AY483Tk2ko,8247
181
181
  GANDLF/utils/parameter_processing.py,sha256=DA7ZEsizWWLJZnCxBnDNh1NyA-bw5oirOvodiZZWbIk,5675
182
182
  GANDLF/utils/pred_target_processors.py,sha256=aatXJ6jdJaNAHa_tPzHfC1gOQrPYJLtg-cYeUFvkM_s,2701
183
- GANDLF/utils/tensor.py,sha256=AOwNTQfw9mnsomGwOF2Q_rdDS1WANlIatB0hhZN0gSg,21504
183
+ GANDLF/utils/tensor.py,sha256=SbcTyWs_qaFTnxpFlJHiq9xNKesDu7t0YZsm9eUnDSk,21565
184
184
  GANDLF/utils/write_parse.py,sha256=HROxskhet-uIdUJmz16z_7p9r0mf8hWsqQFygwZ8ap0,9202
185
- gandlf-0.1.4.dist-info/licenses/LICENSE,sha256=GlZPAfA4eckod8IVayhBXkqCpESXf6cc9BGli_Jwims,11357
186
- gandlf-0.1.4.dist-info/METADATA,sha256=qvx9jEiSPd2XFxeU3aLHp7vVrxDqtmtxG2MDkNaPZ3E,9892
187
- gandlf-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
188
- gandlf-0.1.4.dist-info/entry_points.txt,sha256=agwocNI7Upi-sFDe1rMl71dGN8YhCBB7WJmtBHRF4jg,902
189
- gandlf-0.1.4.dist-info/top_level.txt,sha256=i5D9wEbQhl085_9Lx2m7x-9Zu6nlx1tjYYbuSihG09E,7
190
- gandlf-0.1.4.dist-info/RECORD,,
185
+ gandlf-0.1.6.dev20251109.dist-info/licenses/LICENSE,sha256=GlZPAfA4eckod8IVayhBXkqCpESXf6cc9BGli_Jwims,11357
186
+ gandlf-0.1.6.dev20251109.dist-info/METADATA,sha256=OwoTI2uOcWtOPKnPAMJcAcJkq7QxpplOvVT0-nEPnpI,9904
187
+ gandlf-0.1.6.dev20251109.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
188
+ gandlf-0.1.6.dev20251109.dist-info/entry_points.txt,sha256=agwocNI7Upi-sFDe1rMl71dGN8YhCBB7WJmtBHRF4jg,902
189
+ gandlf-0.1.6.dev20251109.dist-info/top_level.txt,sha256=i5D9wEbQhl085_9Lx2m7x-9Zu6nlx1tjYYbuSihG09E,7
190
+ gandlf-0.1.6.dev20251109.dist-info/RECORD,,