簡體   English   中英

如何在Keras中顯示由Resnet50模型提取的圖像的特征

[英]How can I display a features of a image that was extracted by a Resnet50 model in keras

因此,我想做的是顯示從Resnet50模型提取並另存為.npy的功能。

我完全可以閱讀它,數組看起來也很好。 但是我無法找到一種很好地顯示結果的方法。 如何在opencv matplotlib中顯示此內容?

這是我到目前為止的內容:

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from matplotlib import cm
import os

path = "ResnetFeatures/"

def load_resnet_features(file, path):
    file_path = os.path.join(path, file)
    return np.load(file_path)

test_file = '1500test.npy'




test_feature = load_resnet_features(test_file, path)
print(test_feature.shape)
test_feature = np.squeeze(test_feature, axis=0)
print(test_feature.shape)
test_feature = test_feature.reshape((49, 2048))
plt.imshow(test_feature)
plt.show()

這給這個

(1, 7, 7, 2048)
(7, 7, 2048)

這樣就可以了,但這不是我想要的。 我想要形狀更方形的東西是原始圖像(224,224,3) 在此處輸入圖片說明

好的,我感謝Jake P的幫助。 在此處輸入圖片說明

所以我知道圖像可以像(49,2048)那樣重塑,所以我將2048分開以得到(7,7)(64,32),然后交叉乘以(7 * 32)(7 * 64)

test_feature = test_feature.reshape((448, 224))
print_shape(test_feature)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM