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

**Feat: Integrate Loss Graphs into Gradio Interface** #2241

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion i18n/locale/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "Pitch settings",
"音频设备": "Audio device",
"音高算法": "pitch detection algorithm",
"额外推理时长": "Extra inference time"
"额外推理时长": "Extra inference time",
"损失图": "Loss Graph",
"选择语音": "Select voice",
"更新损失图": "Update Loss Graph",
"更新语音列表": "Update Voice List",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "Training Progress Overview: Lower values indicate better model performance. For detailed insights, explore TensorBoard."
}
7 changes: 6 additions & 1 deletion i18n/locale/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "Ajuste de tono",
"音频设备": "Dispositivo de audio",
"音高算法": "Algoritmo de tono",
"额外推理时长": "Tiempo de inferencia adicional"
"额外推理时长": "Tiempo de inferencia adicional",
"损失图": "Gráfico de pérdida",
"选择语音": "Seleccione el audio",
"更新损失图": "Actualizar gráfico de pérdida",
"更新语音列表": "Actualizar lista de audio",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "Resumen del progreso de entrenamiento: cuanto menor sea el valor, mejor será el rendimiento del modelo. Para obtener una visión detallada, explore TensorBoard."
}
7 changes: 6 additions & 1 deletion i18n/locale/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "Réglages de la hauteur",
"音频设备": "Périphérique audio",
"音高算法": "algorithme de détection de la hauteur",
"额外推理时长": "Temps d'inférence supplémentaire"
"额外推理时长": "Temps d'inférence supplémentaire",
"损失图": "Graphique de perte",
"选择语音": "Sélectionner la voix",
"更新损失图": "Actualiser le graphique de perte",
"更新语音列表": "Actualiser la liste des voix",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "Aperçu de la progression de l'entraînement : les valeurs inférieures indiquent des performances de modèle plus élevées. Pour une compréhension détaillée, explorez TensorBoard."
}
7 changes: 6 additions & 1 deletion i18n/locale/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "Impostazioni del tono",
"音频设备": "Dispositivo audio",
"音高算法": "音高算法",
"额外推理时长": "Tempo di inferenza extra"
"额外推理时长": "Tempo di inferenza extra",
"损失图": "Grafico delle perdite",
"选择语音": "Seleziona la voce",
"更新损失图": "Aggiornare il grafico delle perdite",
"更新语音列表": "Aggiornare l'elenco delle voci",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "Riepilogo del progresso dell'addestramento: i valori più bassi indicano prestazioni di modello migliori. Per una comprensione più approfondita, esplora TensorBoard."
}
7 changes: 6 additions & 1 deletion i18n/locale/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "音程設定",
"音频设备": "オーディオデバイス",
"音高算法": "ピッチアルゴリズム",
"额外推理时长": "追加推論時間"
"额外推理时长": "追加推論時間",
"损失图": "損失グラフ",
"选择语音": "音声を選択",
"更新损失图": "損失グラフを更新する",
"更新语音列表": "音声リストを更新する",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "トレーニング進行状況の概要:値が低いほど、モデルの性能が良い。詳細な見解を得るには、TensorBoardを探索してください。"
}
7 changes: 6 additions & 1 deletion i18n/locale/ko_KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "음조 설정",
"音频设备": "音频设备",
"音高算法": "음높이 알고리즘",
"额外推理时长": "추가 추론 시간"
"额外推理时长": "추가 추론 시간",
"损失图": "손실 그래프",
"选择语音": "음성 선택",
"更新损失图": "손실 그래프 업데이트",
"更新语音列表": "음성 목록 업데이트",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "훈련 진행 개요: 값이 낮을수록 모델 성능이 좋습니다. 자세한 내용은 TensorBoard를 탐색하세요."
}
7 changes: 6 additions & 1 deletion i18n/locale/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "Configurações de tom",
"音频设备": "音频设备",
"音高算法": "Algoritmo de detecção de pitch",
"额外推理时长": "Tempo extra de inferência"
"额外推理时长": "Tempo extra de inferência",
"损失图": "Gráfico de perda",
"选择语音": "Selecione o áudio",
"更新损失图": "Atualizar gráfico de perda",
"更新语音列表": "Atualizar lista de áudio",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "Visão geral do progresso do treinamento: quanto menor o valor, melhor o desempenho do modelo. Para obter insights detalhados, explore o TensorBoard."
}
7 changes: 6 additions & 1 deletion i18n/locale/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "Настройка высоты звука",
"音频设备": "Аудиоустройство",
"音高算法": "Алгоритм оценки высоты звука",
"额外推理时长": "Доп. время переработки"
"额外推理时长": "Доп. время переработки",
"损失图": "График потерь",
"选择语音": "Выберите голос",
"更新损失图": "Обновить график потерь",
"更新语音列表": "Обновить список голосов",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "Обзор обучения: чем ниже значение, тем лучше качество модели. Подробнее см. TensorBoard."
}
7 changes: 6 additions & 1 deletion i18n/locale/tr_TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "Pitch ayarları",
"音频设备": "Ses cihazı",
"音高算法": "音高算法",
"额外推理时长": "Ekstra çıkartma süresi"
"额外推理时长": "Ekstra çıkartma süresi",
"损失图": "Kayıp grafiği",
"选择语音": "Konuşma seç",
"更新损失图": "Kayıp grafiğini güncelle",
"更新语音列表": "Konuşma listesini güncelle",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "Eğitim ilerlemesi özeti: Düşük değerler, model performansının daha iyi olduğunu gösterir. Daha fazla ayrıntı için TensorBoard'u keşfedin."
}
7 changes: 6 additions & 1 deletion i18n/locale/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "音调设置",
"音频设备": "音频设备",
"音高算法": "音高算法",
"额外推理时长": "额外推理时长"
"额外推理时长": "额外推理时长",
"损失图": "损失图",
"选择语音": "选择语音",
"更新损失图": "更新损失图",
"更新语音列表": "更新语音列表",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。"
}
7 changes: 6 additions & 1 deletion i18n/locale/zh_HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "音調設定",
"音频设备": "音訊設備",
"音高算法": "音高演算法",
"额外推理时长": "額外推理時長"
"额外推理时长": "額外推理時長",
"损失图": "損失圖",
"选择语音": "選擇語音",
"更新损失图": "更新損失圖",
"更新语音列表": "更新語音列表",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "訓練進度概覽:值越低,模型性能越好。如需詳細見解,請探索 TensorBoard。"
}
7 changes: 6 additions & 1 deletion i18n/locale/zh_SG.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "音調設定",
"音频设备": "音訊設備",
"音高算法": "音高演算法",
"额外推理时长": "額外推理時長"
"额外推理时长": "額外推理時長",
"损失图": "損失圖",
"选择语音": "選擇語音",
"更新损失图": "更新損失圖",
"更新语音列表": "更新語音列表",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "訓練進度概覽:值越低,模型性能越好。如需詳細見解,請探索 TensorBoard。"
}
7 changes: 6 additions & 1 deletion i18n/locale/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@
"音调设置": "音調設定",
"音频设备": "音訊設備",
"音高算法": "音高演算法",
"额外推理时长": "額外推理時長"
"额外推理时长": "額外推理時長",
"损失图": "損失圖",
"选择语音": "选择语音",
"更新损失图": "更新損失圖",
"更新语音列表": "更新语音列表",
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。": "訓練進度概覽:值越低,模型性能越好。如需詳細見解,請探索 TensorBoard。"
}
150 changes: 150 additions & 0 deletions infer-web.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os
import sys
from dotenv import load_dotenv
Expand Down Expand Up @@ -806,6 +807,113 @@ def change_f0_method(f0method8):
return {"visible": visible, "__type__": "update"}


# start tab loss graph helper functions
desired_tags = ["loss_d_total", "loss_g_total", "loss_g_fm", "loss_g_mel", "loss_g_kl"]


def get_projects():
"""
Gets a list of project names from the index root directory.

Returns:
list: A list of project names.
str: The default project name (first in the list).
dict: A dictionary of image paths keyed by desired_tags for the default project.
"""
projects = [name for name in os.listdir(index_root) if os.path.isdir(os.path.join(index_root, name)) and name != 'mute' and os.path.isdir(os.path.join(index_root, name, 'loss_graphs'))]

# Check if there are any projects before accessing
if projects:
default_project_name = projects[0]
else:
print("No projects found.")
default_project_name = None

return sorted(projects), default_project_name


def get_loss_graph_images(selection):
"""
Gets loss graph images for a given project, assuming filenames match desired order.

Args:
selection (str): Project name.

Returns:
dict: A dictionary of image paths keyed by desired_tags.
"""
if not selection:
print("No project selected")
return {}

loss_graphs_path = os.path.join(index_root, selection, 'loss_graphs')
if not os.path.exists(loss_graphs_path):
print(f"Directory not found: {loss_graphs_path}")
return {}

graphs = {}
for tag in desired_tags:
image_path = os.path.join(loss_graphs_path, f"{tag}.jpeg")
if os.path.exists(image_path):
graphs[tag] = image_path

return graphs


def get_loss_graph_tabs(project):
"""
Create Gradio Tabs and Image fields for the loss graphs.

Args:
project (str): Project name.

Returns:
gr.Tabs, list: A tuple containing the Gradio Tabs component and a list of image fields.
"""
loss_graph_tabs = gr.Tabs()
loss_graph_images = get_loss_graph_images(project)
loss_graph_image_fields = {}

with loss_graph_tabs:
for tag, image_path in loss_graph_images.items():
with gr.TabItem(tag):
image_field = gr.Image(value=image_path, width="100%")
loss_graph_image_fields[tag] = image_field
return loss_graph_tabs, list(loss_graph_image_fields.values())


def update_loss_graph_images(selection):
"""
Update the loss graph images for a given project.
"""
loss_graph_images = get_loss_graph_images(selection)
updated_values = []

for i, tag in enumerate(desired_tags):
if i < len(image_fields):
if tag in loss_graph_images:
image_path = loss_graph_images[tag]
if os.path.exists(image_path) and os.path.isfile(image_path):
updated_values.append(image_path)
else:
print(f"Warning: Image file does not exist or is not a file: {image_path}")
updated_values.append(None)
else:
print(f"Warning: No image found for tag: {tag}")
updated_values.append(None)

return updated_values


def update_projects():
"""
Update the list of projects.
"""
projects, default_project_name = get_projects()
return {"choices": projects, "__type__": "update"}


# gradio app
with gr.Blocks(title="RVC WebUI") as app:
gr.Markdown("## RVC WebUI")
gr.Markdown(
Expand Down Expand Up @@ -1420,7 +1528,49 @@ def change_f0_method(f0method8):
info3,
api_name="train_start_all",
)
with gr.TabItem(i18n("损失图")):
gr.Markdown(
value=i18n(
"训练进度概览:值越低,模型性能越好。如需详细见解,请探索 TensorBoard。"
)
)
with gr.Row():
projects, default_project_name = get_projects()
voice_list_dropdown = gr.Dropdown(
label=i18n("选择语音"),
choices=projects,
interactive=True,
value=default_project_name
)
with gr.Column():
update_voice_list_button = gr.Button(
i18n("更新语音列表"),
variant="primary"
)
update_loss_graph_button = gr.Button(
i18n("更新损失图"),
variant="primary"
)
update_voice_list_button.click(
fn=update_projects,
inputs=[],
outputs=[voice_list_dropdown],
api_name="infer_refresh"
)
with gr.Row():
tabs, image_fields = get_loss_graph_tabs(default_project_name)

voice_list_dropdown.change(
fn=update_loss_graph_images,
inputs=voice_list_dropdown,
outputs=image_fields
)

update_loss_graph_button.click(
fn=update_loss_graph_images,
inputs=voice_list_dropdown,
outputs=image_fields
)
with gr.TabItem(i18n("ckpt处理")):
with gr.Group():
gr.Markdown(value=i18n("模型融合, 可用于测试音色融合"))
Expand Down
Loading