def image3_animatedGIF(tag,x):
//x=numpy.random.randint(0,256,[10,10,10],numpy.uint8)
ims=[GIF.fromarray(np.asarray((x[0,i,:,:,0]).astype(np.uint8))) for i in range(x.shape[3])]
s=b""
for b in PIL.GifImagePlugin.getheader(ims[0])[0]:
s+=b
s+=b"\x21\xFF\x0B\x4E\x45\x54\x53\x43\x41\x50\x45\x32\x2E\x30\x03\x01\x00\x00\x00"
for i in ims:
for b in PIL.GifImagePlugin.getdata(i):
s+=b
After Change
def image3_animatedGIF(tag,ims):
//x=numpy.random.randint(0,256,[10,10,10],numpy.uint8)
ims = [np.asarray((ims[i,:,:]).astype(np.uint8)) for i in range(ims.shape[0])]
ims=[GIF.fromarray(im) for im in ims]
s=b""
for b in PIL.GifImagePlugin.getheader(ims[0])[0]:
s+=b
s+=b"\x21\xFF\x0B\x4E\x45\x54\x53\x43\x41\x50\x45\x32\x2E\x30\x03\x01\x00\x00\x00"
for i in ims:
for b in PIL.GifImagePlugin.getdata(i):
s+=b