def make_image(sequence, epoch, name='_output_'):
"""plot drawing with separated strokes"""
strokes = np.split(sequence, np.where(sequence[:,2]>0)[0]+1)
fig = plt.figure()
ax1 = fig.add_subplot(111)
for s in strokes:
plt.plot(s[:,0],-s[:,1])
canvas = plt.get_current_fig_manager().canvas
canvas.draw()
pil_image = PIL.Image.frombytes('RGB', canvas.get_width_height(),
canvas.tostring_rgb())
name = str(epoch)+name+'.jpg'
pil_image.save(name,"JPEG")
plt.close("all")
评论列表
文章目录