MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / build_wan22_components

Function build_wan22_components

app/utils/model_components.py:171–336  ·  view source on GitHub ↗

构建 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")

Source from the content-addressed store, hash-verified

169
170
171def 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(

Callers 1

build_video_pageFunction · 0.90

Calls 6

get_high_noise_choicesFunction · 0.90
extract_model_nameFunction · 0.90
check_model_existsFunction · 0.90
get_low_noise_choicesFunction · 0.90
tFunction · 0.90
get_lora_choicesFunction · 0.85

Tested by

no test coverage detected