Skip to content

Commit

Permalink
Merge pull request #337 from cytomining/issue/322
Browse files Browse the repository at this point in the history
Replace tiff\tif to png if compression is on.
  • Loading branch information
Arkkienkeli authored Oct 12, 2022
2 parents 983b688 + d611072 commit b57561a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugins/crop_generators/full_image_crop_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ class GeneratorClass(deepprofiler.imaging.cropping.CropGenerator):

def __init__(self, config, dset, mode="training"):
super(GeneratorClass, self).__init__(config, dset)
if self.config['prepare']['compression']['implement']:
self.directory = self.config["paths"]["compressed_images"]
else:
self.directory = self.config["paths"]["images"]

self.num_channels = len(self.config["dataset"]["images"]["channels"])
self.box_size = self.config["dataset"]["locations"]["box_size"]
self.view_size = self.config["dataset"]["locations"]["view_size"]
Expand All @@ -30,6 +25,12 @@ def __init__(self, config, dset, mode="training"):

# Load metadata
self.all_images = pd.read_csv(self.config["paths"]["index"])
if self.config['prepare']['compression']['implement']:
self.directory = self.config["paths"]["compressed_images"]
self.all_images.replace({'.tiff': '.png', '.tif': '.png'}, inplace=True, regex=True)
else:
self.directory = self.config["paths"]["images"]

self.target = self.config["train"]["partition"]["targets"][0]

# Index targets for one-hot encoded labels
Expand Down Expand Up @@ -104,7 +105,7 @@ def generator(self, sess, global_step=0):
for i in range(len(batch_paths)):
x[i, :, :, :] = images[i]

inputs = [x, np.asarray([[0,0,1,1]]*len(y)), np.arange(0, len(y))]
inputs = [x, np.asarray([[0, 0, 1, 1]]*len(y)), np.arange(0, len(y))]
yield inputs, tf.keras.utils.to_categorical(y, num_classes=self.num_classes)

image_loader.close()
Expand Down

0 comments on commit b57561a

Please sign in to comment.