1 回答
TA贡献1828条经验 获得超4个赞
我现在编辑了我的回答,以便更好地理解这个问题。此代码将绘制图像以及输出。
import matplotlib.image as mpimg
import numpy as np
import matplotlib.pyplot as plt
img_paths = ['../python/imgs/Image001.png',
'../python/imgs/Image002.png',
'../python/imgs/Image003.png',
'../python/imgs/Image004.png',
'../python/imgs/Image005.png']
input = np.array([mpimg.imread(path) for path in img_paths])
output = np.random.rand(5, 6)
print(input.shape, output.shape)
fig, axs = plt.subplots(2, 5, figsize=(8, 4), sharey = 'row')
for i, sample in enumerate(range(5)):
o = output[sample]
axs[0,i].set_title(f'Sample {sample + 1}')
axs[0,i].imshow(input[i,:])
axs[0,i].axis('off')
axs[1,i].bar(range(6), o)
axs[1,i].set_xticks(range(6))
axs[1,i].set_xticklabels([f'{i+1}' for i in range(6)])
plt.show()
输出:
(5, 1510, 2560, 4) (5, 6)
添加回答
举报