Skip to content

Commit

Permalink
Only load merged images upon inference (#9)
Browse files Browse the repository at this point in the history
Only load photos that have green and blue channels.
  • Loading branch information
CloudyOverhead authored Apr 24, 2021
1 parent 015132f commit 835d8c8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions acrosome_counter/load_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ def __init__(self, data_dir, is_training):
for root, _, files in walk(data_dir):
for file in files:
if 'tif' in file.split(".")[-1]:
filename = relpath(join(root, file), data_dir)
self.filenames.append(filename)
filepath = join(root, file)
if is_merged(filepath):
filename = relpath(filepath, data_dir)
self.filenames.append(filename)

self.metadata = self.register()

Expand Down Expand Up @@ -164,3 +166,8 @@ def review(self):
scores=scores,
)
visualize(image, instances, self.metadata)


def is_merged(filepath):
image = plt.imread(filepath)
return image[..., 1].any() and image[..., 2].any()

0 comments on commit 835d8c8

Please sign in to comment.