Skip to content

Commit

Permalink
Make background subtraction backward compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzam committed Aug 21, 2024
1 parent 9d4cb6d commit a2f557c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lensless/recon/trainable_recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ def _prepare_process_block(self, process):

def set_pre_process(self, pre_process):
if isinstance(pre_process, torch.nn.DataParallel):
self.input_background = pre_process.module.input_background
if hasattr(pre_process.module, "input_background"):
self.input_background = pre_process.module.input_background
else:
self.input_background = pre_process.input_background
if hasattr(pre_process, "input_background"):
self.input_background = pre_process.input_background
(
self.pre_process,
self.pre_process_model,
Expand Down
4 changes: 2 additions & 2 deletions test/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_trainable_recon(algorithm):
psf = torch.rand(1, 32, 64, 3, dtype=torch_type)
data = torch.rand(2, 1, 32, 64, 3, dtype=torch_type)

def pre_process(x, param):
def pre_process(x, param, background=None):
return x

def post_process(x, param, residual=None):
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_trainable_batch(algorithm):
data2 = torch.rand(1, 1, 34, 64, 3, dtype=torch_type)
data2[0, 0, ...] = data1[0, 0, ...]

def pre_process(x, param):
def pre_process(x, param, background=None):
return x

def post_process(x, param, residual=None):
Expand Down

0 comments on commit a2f557c

Please sign in to comment.