(config, ckpt_config_key=None, filename=None, subdir=["original", "fp8", "int8", "distill_models", "distill_fp8", "distill_int8"])
| 435 | |
| 436 | def 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 | |
| 455 | def load_safetensors(in_path, remove_key=None, include_keys=None): |
| 456 | """加载safetensors文件或目录,支持按key包含筛选或排除""" |
no test coverage detected