ValueError: Image size of 1200x102500 pixels is too large. It must be less than 2^16 in each directi
问题情况
Traceback (most recent call last):
File "CNNVisualisation.py", line 335, in <module>
plot_weights(alexnet, 3, single_channel = True, saveName='alexnet, 3')
File "CNNVisualisation.py", line 312, in plot_weights
plot_filters_single_channel(weight_tensor, saveName)
File "CNNVisualisation.py", line 257, in plot_filters_single_channel
plt.savefig('plot_filters_single_channel_' + saveName + '.png', dpi=100)
File "/opt/conda/lib/python3.7/site-packages/matplotlib/pyplot.py", line 729, in savefig
res = fig.savefig(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/matplotlib/figure.py", line 2180, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 2091, in print_figure
**kwargs)
File "/opt/conda/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 527, in print_png
FigureCanvasAgg.draw(self)
File "/opt/conda/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 386, in draw
self.renderer = self.get_renderer(cleared=True)
File "/opt/conda/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 399, in get_renderer
self.renderer = RendererAgg(w, h, self.figure.dpi)
File "/opt/conda/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 86, in __init__
self._renderer = _RendererAgg(int(width), int(height), dpi)
ValueError: Image size of 1200x102500 pixels is too large. It must be less than 2^16 in each direction.
原因
JPG的最大大小为每个方向65.535像素。这是一个文件格式的限制,没有办法增加。
上面的图像尺寸超出了范围
解决方式
分开保存图片,或者降低图片的像素
- 参考文献
ValueError: Image size of 1440x88500 pixels is too large. It must be less than 2^16 in each direction. · Issue #16234 · matplotlib/matplotlib
https://github.com/matplotlib/matplotlib/issues/16234
xlim with annotate makes image size too large if out of range · Issue #7895 · matplotlib/matplotlib
https://github.com/matplotlib/matplotlib/issues/7895
xlim with annotate makes image size too large if out of range · Issue #7895 · matplotlib/matplotlib
https://github.com/matplotlib/matplotlib/issues/7895
matplotlib error ‘Image size of 362976x273 pixels is too large’ - Stack Overflow
https://*.com/questions/52375207/matplotlib-error-image-size-of-362976x273-pixels-is-too-large
上一篇: php生成某个范围内的随机时间