tensorboard updates

This commit is contained in:
Glenn Jocher
2019-08-09 16:37:19 +02:00
parent fdd5afa229
commit 933f85f632
3 changed files with 22 additions and 45 deletions
+2 -14
View File
@@ -819,18 +819,6 @@ def version_to_tuple(version):
def fig_to_data(fig):
# Used to convert a Matplotlib figure to a 4D numpy array with RGBA channels and return it
# param fig a matplotlib figure
# return a numpy 3D array of RGBA values
# draw the renderer
# Converts a matplotlib fig to 3D numpy array (fig is a matplotlib figure)
fig.canvas.draw()
# Get the RGBA buffer from the figure
w,h = fig.canvas.get_width_height()
buf = np.fromstring (fig.canvas.tostring_argb(), dtype=np.uint8)
buf.shape = (w, h, 4)
# canvas.tostring_argb give pixmap in ARGB mode. Roll the ALPHA channel to have it in RGBA mode
buf = np.roll(buf, 3, axis = 2)
return buf[:,:,:3] # Return RGB numpy image
return np.array(fig.canvas.renderer.buffer_rgba())[:, :, :3] # RGB image