# Save models
            self.autoencoder.save(self.autoencoder_model_pkl)
            self.encoder.save(self.encoder_model_pkl)
            self.decoder.save(self.decoder_model_pkl)
        else:
            # Save models
            self.autoencoder = load_model(self.autoencoder_model_pkl)
            self.encoder = load_model(self.encoder_model_pkl)
            self.decoder = load_model(self.decoder_model_pkl)

    def predict(self, test_profile_images):
        png_profile_images = self.process_images(test_profile_images)
        encoded_imgs = self.encoder.predict(png_profile_images)
        decoded_imgs = self.decoder.predict(encoded_imgs)
        return test_profile_images, decoded_imgs


if __name__ == "__main__":
    profile_gray_objs, midcurve_gray_objs = get_training_data()
    test_gray_images = random.sample(profile_gray_objs, 5)

    profile_gray_objs = np.asarray(profile_gray_objs) / 255.
    midcurve_gray_objs = np.asarray(midcurve_gray_objs) / 255.
    test_gray_images = np.asarray(test_gray_images) / 255.

    endec = dense_encoderdecoder()
    endec.train(profile_gray_objs, midcurve_gray_objs)

    original_profile_imgs, predicted_midcurve_imgs = endec.predict(
        test_gray_images)
    plot_results(original_profile_imgs, predicted_midcurve_imgs)
import sys
#sys.path.append('...')
from utils.utils import get_training_data
from utils.utils import plot_results

from core.cnnencoderdecoder.build_cnn_encoderdecoder_model import cnn_encoderdecoder

import numpy as np
import random

if __name__ == "__main__":
    profile_pngs_objs, midcurve_pngs_objs = get_training_data(size=(128, 128))

    test_gray_images = random.sample(profile_pngs_objs, 5)
    test_gray_images = np.expand_dims(np.asarray(test_gray_images),
                                      axis=-1) / 255.

    profile_pngs_objs = np.asarray(profile_pngs_objs)
    midcurve_pngs_objs = np.asarray(midcurve_pngs_objs)

    profile_pngs_objs = np.expand_dims(profile_pngs_objs, axis=-1)
    midcurve_pngs_objs = np.expand_dims(midcurve_pngs_objs, axis=-1)

    profile_pngs_objs = profile_pngs_objs / 255.  #Normalize [0,1]
    midcurve_pngs_objs = midcurve_pngs_objs / 255.  #Normalize [0,1]

    #profile_pngs_objs = (profile_pngs_objs - 127.5)/127.5 #Normalize [-1, 1]
    #midcurve_pngs_objs = (midcurve_pngs_objs - 127.5)/127.5 #Normalize [-1, 1]

    x_coord = np.zeros(shape=(128, 128, 1))
    y_coord = np.zeros(shape=(128, 128, 1))