added diff map during training

This commit is contained in:
SayanoAI
2024-09-16 14:30:02 -04:00
parent ec21a76e84
commit 5775c6d7b4
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -187,7 +187,7 @@ def latest_checkpoint_path(dir_path, regex="G_*.pth"):
return x
def plot_spectrogram_to_numpy(spectrogram):
def plot_spectrogram_to_numpy(spectrogram, cmap=None):
global MATPLOTLIB_FLAG
if not MATPLOTLIB_FLAG:
import matplotlib
@@ -200,7 +200,7 @@ def plot_spectrogram_to_numpy(spectrogram):
import numpy as np
fig, ax = plt.subplots(figsize=(10, 2))
im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation="none")
im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation="none", cmap=cmap)
plt.colorbar(im, ax=ax)
plt.xlabel("Frames")
plt.ylabel("Channels")
+1
View File
@@ -612,6 +612,7 @@ def train_and_evaluate(
"slice/mel_org": utils.plot_spectrogram_to_numpy(y_mel[0].data.cpu().numpy()),
"slice/mel_gen": utils.plot_spectrogram_to_numpy(y_hat_mel[0].data.cpu().numpy()),
"all/mel": utils.plot_spectrogram_to_numpy(mel[0].data.cpu().numpy()),
"all/diff": utils.plot_spectrogram_to_numpy((y_mel[0]-y_mel[0]).abs().data.cpu().numpy(), cmap="hot")
}
with torch.no_grad():