我正在尝试使用此脚本为多个图像分割数据保存PNG文件。文件将被保存,但是全部相同。 plt.imshow()
显示的是其他图像,但我无法保存它们。我正在使用icenet图像分割脚本,将其修改为不仅可以在单个图像上运行在多个图像上。如何分别保存每个图像?
for i,image_path in enumerate(TEST_IMAGE_PATHS):
print("Running inference for image at '{}'...".format(image_path))
image = Image.open(image_path)
image_np = load_image_into_numpy_array(image)
# Actual inference result
segmentation_mask = run_inference_for_single_image(image_np, segmentation_graph)
# Decode the grayscale mask
rgb_segmentation_mask = decode_train_ids(segmentation_mask)
plt.figure(figsize=(30,20))
output_path = "./Test footages/Output_resized/"
for i in range(0,26):
plt.draw()
fig.savefig(path.join(output_path,'test {0}.png'.format(i+1)))
plt.imshow(rgb_segmentation_mask.astype(np.uint8)); plt.axis('off')
#plt.close()