io.imsave()不会创建多个图像文件

时间:2017-08-24 13:08:14

标签: python machine-learning

我正在尝试运行一个while循环,最后创建并保存图像。不幸的是,每个循环都会更新以前保存的图像文件,而不是创建新的图像文件。因此,在运行5次的while循环结束时(并且应该创建5个单独的图像),我最终得到一个运行5次的while循环,但只创建一个更新5次的图像。 这是我的相关代码块:

i = 5
    while i > 0:
        layer_name = 'pool'+str(i)
    # Number of output classes of model being used
        nb_classes = 1000

        cam3 = grad_cam(x, vgg, sess, predicted_class, layer_name, nb_classes)

        img = img.astype(float)
        img /= img.max()

    # Superimposing the visualization with the image.
        new_img = img+3*cam3
        new_img /= new_img.max()

    # Display and save
        #io.imshow(new_img)
        #plt.show()
        io.imsave(FLAGS.output, new_img)



        i = i-1
        print (i)

任何建议都受到高度赞赏,因为我已经被困在这几个小时了。感谢

1 个答案:

答案 0 :(得分:1)

我不知道io.imsave,但我想它来自: skimage.io.imsave

所以我想你应该在每次迭代中都有一个新的文件名?