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

build: move umap-learn into optional notebook dependencies #50

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions TTS/bin/train_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import time
import traceback
import warnings

import torch
from torch.utils.data import DataLoader
Expand Down Expand Up @@ -116,11 +117,14 @@ def evaluation(model, criterion, data_loader, global_step):
eval_avg_loss = eval_loss / len(data_loader)
# save stats
dashboard_logger.eval_stats(global_step, {"loss": eval_avg_loss})
# plot the last batch in the evaluation
figures = {
"UMAP Plot": plot_embeddings(outputs.detach().cpu().numpy(), c.num_classes_in_batch),
}
dashboard_logger.eval_figures(global_step, figures)
try:
# plot the last batch in the evaluation
figures = {
"UMAP Plot": plot_embeddings(outputs.detach().cpu().numpy(), c.num_classes_in_batch),
}
dashboard_logger.eval_figures(global_step, figures)
except ImportError:
warnings.warn("Install the `umap-learn` package to see embedding plots.")
return eval_avg_loss


Expand Down
5 changes: 4 additions & 1 deletion TTS/encoder/utils/visual.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import umap

matplotlib.use("Agg")

Expand Down Expand Up @@ -30,6 +29,10 @@


def plot_embeddings(embeddings, num_classes_in_batch):
try:
import umap
except ImportError as e:
raise ImportError("Package not installed: umap-learn") from e
num_utter_per_class = embeddings.shape[0] // num_classes_in_batch

# if necessary get just the first 10 classes
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ dependencies = [
"packaging>=23.1",
# Inference
"pysbd>=0.3.4",
# Notebooks
"umap-learn>=0.5.1",
# Training
"matplotlib>=3.7.0",
# Coqui stack
Expand Down Expand Up @@ -100,6 +98,7 @@ docs = [
notebooks = [
"bokeh==1.4.0",
"pandas>=1.4,<2.0",
"umap-learn>=0.5.1",
]
# For running the TTS server
server = ["flask>=2.0.1"]
Expand Down
Loading