start merge
This commit is contained in:
1 parent
92ce5e24bc
commit
062483df1a
3 files changed
+2527
-4
No files matched your search
+169
-4
@@ -1,8 +1,173 @@
|
|||||||
voices/*.*
|
voices/*
|
||||||
models/*.*
|
models/*
|
||||||
outputs/*.*
|
outputs/*
|
||||||
finetune/*.*
|
finetune/*
|
||||||
|
alltalk_environment/*
|
||||||
system/config/at_github_sha.json
|
system/config/at_github_sha.json
|
||||||
system/tts_engines/tts_engines.json
|
system/tts_engines/tts_engines.json
|
||||||
confignew.json
|
confignew.json
|
||||||
diagnostics.log
|
diagnostics.log
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||||
|
.pdm.toml
|
||||||
|
.pdm-python
|
||||||
|
.pdm-build/
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
|
||||||
|
.idea/*
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
import datetime
|
||||||
|
import io
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from matplotlib import pyplot as plt
|
||||||
|
from trainer import ConsoleLogger
|
||||||
|
from trainer.logging.console_logger import tcolors
|
||||||
|
from trainer.utils.distributed import rank_zero_only
|
||||||
|
|
||||||
|
logger = logging.getLogger("trainer")
|
||||||
|
|
||||||
|
class MetricsLogger(ConsoleLogger):
|
||||||
|
def __init__(self, ):
|
||||||
|
super().__init__()
|
||||||
|
self.cur_epoch_start = None
|
||||||
|
self.cur_epoch_end = None
|
||||||
|
self.cur_epoch = None
|
||||||
|
self.epoch_durations = []
|
||||||
|
self.max_epoch = None
|
||||||
|
self.batch_steps = None
|
||||||
|
self.global_steps = None
|
||||||
|
self.loss = []
|
||||||
|
self.avg_loss = []
|
||||||
|
self.loss_mel_ce = []
|
||||||
|
self.avg_loss_mel_ce = []
|
||||||
|
self.loss_text_ce = []
|
||||||
|
self.avg_loss_text_ce = []
|
||||||
|
self.learning_rates = []
|
||||||
|
self.total_duration = None
|
||||||
|
self.estimated_duration = None
|
||||||
|
self.start = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_now():
|
||||||
|
return datetime.datetime.now()
|
||||||
|
@staticmethod
|
||||||
|
def format_duration(seconds):
|
||||||
|
if seconds:
|
||||||
|
# Calculate hours, minutes, and seconds
|
||||||
|
hours = seconds // 3600
|
||||||
|
minutes = (seconds % 3600) // 60
|
||||||
|
seconds = seconds % 60
|
||||||
|
return f"{int(hours)}:{int(minutes)}:{int(seconds)}"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@rank_zero_only
|
||||||
|
def print_epoch_start(self, epoch, max_epoch, output_path=None):
|
||||||
|
self.cur_epoch = epoch
|
||||||
|
self.cur_epoch_start = self.get_now()
|
||||||
|
self.max_epoch = max_epoch
|
||||||
|
super().print_epoch_start(epoch, max_epoch, output_path)
|
||||||
|
|
||||||
|
@rank_zero_only
|
||||||
|
def print_train_start(self):
|
||||||
|
super().print_train_start()
|
||||||
|
|
||||||
|
@rank_zero_only
|
||||||
|
def print_train_step(self, batch_steps, step, global_step, loss_dict, avg_loss_dict):
|
||||||
|
self.batch_steps = batch_steps
|
||||||
|
self.global_steps = global_step
|
||||||
|
|
||||||
|
for key, value in loss_dict.items():
|
||||||
|
if key == 'loss_mel_ce':
|
||||||
|
self.loss_mel_ce.append((global_step, value))
|
||||||
|
elif key == 'loss':
|
||||||
|
self.loss.append((global_step, value))
|
||||||
|
elif key == 'loss_text_ce':
|
||||||
|
self.loss_text_ce.append((global_step, value))
|
||||||
|
elif key == 'current_lr':
|
||||||
|
self.learning_rates.append((global_step, value))
|
||||||
|
super().print_train_step(batch_steps, step, global_step, loss_dict, avg_loss_dict)
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
@rank_zero_only
|
||||||
|
def print_train_epoch_end(self, global_step, epoch, epoch_time, print_dict):
|
||||||
|
super().print_epoch_end(global_step, epoch, epoch_time, print_dict)
|
||||||
|
if self.estimated_duration:
|
||||||
|
self.log_with_flush(
|
||||||
|
"\n{}{} >> ETA: {} {}".format(tcolors.UNDERLINE, tcolors.BOLD, self.format_duration(self.estimated_duration), tcolors.ENDC),
|
||||||
|
)
|
||||||
|
|
||||||
|
@rank_zero_only
|
||||||
|
def print_eval_start(self):
|
||||||
|
super().print_eval_start()
|
||||||
|
|
||||||
|
@rank_zero_only
|
||||||
|
def print_eval_step(self, step, loss_dict, avg_loss_dict):
|
||||||
|
super().print_eval_step(step, loss_dict, avg_loss_dict)
|
||||||
|
|
||||||
|
@rank_zero_only
|
||||||
|
def print_epoch_end(self, epoch, avg_loss_dict):
|
||||||
|
self.cur_epoch_end = self.get_now()
|
||||||
|
self.epoch_durations.append((self.cur_epoch_end - self.cur_epoch_start).total_seconds())
|
||||||
|
for key, value in avg_loss_dict.items():
|
||||||
|
if key == 'avg_loss_mel_ce':
|
||||||
|
self.avg_loss_mel_ce.append((epoch, value))
|
||||||
|
elif key == 'avg_loss':
|
||||||
|
self.avg_loss.append((epoch, value))
|
||||||
|
elif key == 'avg_loss_text_ce':
|
||||||
|
self.avg_loss_text_ce.append((epoch, value))
|
||||||
|
|
||||||
|
if len(self.epoch_durations) > 1 and self.max_epoch:
|
||||||
|
self.total_duration = sum(self.epoch_durations)
|
||||||
|
additional_data_points_needed = self.max_epoch - len(self.epoch_durations)
|
||||||
|
if additional_data_points_needed > 0:
|
||||||
|
weighted_avg_duration = sum((i + 1) * duration for i, duration in enumerate(self.epoch_durations)) / sum(range(1, len(self.epoch_durations) + 1))
|
||||||
|
self.estimated_duration = (weighted_avg_duration * additional_data_points_needed)
|
||||||
|
|
||||||
|
super().print_epoch_end(epoch, avg_loss_dict)
|
||||||
|
|
||||||
|
def plot_metrics(self, show_loss_mel_ce=False, show_loss_text_ce=False, show_loss=True):
|
||||||
|
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(24, 18))
|
||||||
|
|
||||||
|
ax2.set_title('Steps')
|
||||||
|
ax2.set_xlabel('Steps')
|
||||||
|
ax2.set_ylabel('Value')
|
||||||
|
|
||||||
|
ax1.set_title('Epochs')
|
||||||
|
ax1.set_xlabel('Epoch')
|
||||||
|
ax1.set_ylabel('Value')
|
||||||
|
|
||||||
|
ax3.set_title('Learning Rates')
|
||||||
|
ax3.set_xlabel('Steps')
|
||||||
|
ax3.set_ylabel('Value')
|
||||||
|
|
||||||
|
if self.loss and self.loss_text_ce and self.loss_mel_ce:
|
||||||
|
if show_loss:
|
||||||
|
ax2.plot(*zip(*self.loss), color='green', linestyle='-', label='Loss')
|
||||||
|
ax2.fill_between(*zip(*self.loss), color='lightgreen', alpha=0.1)
|
||||||
|
if show_loss_text_ce:
|
||||||
|
ax2.plot(*zip(*self.loss_text_ce), color='red', linestyle='-', label='Loss Text')
|
||||||
|
ax2.fill_between(*zip(*self.loss_text_ce), color='lightcoral', alpha=0.1)
|
||||||
|
if show_loss_mel_ce:
|
||||||
|
ax2.plot(*zip(*self.loss_mel_ce), color='blue', linestyle='-', label='Loss MEL')
|
||||||
|
ax2.fill_between(*zip(*self.loss_mel_ce), color='lightblue', alpha=0.1)
|
||||||
|
ax2.legend()
|
||||||
|
|
||||||
|
if self.learning_rates:
|
||||||
|
ax3.plot(*zip(*self.learning_rates), linestyle='-', color='blue', label='Learning Rate')
|
||||||
|
ax3.fill_between(*zip(*self.learning_rates), color='lightblue', alpha=0.1)
|
||||||
|
ax3.legend()
|
||||||
|
|
||||||
|
if self.avg_loss and self.avg_loss_text_ce and self.avg_loss_mel_ce:
|
||||||
|
if show_loss:
|
||||||
|
ax1.plot(*zip(*self.avg_loss), color='green', linestyle='-', label='Avg Loss')
|
||||||
|
ax1.fill_between(*zip(*self.avg_loss), color='lightgreen', alpha=0.1)
|
||||||
|
if show_loss_text_ce:
|
||||||
|
ax1.plot(*zip(*self.avg_loss_text_ce), color='red', linestyle='-', label='Avg Loss Text')
|
||||||
|
ax1.fill_between(*zip(*self.avg_loss_text_ce), color='lightcoral', alpha=0.1)
|
||||||
|
if show_loss_mel_ce:
|
||||||
|
ax1.plot(*zip(*self.avg_loss_mel_ce), color='blue', linestyle='-', label='Avg Loss MEL')
|
||||||
|
ax1.fill_between(*zip(*self.avg_loss_mel_ce), color='lightblue', alpha=0.1)
|
||||||
|
ax1.set_xlim(left=0)
|
||||||
|
ax1.legend()
|
||||||
|
|
||||||
|
plt.style.use('dark_background')
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.savefig("training_metrics.png", format='png', bbox_inches='tight', pad_inches=0.1)
|
||||||
|
plt.close()
|
||||||
|
return "training_metrics.png"
|
||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user