Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

去模糊特徵圖R的可視化圖 #49

Open
joe880923 opened this issue Dec 18, 2023 · 7 comments
Open

去模糊特徵圖R的可視化圖 #49

joe880923 opened this issue Dec 18, 2023 · 7 comments

Comments

@joe880923
Copy link

作者您好,想請問你可以提供去模糊特徵圖R的可視化方法嗎?
有嘗試使用一些方法但可視化的圖片很奇怪。

@Algolzw
Copy link
Collaborator

Algolzw commented Dec 18, 2023

你好,可以尝试使用matplotlib并设置cmap='jet' .

@joe880923
Copy link
Author

joe880923 commented Dec 18, 2023

作者您好,我儲存R特徵圖的code是這樣
test = self.channel_1(f2) #將R特徵圖channel做1*1con讓channel為1
test = np.squeeze(test, axis=2)
ndarr = test.detach().squeeze().cpu().numpy()
ndarr = (ndarr * 255).clip(0, 255).astype(np.uint8)
print("ndarr-------------------", ndarr.shape)
print("ndarr dtype-------------------", ndarr.dtype)
print("ndarr min/max-----------------", ndarr.min(), ndarr.max())
ndarr = ndarr.astype(np.uint8)
ndarr_transposed = np.transpose(ndarr, (0, 1)) # 对于二维数组,不需要改变轴的顺序

    plt.imshow(ndarr_transposed, cmap='jet')
    plt.savefig('feature_map.png')
    plt.show()

儲存的結果長這樣是正確的嗎?
image

image

image

感覺應該正常不會長這樣,再麻煩您跟我說一下,謝謝!

@Algolzw
Copy link
Collaborator

Algolzw commented Dec 19, 2023

看起来不对= =。你为什么要加一个1x1卷积让channel为1呢?可以直接只取第一个(或者前N个)通道的特征不?

@joe880923
Copy link
Author

我原本的理解是如果只使用第一個channel的話會導致資訊流失,依照您給的建議有嘗試過使用第1個channel來測試,如下:
first_channel = f2[0, :1, :, :]
test = np.squeeze(first_channel, axis=0)
ndarr = test.detach().squeeze().cpu().numpy()
ndarr = (ndarr * 255).clip(0, 255).astype(np.uint8)
plt.imshow(ndarr, cmap='jet')
plt.savefig('feature_map.png')
plt.show()

印出的結果為
image

image

好像更加的不太對的樣子,不太確定我哪邊理解有問題或操作,再麻煩您給我點指導,謝謝您!

@Algolzw
Copy link
Collaborator

Algolzw commented Dec 20, 2023

你这是学习后的模型吗还是random weights?可以多打印几个feature通道看看呢,理论上有些通道信息比较多。

@joe880923
Copy link
Author

作者您好,我是使用已經訓練完後的權重檔案去印出圖片,作者您說的多印幾個是指我針對第一個通道、第二個通道、第三個通道打印出來分別儲存起來的意思嗎?

@Algolzw
Copy link
Collaborator

Algolzw commented Dec 21, 2023

是的,有的通道信息应该会多一点

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants