构建 wan2.1 模型相关组件 必须在 Gradio 的 with 块内调用 Returns: dict: 包含所有 wan2.1 相关组件的字典
(model_path, model_path_input, model_type_input, task_type_input, download_source_input, update_funcs, download_funcs, lang="zh")
| 60 | |
| 61 | |
| 62 | def build_wan21_components(model_path, model_path_input, model_type_input, task_type_input, download_source_input, update_funcs, download_funcs, lang="zh"): |
| 63 | """构建 wan2.1 模型相关组件 |
| 64 | 必须在 Gradio 的 with 块内调用 |
| 65 | |
| 66 | Returns: |
| 67 | dict: 包含所有 wan2.1 相关组件的字典 |
| 68 | """ |
| 69 | # wan2.1:Diffusion模型 |
| 70 | with gr.Column(elem_classes=["diffusion-model-group"]) as wan21_row: |
| 71 | with gr.Row(): |
| 72 | with gr.Column(scale=5): |
| 73 | dit_choices_init = get_dit_choices(model_path, "wan2.1", "i2v") |
| 74 | dit_path_input = gr.Dropdown( |
| 75 | label="🎨 Diffusion模型", |
| 76 | choices=dit_choices_init, |
| 77 | value=dit_choices_init[0] if dit_choices_init else "", |
| 78 | allow_custom_value=True, |
| 79 | visible=True, |
| 80 | ) |
| 81 | with gr.Column(scale=1, min_width=150): |
| 82 | # 初始化时检查模型状态,确定下载按钮的初始可见性 |
| 83 | from utils.model_utils import check_model_exists, extract_model_name |
| 84 | |
| 85 | dit_btn_visible = False |
| 86 | if dit_choices_init: |
| 87 | first_choice = dit_choices_init[0] |
| 88 | actual_name = extract_model_name(first_choice) |
| 89 | dit_exists = check_model_exists(model_path, actual_name) |
| 90 | dit_btn_visible = not dit_exists |
| 91 | |
| 92 | dit_download_btn = gr.Button("📥 下载", visible=dit_btn_visible, size="sm", variant="secondary") |
| 93 | dit_download_status = gr.Markdown("", visible=False) |
| 94 | |
| 95 | lora_choices_init = get_lora_choices(model_path) |
| 96 | with gr.Row(): |
| 97 | with gr.Column(scale=1): |
| 98 | use_lora = gr.Checkbox( |
| 99 | label=t("use_lora", lang), |
| 100 | value=False, |
| 101 | ) |
| 102 | lora_path_input = gr.Dropdown( |
| 103 | label=t("lora", lang), |
| 104 | choices=lora_choices_init, |
| 105 | value=lora_choices_init[0] if lora_choices_init and lora_choices_init[0] else "", |
| 106 | allow_custom_value=True, |
| 107 | visible=False, |
| 108 | info=t("lora_info", lang), |
| 109 | ) |
| 110 | lora_strength = gr.Slider( |
| 111 | label=t("lora_strength", lang), |
| 112 | minimum=0.0, |
| 113 | maximum=10.0, |
| 114 | step=0.1, |
| 115 | value=1.0, |
| 116 | visible=False, |
| 117 | info=t("lora_strength_info", lang), |
| 118 | ) |
| 119 |
no test coverage detected