Skip to content

Instantly share code, notes, and snippets.

@rasha-salim
Created February 7, 2021 09:06
Show Gist options
  • Save rasha-salim/c127d679aabf552a74b7426799e1203b to your computer and use it in GitHub Desktop.
Save rasha-salim/c127d679aabf552a74b7426799e1203b to your computer and use it in GitHub Desktop.
inputs_dir = '/content/landcovernet/inputs' # The directory where our input resides
targets_dir = '/content/landcovernet/targets' # The directory where our target resides
# First stack all the bands togather
def process_tiffs(inputs_dir, target_dir):
data = []
sub_dir_list = []
images_target = {}
stacked_imgs = []
list_bands = []
for sub_dir in os.listdir(inputs_dir):
# Store the images dir and their target
sub_dir_list.append(os.path.join(inputs_dir, sub_dir))
print(sub_dir_list)
for image_dir in sub_dir_list:
# Get the rgb version
rgb = get_rgb(image_dir)
custom_img = get_cust_img(image_dir)
mask = get_img_mask(targets_dir, image_dir)
mask = process_masks(mask) # get the six classes
# Dictionary of image and its target in numpy format
images_target = {}
images_target = {
'input' : custom_img,
'input_rgb' : rgb,
'mask' : mask,
}
stacked_imgs.append(images_target) # list of dict
return stacked_imgs
#return images
images_target = process_tiffs(inputs_dir, targets_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment