Spaces:
Running
Running
Update gradio_tabs/merge.py
Browse files- gradio_tabs/merge.py +28 -4
gradio_tabs/merge.py
CHANGED
@@ -773,10 +773,28 @@ def set_default_style_ratios(is_extended: bool, merged_data: Optional[dict], mod
|
|
773 |
return updates
|
774 |
|
775 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
776 |
def get_fn_models(model_list: List[str]) -> List[str]:
|
777 |
-
"""FNシリーズとwhisper
|
778 |
fn_pattern = re.compile(r"^FN([1-9]|10)$")
|
779 |
-
|
|
|
|
|
|
|
|
|
|
|
780 |
|
781 |
def get_standard_models(model_list: List[str]) -> List[str]:
|
782 |
"""FNシリーズとwhisper以外のモデルをリストから抽出する"""
|
@@ -1009,7 +1027,10 @@ def create_merge_app(model_holder: TTSModelHolder) -> gr.Blocks:
|
|
1009 |
# 存在する場合、現在の表示モードの選択肢になくても追加して選択を維持
|
1010 |
if current_value not in final_choices:
|
1011 |
final_choices.append(current_value)
|
1012 |
-
|
|
|
|
|
|
|
1013 |
updates.append(gr.update(choices=final_choices, value=current_value))
|
1014 |
else:
|
1015 |
# 存在しない場合 (モデルが削除された等)、リセットする
|
@@ -1043,7 +1064,10 @@ def create_merge_app(model_holder: TTSModelHolder) -> gr.Blocks:
|
|
1043 |
if current_value and current_value not in final_choices:
|
1044 |
# ユーザーの選択を維持するために、一時的に選択肢に追加
|
1045 |
final_choices.append(current_value)
|
1046 |
-
|
|
|
|
|
|
|
1047 |
|
1048 |
# valueはGradioが自動で維持してくれるので、choicesのみ更新
|
1049 |
updates.append(gr.update(choices=final_choices))
|
|
|
773 |
return updates
|
774 |
|
775 |
|
776 |
+
# =========================================================================
|
777 |
+
# ★★★★★★★★★★★★★★★★★★★ 修正箇所 ★★★★★★★★★★★★★★★★★★★
|
778 |
+
# =========================================================================
|
779 |
+
def fn_model_sort_key(name: str):
|
780 |
+
"""FNモデルを自然順ソートするためのキー関数。FN以外のモデルも扱う。"""
|
781 |
+
match = re.match(r"FN(\d+)", name)
|
782 |
+
if match:
|
783 |
+
# FNモデルは (0, 数値) のタプルをキーにする
|
784 |
+
return (0, int(match.group(1)))
|
785 |
+
# FN以外のモデル (whisperや標準モデル) は (1, 名前) をキーにする
|
786 |
+
return (1, name)
|
787 |
+
|
788 |
+
|
789 |
def get_fn_models(model_list: List[str]) -> List[str]:
|
790 |
+
"""FNシリーズとwhisperモデルをリストから抽出し、自然順ソートして返す"""
|
791 |
fn_pattern = re.compile(r"^FN([1-9]|10)$")
|
792 |
+
target_models = [name for name in model_list if fn_pattern.match(name) or name == "whisper"]
|
793 |
+
# キー関数でソート
|
794 |
+
return sorted(target_models, key=fn_model_sort_key)
|
795 |
+
# =========================================================================
|
796 |
+
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
|
797 |
+
|
798 |
|
799 |
def get_standard_models(model_list: List[str]) -> List[str]:
|
800 |
"""FNシリーズとwhisper以外のモデルをリストから抽出する"""
|
|
|
1027 |
# 存在する場合、現在の表示モードの選択肢になくても追加して選択を維持
|
1028 |
if current_value not in final_choices:
|
1029 |
final_choices.append(current_value)
|
1030 |
+
if is_fn_mode:
|
1031 |
+
final_choices.sort(key=fn_model_sort_key)
|
1032 |
+
else:
|
1033 |
+
final_choices.sort()
|
1034 |
updates.append(gr.update(choices=final_choices, value=current_value))
|
1035 |
else:
|
1036 |
# 存在しない場合 (モデルが削除された等)、リセットする
|
|
|
1064 |
if current_value and current_value not in final_choices:
|
1065 |
# ユーザーの選択を維持するために、一時的に選択肢に追加
|
1066 |
final_choices.append(current_value)
|
1067 |
+
if is_fn_mode:
|
1068 |
+
final_choices.sort(key=fn_model_sort_key)
|
1069 |
+
else:
|
1070 |
+
final_choices.sort()
|
1071 |
|
1072 |
# valueはGradioが自動で維持してくれるので、choicesのみ更新
|
1073 |
updates.append(gr.update(choices=final_choices))
|