| 5 | |
| 6 | |
| 7 | def prepare_base_model(): |
| 8 | print(f'Preparing base stable-diffusion-v1-5 weights...') |
| 9 | local_dir = "./pretrained_weights/stable-diffusion-v1-5" |
| 10 | os.makedirs(local_dir, exist_ok=True) |
| 11 | for hub_file in ["unet/config.json", "unet/diffusion_pytorch_model.bin"]: |
| 12 | path = Path(hub_file) |
| 13 | saved_path = local_dir / path |
| 14 | if os.path.exists(saved_path): |
| 15 | continue |
| 16 | hf_hub_download( |
| 17 | repo_id="runwayml/stable-diffusion-v1-5", |
| 18 | subfolder=PurePosixPath(path.parent), |
| 19 | filename=PurePosixPath(path.name), |
| 20 | local_dir=local_dir, |
| 21 | ) |
| 22 | |
| 23 | |
| 24 | def prepare_image_encoder(): |