#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 14 11:44:05 2021

@author: valentinahrtonova
"""
from numpy.random import randn
from matplotlib import pyplot as plt

from keras.models import load_model

def generate_latent_points(latent_dim, n_samples):
	# generate points in the latent space
	x_input = randn(latent_dim * n_samples)
	# reshape into a batch of inputs for the network
	x_input = x_input.reshape(n_samples, latent_dim)
	return x_input
   
model = load_model('DCGAN_model_645.h5')

latent_dim = 100
n_samples = 9

# for i in range(9):
    
#     x_input = generate_latent_points(latent_dim, n_samples)
#     examples = model.predict(x_input)
#     examples = (examples + 1) / 2.0
#     examples = examples[0,:,:,:]

    
#     plt.imshow(examples)
#     plt.axis('off')
    
#     filename = 'mask_1%03d.png' % (i)
#     plt.savefig(filename)
    
x_input = generate_latent_points(latent_dim, n_samples)
examples = model.predict(x_input)

n = 3
examples = (examples + 1) / 2.0
 	# plot images
for j in range(n * n):
		# define subplot
    plt.subplot(n, n, 1 + j)
    plt.axis('off')
		# plot raw pixel data
    plt.imshow(examples[j])

filename = 'demo_output/generated_.png'
plt.savefig(filename)