| import torch | |
| from safetensors.torch import load_file | |
| # 1. 载入 safetensors 权重文件 | |
| safetensor_path = "diffusion_pytorch_model.safetensors" | |
| state_dict = load_file(safetensor_path) | |
| # 2. 保存为 PyTorch 的 .pth 格式 | |
| torch.save(state_dict, "Wan2.1_VAE.pth") | |
| print("转换完成:Wan2.1_VAE.pth") | |