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

Function find_torch_model_path

lightx2v/utils/utils.py:437–453  ·  view source on GitHub ↗
(config, ckpt_config_key=None, filename=None, subdir=["original", "fp8", "int8", "distill_models", "distill_fp8", "distill_int8"])

Source from the content-addressed store, hash-verified

435
436def find_torch_model_path(config, ckpt_config_key=None, filename=None, subdir=["original", "fp8", "int8", "distill_models", "distill_fp8", "distill_int8"]):
437 if ckpt_config_key and config.get(ckpt_config_key, None) is not None:
438 return config.get(ckpt_config_key)
439
440 paths_to_check = [
441 os.path.join(config["model_path"], filename),
442 ]
443 if isinstance(subdir, list):
444 for sub in subdir:
445 paths_to_check.insert(0, os.path.join(config["model_path"], sub, filename))
446 else:
447 paths_to_check.insert(0, os.path.join(config["model_path"], subdir, filename))
448
449 for path in paths_to_check:
450 if os.path.exists(path):
451 return path
452 raise FileNotFoundError(f"PyTorch model file '{filename}' not found.\nPlease download the model from https://huggingface.co/lightx2v/ or specify the model path in the configuration file.")
453
454
455def load_safetensors(in_path, remove_key=None, include_keys=None):
456 """加载safetensors文件或目录,支持按key包含筛选或排除"""

Callers 15

load_wan_text_encoderFunction · 0.90
load_wan_image_encoderFunction · 0.90
load_wan_vae_encoderFunction · 0.90
load_wan_vae_decoderFunction · 0.90
load_vae_decoderMethod · 0.90
load_vae_encoderMethod · 0.90
load_vae_decoderMethod · 0.90
load_text_encoderMethod · 0.90
load_vae_encoderMethod · 0.90
load_vae_decoderMethod · 0.90
_load_ckptMethod · 0.90
load_image_encoderMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected