Как создать и сохранить gif изображений в оттенках серого с подушкой? - PullRequest
1 голос
/ 09 октября 2019

Я получаю ошибку атрибута при запуске этого. Этот код работает для другого набора данных RGB. Python3.6, windows10

Код:

    image_dirs = glob.glob(denoised_dir + "/*")
    for_gif = []
    counter = 0 
    for (count, each_dir)in enumerate(image_dirs):
        images = glob.glob(each_dir + "/*")
        print(images)
        for image in images:
            counter += 1
            print(counter)
            print("processing denoised image:", image)
            im = Image.open(image)
            print("confirmimation", type(im))
            for_gif.append(im)
            print("counter", counter)
            print("for_gif", len(for_gif))
        print(for_gif)
        os.makedirs("./outputs/noise/gif/"+str(args.imgsize) + "_" + str(args.epochs) + "/" + args.image_type, exist_ok = True)
        print("directory created")
        for_gif[0].save("./outputs/noise/gif/"+str(args.imgsize) + "_" + str(args.epochs) + "/" + args.image_type + "/" + str(count) + ".gif", 
                        save_all=True, 
                        append_images=for_gif[1:],
                        optimize=False, 
                        duration=500, 
                        loop=0
                        )

и for_gif, как показано ниже:

[<PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A07CF28>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0EC7F0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0F08D0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0F0BE0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC080>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120
at 0x1FE2A0FC0F0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC160>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC1D0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC240>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC2B0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC320>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC390>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC400>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC470>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC4E0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC550>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC5C0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC630>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC6A0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC710>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC780>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC7F0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC860>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC8D0>, <PIL.PngImagePlugin.PngImageFile image mode=L size=120x120 at 0x1FE2A0FC940>]

Ошибка:

AttributeError: 'NoneType' object has no attribute 'palette'

Любой совет поможет мне. Спасибо.

...