Feat, refactor: gradio theme setting

This commit is contained in:
litagin02
2024-02-09 18:05:27 +09:00
parent 862a719e2f
commit c3f00dbc4f
7 changed files with 31 additions and 17 deletions

3
app.py
View File

@@ -19,6 +19,7 @@ from common.constants import (
DEFAULT_SPLIT_INTERVAL, DEFAULT_SPLIT_INTERVAL,
DEFAULT_STYLE, DEFAULT_STYLE,
DEFAULT_STYLE_WEIGHT, DEFAULT_STYLE_WEIGHT,
GRADIO_THEME,
LATEST_VERSION, LATEST_VERSION,
Languages, Languages,
) )
@@ -284,7 +285,7 @@ if __name__ == "__main__":
initial_id = 0 initial_id = 0
initial_pth_files = model_holder.model_files_dict[model_names[initial_id]] initial_pth_files = model_holder.model_files_dict[model_names[initial_id]]
with gr.Blocks(theme="NoCrypt/miku") as app: with gr.Blocks(theme=GRADIO_THEME) as app:
gr.Markdown(initial_md) gr.Markdown(initial_md)
with gr.Accordion(label="使い方", open=False): with gr.Accordion(label="使い方", open=False):
gr.Markdown(how_to_md) gr.Markdown(how_to_md)

View File

@@ -1,6 +1,10 @@
import enum import enum
LATEST_VERSION: str = "2.1.1" # Built-in theme: "default", "base", "monochrome", "soft", "glass"
# See https://huggingface.co/spaces/gradio/theme-gallery for more themes
GRADIO_THEME: str = "NoCrypt/miku"
LATEST_VERSION: str = "2.2"
DEFAULT_STYLE: str = "Neutral" DEFAULT_STYLE: str = "Neutral"
DEFAULT_STYLE_WEIGHT: float = 5.0 DEFAULT_STYLE_WEIGHT: float = 5.0

View File

@@ -7,8 +7,10 @@
- バッチサイズのデフォルトを4から2に変更。学習が遅い場合はバッチサイズを下げて試してみて、VRAMに余裕があれば上げてください。バッチサイズごとのVRAM使用量目安は、1: 6GB, 2: 8GB, 3: 10GB, 4: 12GB くらいのようです。 - バッチサイズのデフォルトを4から2に変更。学習が遅い場合はバッチサイズを下げて試してみて、VRAMに余裕があれば上げてください。バッチサイズごとのVRAM使用量目安は、1: 6GB, 2: 8GB, 3: 10GB, 4: 12GB くらいのようです。
- 学習の際の検証データ数をデフォルトで0に変更し、また検証データ数を学習用WebUIで指定できるようにした - 学習の際の検証データ数をデフォルトで0に変更し、また検証データ数を学習用WebUIで指定できるようにした
- Tensorboardのログ間隔を学習用WebUIで指定できるようにした - Tensorboardのログ間隔を学習用WebUIで指定できるようにした
- UIのテーマを`common/constants.py``GRADIO_THEME`で指定できるようにした
### バグ修正等 ### バグ修正等
- JP-Extra使用時にバッチサイズが1だと学習中にエラーが発生するバグを修正
- 「こんにちは!?!?!?!?」等、感嘆符等の記号が連続すると学習・音声合成でエラーになるバグを修正 - 「こんにちは!?!?!?!?」等、感嘆符等の記号が連続すると学習・音声合成でエラーになるバグを修正
- `—` (em dash, U+2014) や `―` (quotation dash, U+2015) 等のダッシュやハイフンの各種変種が、種類によって「-」に正規化されたりされていなかったりする処理を、全て「-」に正規化するように修正 - `—` (em dash, U+2014) や `―` (quotation dash, U+2015) 等のダッシュやハイフンの各種変種が、種類によって「-」に正規化されたりされていなかったりする処理を、全て「-」に正規化するように修正

View File

