Skip to content

Commit

Permalink
Issue #44 moved copy images out of class
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed Jul 27, 2022
1 parent ac77af5 commit 58b6203
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions sksurgerytf/models/rgb_unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,6 @@ def __init__(self,
self._load_data()
self.train()

def _copy_images(self, src_dir, dst_dir):
"""
Symlinks .png files from one directory to another.
"""
#pylint: disable=no-self-use
for image_file in glob.iglob(os.path.join(src_dir, "*.png")):
destination = os.path.join(dst_dir,
os.path.basename(
os.path.dirname(src_dir)) + "_" +
os.path.basename(image_file))
os.symlink(image_file, destination)

def _copy_data(self):
"""
Copies data from data directory to working directory.
Expand Down Expand Up @@ -214,20 +202,20 @@ def _copy_data(self):
if self.omit is not None and self.omit == os.path.basename(sub_dir):
LOGGER.info("Sym-linking validate images from %s to %s",
images_sub_dir, self.validate_images_working_dir)
self._copy_images(images_sub_dir,
self.validate_images_working_dir)
_copy_images(images_sub_dir,
self.validate_images_working_dir)

LOGGER.info("Sym-linking validate masks from %s to %s",
mask_sub_dir, self.validate_masks_working_dir)
self._copy_images(mask_sub_dir, self.validate_masks_working_dir)
_copy_images(mask_sub_dir, self.validate_masks_working_dir)
else:
LOGGER.info("Sym-linking train images from %s to %s",
images_sub_dir, self.train_images_working_dir)
self._copy_images(images_sub_dir, self.train_images_working_dir)
_copy_images(images_sub_dir, self.train_images_working_dir)

LOGGER.info("Sym-linking train masks from %s to %s",
mask_sub_dir, self.train_masks_working_dir)
self._copy_images(mask_sub_dir, self.train_masks_working_dir)
_copy_images(mask_sub_dir, self.train_masks_working_dir)

def _load_data(self):
"""
Expand Down Expand Up @@ -625,3 +613,15 @@ def run_rgb_unet_model(logs,
os.path.join(prediction, os.path.basename(test_file)), mask)
else:
cv2.imwrite(prediction, mask)


def _copy_images(src_dir, dst_dir):
"""
Symlinks .png files from one directory to another.
"""
for image_file in glob.iglob(os.path.join(src_dir, "*.png")):
destination = os.path.join(dst_dir,
os.path.basename(
os.path.dirname(src_dir)) + "_" +
os.path.basename(image_file))
os.symlink(image_file, destination)

0 comments on commit 58b6203

Please sign in to comment.