How to increase the image size extracted from visualizing the feature map?

Viewed 20

can someone help me on how to increase the size of images from feature map extracted? i recently run CNN on set of images and would like to see the feature extracted. I manage to extract it but unable to actually see it because it was too small. My code:

from matplotlib import pyplot
    
    #summarize feature map shapes
    for i in range(len(cnn.layers)):
        layer = cnn.layers[i]
        #check fr conv layer
        if 'conv' not in layer.name:
            continue
            
        print(i, layer.name,layer.output.shape)
    
    from keras import models
    from keras.preprocessing import image
    
    model_new = models.Model(inputs=cnn.inputs, outputs=cnn.layers[1].output)
    img_path = 'train/1/2NbeGPsQf2Q - 4 0.jpg'
    img = image.load_img(img_path, target_size=(img_rows, img_cols))
    
    import numpy as np
    from keras.applications.imagenet_utils import decode_predictions, preprocess_input
    
    img = image.img_to_array(img)
    img = np.expand_dims(img, axis=0)
    img = preprocess_input(img)
    
    features = model_new.predict(img)
    
    square = 10
    ix = 1
    for _ in range(square):
        for _ in range(square):
            # specify subplot and turn of axis
            ax = pyplot.subplot(square, square, ix)
            ax.set_xticks([])
            ax.set_yticks([])
            # plot filter channel in colour
            pyplot.imshow(features[0, :, :, ix-1], cmap='viridis')
            ix += 1
    # show the figure
    pyplot.show()

the result is at attached.output of feature map layer 1

its too small. How can i make it bigger so i can see what actually is there?

Appreciate for any input. Thanks!

0 Answers
Related