构建 wan2.2 模型相关组件 必须在 Gradio 的 with 块内调用 Returns: dict: 包含所有 wan2.2 相关组件的字典
(model_path, model_path_input, task_type_input, download_source_input, update_funcs, download_funcs, lang="zh")
| 169 | |
| 170 | |
| 171 | def build_wan22_components(model_path, model_path_input, task_type_input, download_source_input, update_funcs, download_funcs, lang="zh"): |
| 172 | """构建 wan2.2 模型相关组件 |
| 173 | 必须在 Gradio 的 with 块内调用 |
| 174 | |
| 175 | Returns: |
| 176 | dict: 包含所有 wan2.2 相关组件的字典 |
| 177 | """ |
| 178 | # wan2.2 专用:高噪模型 + 低噪模型 |
| 179 | with gr.Row(visible=False, elem_classes=["wan22-row"]) as wan22_row: |
| 180 | with gr.Column(scale=1): |
| 181 | high_noise_choices_init = get_high_noise_choices(model_path, "wan2.2", "i2v") |
| 182 | high_noise_path_input = gr.Dropdown( |
| 183 | label="🔊 高噪模型", |
| 184 | choices=high_noise_choices_init, |
| 185 | value=high_noise_choices_init[0] if high_noise_choices_init else "", |
| 186 | allow_custom_value=True, |
| 187 | ) |
| 188 | # 初始化时检查模型状态 |
| 189 | from utils.model_utils import check_model_exists, extract_model_name |
| 190 | |
| 191 | high_noise_btn_visible = False |
| 192 | if high_noise_choices_init: |
| 193 | first_choice = high_noise_choices_init[0] |
| 194 | actual_name = extract_model_name(first_choice) |
| 195 | high_noise_exists = check_model_exists(model_path, actual_name) |
| 196 | high_noise_btn_visible = not high_noise_exists |
| 197 | |
| 198 | high_noise_download_btn = gr.Button("📥 下载", visible=high_noise_btn_visible, size="sm", variant="secondary") |
| 199 | high_noise_download_status = gr.Markdown("", visible=False) |
| 200 | with gr.Column(scale=1): |
| 201 | low_noise_choices_init = get_low_noise_choices(model_path, "wan2.2", "i2v") |
| 202 | low_noise_path_input = gr.Dropdown( |
| 203 | label="🔇 低噪模型", |
| 204 | choices=low_noise_choices_init, |
| 205 | value=low_noise_choices_init[0] if low_noise_choices_init else "", |
| 206 | allow_custom_value=True, |
| 207 | ) |
| 208 | # 初始化时检查模型状态 |
| 209 | low_noise_btn_visible = False |
| 210 | if low_noise_choices_init: |
| 211 | first_choice = low_noise_choices_init[0] |
| 212 | actual_name = extract_model_name(first_choice) |
| 213 | low_noise_exists = check_model_exists(model_path, actual_name) |
| 214 | low_noise_btn_visible = not low_noise_exists |
| 215 | |
| 216 | low_noise_download_btn = gr.Button("📥 下载", visible=low_noise_btn_visible, size="sm", variant="secondary") |
| 217 | low_noise_download_status = gr.Markdown("", visible=False) |
| 218 | |
| 219 | # LoRA 组件(Wan2.2 需要为 high_noise 和 low_noise 分别配置) |
| 220 | lora_choices_init = get_lora_choices(model_path) |
| 221 | with gr.Row(): |
| 222 | with gr.Column(scale=1): |
| 223 | use_lora = gr.Checkbox( |
| 224 | label=t("use_lora", lang), |
| 225 | value=False, |
| 226 | ) |
| 227 | # High Noise LoRA |
| 228 | high_noise_lora_path_input = gr.Dropdown( |
no test coverage detected