BBillot / SynthSR

A framework for joint super-resolution and image synthesis, without requiring real training data
Apache License 2.0
143 stars 23 forks source link

Tutorial 1-SR_real Bug #1

Closed stromguy closed 3 years ago

stromguy commented 3 years ago

Hi, I reacently discoverd your work and decided to try with your tutorials.

In first tutorial named 1-SR_real.py is a bug that appears in file SynthSR/labels_to_image_model.py. Because in this first tutorial you set variable output_channel to None. Then in file labels_to_image_model.py you try to iterate over that variable (output_channel), that has in this case type NonType, which is not possible. You should just add one if statement like I do and everything works fine. You can see in the attached image where the bug is located and how to fix it. im_to_lab_Error_solved

And also in the folowing tutorials, you describe output_channel as output_channel: (optional) a list with the indices of the output channels. So if you set variable output_channel=1, that variable has type integer and not list as you described, as a result the code does not work. You should set variable to output_channel=[1] or add an if statement that checks output_channel data type.

The lines 192-204 in SynthSR/labels_to_image_model.py should be replaced with the folowing code or something similar:

# synthetic regression target
if type(output_channel)!=type(None):
   if type(output_channel)!= type(list()):
      output_channel=[output_channel]
   if any(c==i for c in output_channel):
      target = KL.Lambda(lambda x: tf.cast(x, dtype='float32'))(channel)
      # resample regression target at target resolution if needed
      if crop_shape != output_shape:
         sigma = utils.get_std_blurring_mask_for_downsampling(target_res, atlas_res)
         kernels_list = l2i_et.get_gaussian_1d_kernels(sigma)
         target = l2i_et.blur_tensor(target, kernels_list, n_dims=n_dims)
         target = l2i_et.resample_tensor(target, output_shape)
      regression_target.append(target)`

@BBillot

BBillot commented 3 years ago

Hi, thanks for spotting this. I had already made some changes locally, but hadn't pushed them yet. The thing is that we are two working on this code, and the other author didn't check his changes before pushing. Anyway, thanks ! Benjamin