# -*- coding: utf-8 -*-
"""
Created on Sun Apr 18 19:59:06 2021

@author: xhrton02
"""

# load, split and scale the maps dataset ready for training
from os import listdir
from numpy import asarray
from numpy import load
from matplotlib import pyplot
from keras.preprocessing.image import img_to_array
from keras.preprocessing.image import load_img
from numpy import savez_compressed

mask_path = "D:/hrtoňová/datasets/melanoma/mask/"
targ_path = "D:/hrtoňová/datasets/melanoma/ground_truth/"

mask_list, targ_list = list(), list ()

mask_dir = listdir(mask_path)
if '.DS_Store' in mask_dir:
    mask_dir.remove('.DS_Store')

for filename in mask_dir:
        
		# load and resize the image
		img = load_img(mask_path + filename,target_size=(256, 256))
		# convert to numpy array
		img = img_to_array(img)
		mask_list.append(img)
        
targ_dir = listdir(targ_path)
if '.DS_Store' in targ_dir:
    targ_dir.remove('.DS_Store')
    
for filename in targ_dir:
		# load and resize the image
		img = load_img(targ_path + filename, target_size=(256, 256))
		# convert to numpy array
		img = img_to_array(img)             
		targ_list.append(img)

mask_imgs = asarray(mask_list)
targ_imgs = asarray(targ_list)

print('Loaded: ', mask_imgs.shape, targ_imgs.shape)
# save as compressed numpy array
filename = 'pix2pix_melanoma.npz'
savez_compressed(filename, mask_imgs, targ_imgs)
print('Saved dataset: ', filename)     

