python 含子图的gif生成时内存溢出的方法
时间:2021-06-19 08:17:59|栏目:Python代码|点击: 次
今天想用python做个demo,含两个子图的动态gif,代码如下:
import matplotlib.pyplot as plt
import imageio,os
import matplotlib
# plt.ion()
fig=plt.figure(0)
ax1=plt.subplot(121)
ax2=plt.subplot(122)
ax1.set_title('input')
ax2.set_title('GT')
for i in range(1000):
img1=plt.imread('F:\\pythonprogram\\test_bord/path\\enc_in_img\\{}.png'.format(i))
img2 = plt.imread('F:\\pythonprogram\\test_bord/path\\dec_out_img\\{}.png'.format(i))
ax1.imshow(img1)
ax2.imshow(img2)
# ax2.axis('off')
plt.pause(0.00001)
plt.cla()
plt.show()
首先分别将画布分为两块,分别循环读如图片,显示图片后暂停,再清除原图像~
但是由于plt.cla()只能作用于最后一个子图,第一块子图读取过程中占用大量内存导致内存溢出,目前没找到解决办法。
最后在matlab上完成这个工作。
栏 目:Python代码
本文地址:http://www.codeinn.net/misctech/144574.html






