Skip to content

Commit

Permalink
Correct errors with SR scale in generators
Browse files Browse the repository at this point in the history
  • Loading branch information
danifranco committed Feb 26, 2024
1 parent 7144511 commit 868f5e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions biapy/data/generators/pair_data_2D_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def ensure_shape(self, img, mask):

# Super-resolution check. if random_crops_in_DA is activated the images have not been cropped yet,
# so this check can not be done and it will be done in the random crop
if not self.random_crops_in_DA and self.Y_provided and self.random_crop_scale != 1:
s = [img.shape[0]*self.random_crop_scale, img.shape[1]*self.random_crop_scale]
if not self.random_crops_in_DA and self.Y_provided and any([x != 1 for x in self.random_crop_scale]):
s = [img.shape[0]*self.random_crop_scale[0], img.shape[1]*self.random_crop_scale[1]]
if all(x!=y for x,y in zip(s,mask.shape[:-1])):
raise ValueError("Images loaded need to be LR and its HR version. LR shape:"
" {} vs HR shape {} is not x{} larger".format(img.shape[:-1], mask.shape[:-1], self.random_crop_scale))
Expand Down
2 changes: 1 addition & 1 deletion biapy/data/generators/pair_data_3D_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def ensure_shape(self, img, mask):

# Super-resolution check. if random_crops_in_DA is activated the images have not been cropped yet,
# so this check can not be done and it will be done in the random crop
if not self.random_crops_in_DA and self.Y_provided and self.random_crop_scale != 1:
if not self.random_crops_in_DA and self.Y_provided and any([x != 1 for x in self.random_crop_scale]):
s = [img.shape[0]*self.random_crop_scale[0], img.shape[1]*self.random_crop_scale[1], img.shape[2]*self.random_crop_scale[2]]
if all(x!=y for x,y in zip(s,mask.shape[0:-1])):
raise ValueError("Images loaded need to be LR and its HR version. LR shape:"
Expand Down

0 comments on commit 868f5e3

Please sign in to comment.