tensorboard updates
This commit is contained in:
+2
-14
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user