plt.figure(figsize=(16,16))for i, image inenumerate(original_images):
plt.subplot(4,4,2* i +1)
plt.imshow(image)
plt.axis("off")
plt.subplot(4,4,2* i +2)
y = np.arange(top_probs.shape[-1])
plt.grid()
plt.barh(y, top_probs[i])#Histogram invovle the lable of Y and the probability# plt.gca().invert_yaxis()# plt.gca().set_axisbelow(True)
plt.yticks(y,[cifar100.classes[index]for index in top_labels[i].numpy()])
plt.xlabel("probability")
plt.subplots_adjust(wspace=0.5)
plt.show()
在特定的部分画图
from PIL import Image
import numpy as np
img = Image.open('QQ截图20220719131111.jpg')import torch
print(img)
img = np.array(img)print(torch.tensor(img).shape)import matplotlib.pyplot as plt
plt.xlim(1,50)
plt.gca(
plt.ylim(1,50)
plt.imshow(img,extent=(1,25,1,25))
plt.show()