Skip to content

Commit

Permalink
Merge pull request #21 from Epoxid2/master
Browse files Browse the repository at this point in the history
Added check for multi-layer tiffs
  • Loading branch information
nekitmm authored Apr 13, 2021
2 parents adb22aa + 782674f commit 7079110
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion starnet_v1_TF2.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,19 @@ def save_model(self, weights_filename, history_filename = None):

def transform(self, in_name, out_name):
data = tiff.imread(in_name)
if len(data.shape) > 3:
layer = input("Tiff has %d layers, please enter layer to process: "%data.shape[0])
layer = int(layer)
data=data[layer]

input_dtype = data.dtype
if input_dtype == 'uint16':
image = (data / 255.0 / 255.0).astype('float32')
elif input_dtype == 'uint8':
image = (data / 255.0).astype('float32')
else:
raise ValueError('Unknown image dtype:', data.dtype)

if self.mode == 'Greyscale' and len(image.shape) == 3:
raise ValueError('You loaded Greyscale model, but the image is RGB!')

Expand Down

0 comments on commit 7079110

Please sign in to comment.