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

Function update_model_components

app/utils/video_page.py:327–414  ·  view source on GitHub ↗

统一更新所有模型组件

(model_type, task_type, model_path_val)

Source from the content-addressed store, hash-verified

325
326 # 统一的模型组件更新函数
327 def update_model_components(model_type, task_type, model_path_val):
328 """统一更新所有模型组件"""
329 show_clip = model_type == "Wan2.1" and task_type == "i2v"
330 show_image_input = task_type == "i2v"
331 is_wan21 = model_type == "Wan2.1"
332
333 # 获取模型选项
334 t5_choices = get_t5_model_choices(model_path_val)
335 vae_choices = get_vae_choices(model_path_val)
336 clip_choices = get_clip_model_choices(model_path_val) if show_clip else []
337
338 # 更新 Tokenizer 状态
339 t5_tokenizer_result = update_t5_tokenizer_status(model_path_val)
340 clip_tokenizer_result = update_clip_tokenizer_status(model_path_val)
341
342 # 更新模型下载按钮状态
343 t5_btn_update = update_t5_model_status(model_path_val, t5_choices[0] if t5_choices else "")
344 clip_btn_update = update_clip_model_status(model_path_val, clip_choices[0] if clip_choices else "") if show_clip else gr.update()
345 vae_btn_update = update_vae_status(model_path_val, vae_choices[0] if vae_choices else "")
346
347 if is_wan21:
348 dit_choices = get_dit_choices(model_path_val, "wan2.1", task_type)
349 # 更新 DIT 下载按钮状态
350 from utils.model_utils import extract_model_name
351
352 dit_btn_update = update_dit_status(model_path_val, extract_model_name(dit_choices[0]) if dit_choices else "", "wan2.1") if dit_choices else gr.update(visible=False)
353 return (
354 gr.update(visible=True), # wan21_row
355 gr.update(visible=False), # wan22_row
356 gr.update(choices=dit_choices, value=dit_choices[0] if dit_choices else "", visible=True), # dit_path_input
357 gr.update(), # high_noise_path_input
358 gr.update(), # low_noise_path_input
359 gr.update(visible=show_clip), # clip_row
360 gr.update(visible=True), # vae_row
361 gr.update(visible=True), # t5_row
362 gr.update(choices=t5_choices, value=t5_choices[0] if t5_choices else ""), # t5_path_input
363 gr.update(choices=clip_choices, value=clip_choices[0] if clip_choices else ""), # clip_path_input
364 gr.update(choices=vae_choices, value=vae_choices[0] if vae_choices else ""), # vae_path_input
365 gr.update(visible=show_image_input), # image_input_row
366 gr.update(label=t("output_video_path", lang)), # save_result_path
367 t5_tokenizer_result[0], # t5_tokenizer_hint
368 t5_tokenizer_result[1], # t5_tokenizer_download_btn
369 clip_tokenizer_result[0], # clip_tokenizer_hint
370 clip_tokenizer_result[1], # clip_tokenizer_download_btn
371 t5_btn_update, # t5_download_btn
372 clip_btn_update, # clip_download_btn
373 vae_btn_update, # vae_download_btn
374 dit_btn_update, # dit_download_btn
375 gr.update(), # high_noise_download_btn
376 gr.update(), # low_noise_download_btn
377 )
378 else: # wan2.2
379 high_noise_choices = get_high_noise_choices(model_path_val, "wan2.2", task_type)
380 low_noise_choices = get_low_noise_choices(model_path_val, "wan2.2", task_type)
381 # 更新 high_noise 和 low_noise 下载按钮状态
382 from utils.model_utils import extract_model_name
383
384 high_noise_btn_update = (

Callers

nothing calls this directly

Calls 15

get_t5_model_choicesFunction · 0.90
get_vae_choicesFunction · 0.90
get_clip_model_choicesFunction · 0.90
get_dit_choicesFunction · 0.90
extract_model_nameFunction · 0.90
tFunction · 0.90
get_high_noise_choicesFunction · 0.90
get_low_noise_choicesFunction · 0.90
update_t5_model_statusFunction · 0.85
update_clip_model_statusFunction · 0.85

Tested by

no test coverage detected