Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Matplotlib tostring_rgb() removal #2473

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions infer/lib/train/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def plot_spectrogram_to_numpy(spectrogram):
mpl_logger = logging.getLogger("matplotlib")
mpl_logger.setLevel(logging.WARNING)
import matplotlib.pylab as plt
import numpy as np

fig, ax = plt.subplots(figsize=(10, 2))
im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation="none")
Expand All @@ -235,8 +234,7 @@ def plot_spectrogram_to_numpy(spectrogram):
plt.tight_layout()

fig.canvas.draw()
data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep="")
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
data = np.asarray(fig.canvas.buffer_rgba())
plt.close()
return data

Expand All @@ -251,7 +249,6 @@ def plot_alignment_to_numpy(alignment, info=None):
mpl_logger = logging.getLogger("matplotlib")
mpl_logger.setLevel(logging.WARNING)
import matplotlib.pylab as plt
import numpy as np

fig, ax = plt.subplots(figsize=(6, 4))
im = ax.imshow(
Expand All @@ -266,8 +263,7 @@ def plot_alignment_to_numpy(alignment, info=None):
plt.tight_layout()

fig.canvas.draw()
data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep="")
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
data = np.asarray(fig.canvas.buffer_rgba())
plt.close()
return data

Expand Down