Plot the Training  - 1

During each epoch, the function below plots 9 generated images. For comparison, it will also plot the corresponding 9 original target images and 9 noised input images. We need to use the upscale function we've defined above when plotting to make sure the images are scaled to range between 0 and 255 so that you do not encounter issues when plotting.  A sample output of this function is shown below after the code snippet.

def generated_images_plot(original, noised_data, generator):

print('NOISED')
for i in range(9):
plt.subplot(331 + i)
plt.axis('off')
plt.imshow(upscale(np.squeeze(noised_data[i])), cmap='gray') # upscale for plotting
plt.show()

print('GENERATED')
for i in range(9):
pred = generator.predict(noised_data[i:i+1], verbose=0)
plt.subplot(331 + i)
plt.axis('off')
plt.imshow(upscale(np.squeeze(pred[0])), cmap='gray') # upscale to avoid plotting errors
plt.show()

print('ORIGINAL')
for i in range(9):
plt.subplot(331 + i)
plt.axis('off')
plt.imshow(upscale(np.squeeze(original[i])), cmap='gray') # upscale for plotting
plt.show()
Figure 14.9: Sample/Expected output of the function 'generated_images_plot'
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.235.62