@@ -4,6 +4,7 @@ import os
import gradio as gr import gradio as gr
import yaml import yaml
from common.constants import GRADIO_THEME
from common.log import logger from common.log import logger
from common.subprocess_utils import run_script_with_log from common.subprocess_utils import run_script_with_log
@@ -115,7 +116,7 @@ Style-Bert-VITS2の学習用データセットを作成するためのツール
- 手動で書き起こしをいろいろ修正したり結果を細かく確認したい場合は、[Aivis Dataset](https://github.com/litagin02/Aivis-Dataset)もおすすめします。書き起こし部分もかなり工夫されています。ですがファイル数が多い場合などは、このツールで簡易的に切り出してデータセットを作るだけでも十分という気もしています。 - 手動で書き起こしをいろいろ修正したり結果を細かく確認したい場合は、[Aivis Dataset](https://github.com/litagin02/Aivis-Dataset)もおすすめします。書き起こし部分もかなり工夫されています。ですがファイル数が多い場合などは、このツールで簡易的に切り出してデータセットを作るだけでも十分という気もしています。
""" """
with gr.Blocks(theme="NoCrypt/miku") as app: with gr.Blocks(theme=GRADIO_THEME) as app:
gr.Markdown(initial_md) gr.Markdown(initial_md)
model_name = gr.Textbox( model_name = gr.Textbox(
label="モデル名を入力してください(話者名としても使われます)。" label="モデル名を入力してください(話者名としても使われます)。"

View File

@@ -10,7 +10,7 @@ import yaml
from safetensors import safe_open from safetensors import safe_open
from safetensors.torch import save_file from safetensors.torch import save_file
from common.constants import DEFAULT_STYLE from common.constants import DEFAULT_STYLE, GRADIO_THEME
from common.log import logger from common.log import logger
from common.tts_model import Model, ModelHolder from common.tts_model import Model, ModelHolder
@@ -171,6 +171,8 @@ def merge_models_gr(
speech_style_weight, speech_style_weight,
tempo_weight, tempo_weight,
): ):
if output_name == "":
return "Error: 新しいモデル名を入力してください。"
merged_model_path = merge_models( merged_model_path = merge_models(
model_path_a, model_path_a,
model_path_b, model_path_b,
@@ -190,6 +192,8 @@ def merge_style_gr(
output_name, output_name,
style_triple_list_str: str, style_triple_list_str: str,
): ):
if output_name == "":
return "Error: 新しいモデル名を入力してください。", None
style_triple_list = [] style_triple_list = []
for line in style_triple_list_str.split("\n"): for line in style_triple_list_str.split("\n"):
if not line: if not line:
@@ -295,7 +299,7 @@ if len(model_names) == 0:
initial_id = 0 initial_id = 0
initial_model_files = model_holder.model_files_dict[model_names[initial_id]] initial_model_files = model_holder.model_files_dict[model_names[initial_id]]
with gr.Blocks(theme="NoCrypt/miku") as app: with gr.Blocks(theme=GRADIO_THEME) as app:
gr.Markdown(initial_md) gr.Markdown(initial_md)
with gr.Accordion(label="使い方", open=False): with gr.Accordion(label="使い方", open=False):
gr.Markdown(initial_md) gr.Markdown(initial_md)

View File

@@ -12,7 +12,7 @@ from sklearn.cluster import DBSCAN, AgglomerativeClustering, KMeans
from sklearn.manifold import TSNE from sklearn.manifold import TSNE
from umap import UMAP from umap import UMAP
from common.constants import DEFAULT_STYLE from common.constants import DEFAULT_STYLE, GRADIO_THEME
from common.log import logger from common.log import logger
from config import config from config import config
@@ -209,9 +209,7 @@ def save_style_vectors_from_clustering(model_name, style_names_str: str):
style_names = [name.strip() for name in style_names_str.split(",")] style_names = [name.strip() for name in style_names_str.split(",")]
style_name_list = [DEFAULT_STYLE] + style_names style_name_list = [DEFAULT_STYLE] + style_names
if len(style_name_list) != len(centroids) + 1: if len(style_name_list) != len(centroids) + 1:
return ( return f"スタイルの数が合いません。`,`で正しく{len(centroids)}個に区切られているか確認してください: {style_names_str}"
f"スタイルの数が合いません。`,`で正しく{len(centroids)}個に区切られているか確認してください: {style_names_str}"
)
if len(set(style_names)) != len(style_names): if len(set(style_names)) != len(style_names):
return f"スタイル名が重複しています。" return f"スタイル名が重複しています。"
@@ -325,7 +323,7 @@ UMAPの場合はepsは0.3くらい、t-SNEの場合は2.5くらいがいいか
https://ja.wikipedia.org/wiki/DBSCAN https://ja.wikipedia.org/wiki/DBSCAN
""" """
with gr.Blocks(theme="NoCrypt/miku") as app: with gr.Blocks(theme=GRADIO_THEME) as app:
gr.Markdown(initial_md) gr.Markdown(initial_md)
with gr.Row(): with gr.Row():
model_name = gr.Textbox(placeholder="your_model_name", label="モデル名") model_name = gr.Textbox(placeholder="your_model_name", label="モデル名")
@@ -380,7 +378,9 @@ with gr.Blocks(theme="NoCrypt/miku") as app:
dbscan_button = gr.Button("スタイル分けを実行") dbscan_button = gr.Button("スタイル分けを実行")
num_styles_result = gr.Textbox(label="スタイル数") num_styles_result = gr.Textbox(label="スタイル数")
gr.Markdown("スタイル分けの結果") gr.Markdown("スタイル分けの結果")
gr.Markdown("注意: もともと256次元なものをを2次元に落としているので、正確なベクトルの位置関係ではありません。") gr.Markdown(
"注意: もともと256次元なものをを2次元に落としているので、正確なベクトルの位置関係ではありません。"
)
with gr.Row(): with gr.Row():
gr_plot = gr.Plot() gr_plot = gr.Plot()
with gr.Column(): with gr.Column():
@@ -436,7 +436,9 @@ with gr.Blocks(theme="NoCrypt/miku") as app:
outputs=[info2], outputs=[info2],
) )
with gr.Tab("方法2: 手動でスタイルを選ぶ"): with gr.Tab("方法2: 手動でスタイルを選ぶ"):
gr.Markdown("下のテキスト欄に、各スタイルの代表音声のファイル名を`,`区切りで、その横に対応するスタイル名を`,`区切りで入力してください。") gr.Markdown(
"下のテキスト欄に、各スタイルの代表音声のファイル名を`,`区切りで、その横に対応するスタイル名を`,`区切りで入力してください。"
)
gr.Markdown("例: `angry.wav, sad.wav, happy.wav`と`Angry, Sad, Happy`") gr.Markdown("例: `angry.wav, sad.wav, happy.wav`と`Angry, Sad, Happy`")
gr.Markdown( gr.Markdown(
f"注意: {DEFAULT_STYLE}スタイルは自動的に保存されます、手動では{DEFAULT_STYLE}という名前のスタイルは指定しないでください。" f"注意: {DEFAULT_STYLE}スタイルは自動的に保存されます、手動では{DEFAULT_STYLE}という名前のスタイルは指定しないでください。"

View File

@@ -2,8 +2,8 @@ import argparse
import json import json
import os import os
import shutil import shutil
import subprocess
import socket import socket
import subprocess
import sys import sys
import time import time
import webbrowser import webbrowser
@@ -13,7 +13,7 @@ from multiprocessing import cpu_count
import gradio as gr import gradio as gr
import yaml import yaml
from common.constants import LATEST_VERSION from common.constants import GRADIO_THEME, LATEST_VERSION
from common.log import logger from common.log import logger
from common.stdout_wrapper import SAFE_STDOUT from common.stdout_wrapper import SAFE_STDOUT
from common.subprocess_utils import run_script_with_log, second_elem_of from common.subprocess_utils import run_script_with_log, second_elem_of
@@ -421,7 +421,7 @@ english_teacher.wav|Mary|EN|How are you? I'm fine, thank you, and you?
""" """
if __name__ == "__main__": if __name__ == "__main__":
with gr.Blocks(theme="NoCrypt/miku").queue() as app: with gr.Blocks(theme=GRADIO_THEME).queue() as app:
gr.Markdown(initial_md) gr.Markdown(initial_md)
with gr.Accordion(label="データの前準備", open=False): with gr.Accordion(label="データの前準備", open=False):
gr.Markdown(prepare_md) gr.Markdown(prepare_md)
@@ -435,7 +435,7 @@ if __name__ == "__main__":
) )
batch_size = gr.Slider( batch_size = gr.Slider(
label="バッチサイズ", label="バッチサイズ",
info="速度が異様に遅い場合は小さく、VRAMに余裕があれば大きくしてください。使用量目安: 1: 6GB, 2: 8GB, 3: 10GB, 4: 12GB", info="学習速度が遅い場合は小さくして試し、VRAMに余裕があれば大きくしてください。JP-Extra版でのVRAM使用量目安: 1: 6GB, 2: 8GB, 3: 10GB, 4: 12GB",
value=2, value=2,
minimum=1, minimum=1,
maximum=64, maximum=64,
@@ -516,7 +516,7 @@ if __name__ == "__main__":
gr.Markdown(value="#### Step 1: 設定ファイルの生成") gr.Markdown(value="#### Step 1: 設定ファイルの生成")
use_jp_extra_manual = gr.Checkbox( use_jp_extra_manual = gr.Checkbox(
label="JP-Extra版を使う", label="JP-Extra版を使う",
value=False, value=True,
) )
batch_size_manual = gr.Slider( batch_size_manual = gr.Slider(
label="バッチサイズ", label="バッチサイズ",