Skip to content

Commit e09855a

Browse files
committed
Adapt GUI to v3.3.10 of BiaPy
1 parent 69a6e45 commit e09855a

File tree

9 files changed

+510
-394
lines changed

9 files changed

+510
-394
lines changed

biapy_check_configuration.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Copied from BiaPy commit: 5505d3e3c0499fbed2e4f162e665a529931ca110
1+
## Copied from BiaPy commit: a0f3ee1e03b9e5a7d749ca029d4e8dcecc02adc1 (3.3.10)
22
import os
33
import numpy as np
44
import collections
@@ -10,6 +10,9 @@ def check_configuration(cfg, jobname, check_data_paths=True):
1010
Check if the configuration is good.
1111
"""
1212

13+
if cfg.SYSTEM.NUM_WORKERS < 0:
14+
raise ValueError("'SYSTEM.NUM_WORKERS' can not be less than 0")
15+
1316
dim_count = 2 if cfg.PROBLEM.NDIM == '2D' else 3
1417

1518
# Adjust overlap and padding in the default setting if it was not set
@@ -148,8 +151,8 @@ def check_configuration(cfg, jobname, check_data_paths=True):
148151

149152
#### General checks ####
150153
assert cfg.PROBLEM.NDIM in ['2D', '3D'], "Problem needs to be '2D' or '3D'"
151-
assert cfg.PROBLEM.TYPE in ['SEMANTIC_SEG', 'INSTANCE_SEG', 'CLASSIFICATION', 'DETECTION', 'DENOISING', 'SUPER_RESOLUTION', 'SELF_SUPERVISED'],\
152-
"PROBLEM.TYPE not in ['SEMANTIC_SEG', 'INSTANCE_SEG', 'CLASSIFICATION', 'DETECTION', 'DENOISING', 'SUPER_RESOLUTION', 'SELF_SUPERVISED']"
154+
assert cfg.PROBLEM.TYPE in ['SEMANTIC_SEG', 'INSTANCE_SEG', 'CLASSIFICATION', 'DETECTION', 'DENOISING', 'SUPER_RESOLUTION', 'SELF_SUPERVISED', 'IMAGE_TO_IMAGE'],\
155+
"PROBLEM.TYPE not in ['SEMANTIC_SEG', 'INSTANCE_SEG', 'CLASSIFICATION', 'DETECTION', 'DENOISING', 'SUPER_RESOLUTION', 'SELF_SUPERVISED', 'IMAGE_TO_IMAGE']"
153156

154157
if cfg.PROBLEM.NDIM == '3D' and cfg.TEST.FULL_IMG:
155158
print("WARNING: TEST.FULL_IMG == True while using PROBLEM.NDIM == '3D'. As 3D images are usually 'huge'"
@@ -300,9 +303,11 @@ def check_configuration(cfg, jobname, check_data_paths=True):
300303

301304
#### Super-resolution ####
302305
elif cfg.PROBLEM.TYPE == 'SUPER_RESOLUTION':
303-
if cfg.PROBLEM.SUPER_RESOLUTION.UPSCALING == 1:
306+
if not( cfg.PROBLEM.SUPER_RESOLUTION.UPSCALING ):
304307
raise ValueError("Resolution scale must be provided with 'PROBLEM.SUPER_RESOLUTION.UPSCALING' variable")
305-
assert cfg.PROBLEM.SUPER_RESOLUTION.UPSCALING in [2, 4], "PROBLEM.SUPER_RESOLUTION.UPSCALING not in [2, 4]"
308+
assert all( i > 0 for i in cfg.PROBLEM.SUPER_RESOLUTION.UPSCALING), "'PROBLEM.SUPER_RESOLUTION.UPSCALING' are not positive integers"
309+
if len(cfg.PROBLEM.SUPER_RESOLUTION.UPSCALING) != dim_count:
310+
raise ValueError(f"'PROBLEM.SUPER_RESOLUTION.UPSCALING' needs to be a tuple of {dim_count} integers")
306311
if cfg.MODEL.SOURCE == "torchvision":
307312
raise ValueError("'MODEL.SOURCE' as 'torchvision' is not available in super-resolution workflow")
308313
if cfg.DATA.NORMALIZATION.TYPE != "div":
@@ -539,15 +544,7 @@ def check_configuration(cfg, jobname, check_data_paths=True):
539544

540545
# Adjust Z_DOWN values to feature maps
541546
if all(x == 0 for x in cfg.MODEL.Z_DOWN):
542-
opts.extend(['MODEL.Z_DOWN', (2,)*(len(cfg.MODEL.FEATURE_MAPS)-1)])
543-
opts.extend(['MODEL.Z_DOWN', (2,)*(len(cfg.MODEL.FEATURE_MAPS)-1)])
544-
elif (cfg.PROBLEM.TYPE == 'SUPER_RESOLUTION' and cfg.PROBLEM.NDIM == '3D') and \
545-
any(x != 1 for x in cfg.MODEL.Z_DOWN):
546-
raise ValueError("'MODEL.Z_DOWN' != 1 not allowed in super-resolution workflow")
547547
opts.extend(['MODEL.Z_DOWN', (2,)*(len(cfg.MODEL.FEATURE_MAPS)-1)])
548-
elif (cfg.PROBLEM.TYPE == 'SUPER_RESOLUTION' and cfg.PROBLEM.NDIM == '3D') and \
549-
any(x != 1 for x in cfg.MODEL.Z_DOWN):
550-
raise ValueError("'MODEL.Z_DOWN' != 1 not allowed in super-resolution workflow")
551548
elif any([False for x in cfg.MODEL.Z_DOWN if x != 1 and x != 2]):
552549
raise ValueError("'MODEL.Z_DOWN' needs to be 1 or 2")
553550
else:
@@ -556,6 +553,10 @@ def check_configuration(cfg, jobname, check_data_paths=True):
556553
elif len(cfg.MODEL.FEATURE_MAPS)-1 != len(cfg.MODEL.Z_DOWN):
557554
raise ValueError("'MODEL.FEATURE_MAPS' length minus one and 'MODEL.Z_DOWN' length must be equal")
558555

556+
# Correct UPSCALING for other workflows than SR
557+
if len(cfg.PROBLEM.SUPER_RESOLUTION.UPSCALING) == 0:
558+
opts.extend(['PROBLEM.SUPER_RESOLUTION.UPSCALING', (1,)*dim_count])
559+
559560
if len(opts) > 0:
560561
cfg.merge_from_list(opts)
561562

biapy_config.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
## Copied from BiaPy commit: 5505d3e3c0499fbed2e4f162e665a529931ca110
1+
## Copied from BiaPy commit: a0f3ee1e03b9e5a7d749ca029d4e8dcecc02adc1 (3.3.10)
22
# Model definition variables (source BMZ/BiaPy/Torchvision) not updated yet
3-
43
import os
54
from yacs.config import CfgNode as CN
65

@@ -138,8 +137,8 @@ def __init__(self, job_dir, job_identifier):
138137

139138
### SUPER_RESOLUTION
140139
_C.PROBLEM.SUPER_RESOLUTION = CN()
141-
# Upscaling to be done to the input images. Options: [2, 4]
142-
_C.PROBLEM.SUPER_RESOLUTION.UPSCALING = 1
140+
# Upscaling to be done to the input images on every dimension. Examples: (2,2) in 2D or (2,2,2) in 3D.
141+
_C.PROBLEM.SUPER_RESOLUTION.UPSCALING = ()
143142

144143
### SELF_SUPERVISED
145144
_C.PROBLEM.SELF_SUPERVISED = CN()
@@ -410,7 +409,7 @@ def __init__(self, job_dir, job_identifier):
410409
# “no change” and 0.5 denotes “half of the axis size”.
411410
_C.AUGMENTOR.SHIFT_RANGE = (0.1, 0.2)
412411
# How to fill up the new values created with affine transformations (rotations, shear, shift and zoom).
413-
# Same meaning as in scipy: 'reflect', 'grid-mirror', 'constant', 'grid-constant', 'nearest', 'mirror',
412+
# Same meaning as in scipy: 'reflect', grid-'mirror', 'constant', 'grid-constant', 'nearest', 'mirror',
414413
# 'grid-wrap' and 'wrap'.
415414
_C.AUGMENTOR.AFFINE_MODE = 'constant'
416415
# Make vertical flips
@@ -721,7 +720,9 @@ def __init__(self, job_dir, job_identifier):
721720
# Learning rate
722721
_C.TRAIN.LR = 1.E-4
723722
# Weight decay
724-
_C.TRAIN.W_DECAY = 0.05
723+
_C.TRAIN.W_DECAY = 0.02
724+
# Coefficients used for computing running averages of gradient and its square. Used in ADAM and ADAMW optimizers
725+
_C.TRAIN.OPT_BETAS = (0.9, 0.999)
725726
# Batch size
726727
_C.TRAIN.BATCH_SIZE = 2
727728
# If memory or # gpus is limited, use this variable to maintain the effective batch size, which is

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ def __init__(self, log_file, log_dir):
317317
"MODEL__MAE_DEC_MLP_DIMS__INPUT", "MODEL__MAE_DEC_MLP_DIMS__INFO", "MODEL__MAE_DEC_MLP_DIMS__LABEL"],
318318
widgets_to_set=["transformers_label"]))
319319
self.ui.TRAIN__OPTIMIZER__INPUT.currentIndexChanged.connect(lambda: self.condition_db.combobox_hide_visible_action(self,
320-
["TRAIN__W_DECAY__INPUT", "adamw_weight_decay_label", "TRAIN__W_DECAY__INFO"]))
320+
["TRAIN__W_DECAY__INPUT", "adamw_weight_decay_label", "TRAIN__W_DECAY__INFO",
321+
"TRAIN__OPT_BETAS__INPUT", "TRAIN__OPT_BETAS__LABEL", "TRAIN__OPT_BETAS__INFO"]))
321322
self.ui.TRAIN__PROFILER__INPUT.currentIndexChanged.connect(lambda: self.condition_db.combobox_hide_visible_action(self,
322323
["profiler_batch_range_label", "TRAIN__PROFILER_BATCH_RANGE__INPUT", "TRAIN__PROFILER_BATCH_RANGE__INFO"]))
323324
self.ui.DATA__NORMALIZATION__TYPE__INPUT.currentIndexChanged.connect(lambda: self.condition_db.combobox_hide_visible_action(self,

settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def init_default_settings(self):
3030
self.settings['CUDA_version'] = [10.2, 11.8]
3131

3232
# BiaPy
33-
self.settings['biapy_code_version'] = "v3.3.9"
33+
self.settings['biapy_code_version'] = "v3.3.10"
3434
self.settings['biapy_code_github'] = "https://github.com/BiaPyX/BiaPy"
35-
self.settings['biapy_gui_version'] = "v1.0.3"
35+
self.settings['biapy_gui_version'] = "v1.0.4"
3636
self.settings['biapy_gui_github'] = "https://github.com/BiaPyX/BiaPy-GUI"
37-
self.settings['biapy_gui_last_version_hash'] = "6aadbc94b47cdc9ad4c321b841dc97ddc7fc16bc"
37+
self.settings['biapy_gui_last_version_hash'] = "69a6e455261ebb15f87035984470265c1c301ab7"
3838
self.settings['biapy_container_basename'] = "biapyx/biapy"
3939
self.settings['biapy_container_name'] = self.settings['biapy_container_basename']+":latest-"+str(self.settings['CUDA_version'][-1])
4040
self.settings['biapy_container_sizes'] = ["7.68GB", "11.6GB"]

0 commit comments

Comments
 (0)