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

Function get_lora_choices

app/utils/model_components.py:32–59  ·  view source on GitHub ↗

获取 LoRA 模型可选项,从 model_path/loras 目录检索 Args: model_path: 模型根路径 Returns: list: LoRA 文件列表,如果没有则返回 [""]

(model_path)

Source from the content-addressed store, hash-verified

30
31
32def get_lora_choices(model_path):
33 """获取 LoRA 模型可选项,从 model_path/loras 目录检索
34
35 Args:
36 model_path: 模型根路径
37
38 Returns:
39 list: LoRA 文件列表,如果没有则返回 [""]
40 """
41 loras_dir = os.path.join(model_path, "loras")
42 if not os.path.exists(loras_dir):
43 return [""]
44
45 lora_files = []
46 # 支持常见的 LoRA 文件格式
47 lora_extensions = [".safetensors", ".pt", ".pth", ".ckpt"]
48
49 for item in os.listdir(loras_dir):
50 item_path = os.path.join(loras_dir, item)
51 if os.path.isfile(item_path):
52 # 检查是否是 LoRA 文件
53 if any(item.lower().endswith(ext) for ext in lora_extensions):
54 lora_files.append(item)
55
56 # 按文件名排序
57 lora_files.sort()
58
59 return lora_files if lora_files else [""]
60
61
62def build_wan21_components(model_path, model_path_input, model_type_input, task_type_input, download_source_input, update_funcs, download_funcs, lang="zh"):

Callers 5

build_wan21_componentsFunction · 0.85
update_lora_choicesFunction · 0.85
build_wan22_componentsFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected