Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left

  Apply Now

Project - Introduction to Neural Style Transfer using Deep Learning & TensorFlow 2 (Art Generation Project)

7 / 18

Visualize the Images

We shall visualize the images that we have loaded previously. We shall define the imshow function to do the same.

Note:

  • tf.squeeze removes dimensions of size 1 from the shape of a tensor.
INSTRUCTIONS
  • We shall define the imshow function. We shall pass the image and the title as input arguments to the function.

    • We shall squeeze the fourth dimension, if any.
    • We shall also display the title of the image, if any.

      def imshow(image, title=None):
          if len(image.shape) > 3:
              image = tf.squeeze(image, axis=0)
      
          plt.imshow(image)
          if title:
              plt.title(title)
      
  • Let us display the content and style images side-by-side. Call the imshow function to display the content and style images.

    plt.subplot(1, 2, 1)
    << your code comes here >>(content_image, 'Content Image')
    
    plt.subplot(1, 2, 2)
    << your code comes here >>(style_image, 'Style Image')
    
  • Let us also print the shapes of the content and style images using shape.

    print("Content image shape: ", << your code comes here >>)
    print("Style image shape: ", << your code comes here >>)
    
Get Hint See Answer


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...