Spaces:
Runtime error
Runtime error
File size: 3,259 Bytes
0d24b07 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
import os
from pathlib import Path, PurePosixPath
from huggingface_hub import hf_hub_download
def prepare_base_model():
print(f'Preparing base stable-diffusion-v1-5 weights...')
local_dir = "./pretrained_weights/stable-diffusion-v1-5"
os.makedirs(local_dir, exist_ok=True)
for hub_file in ["unet/config.json", "unet/diffusion_pytorch_model.bin"]:
path = Path(hub_file)
saved_path = local_dir / path
if os.path.exists(saved_path):
continue
hf_hub_download(
repo_id="runwayml/stable-diffusion-v1-5",
subfolder=PurePosixPath(path.parent),
filename=PurePosixPath(path.name),
local_dir=local_dir,
)
def prepare_image_encoder():
print(f"Preparing image encoder weights...")
local_dir = "./pretrained_weights"
os.makedirs(local_dir, exist_ok=True)
for hub_file in ["image_encoder/config.json", "image_encoder/pytorch_model.bin"]:
path = Path(hub_file)
saved_path = local_dir / path
if os.path.exists(saved_path):
continue
hf_hub_download(
repo_id="lambdalabs/sd-image-variations-diffusers",
subfolder=PurePosixPath(path.parent),
filename=PurePosixPath(path.name),
local_dir=local_dir,
)
def prepare_dwpose():
print(f"Preparing DWPose weights...")
local_dir = "./pretrained_weights/DWPose"
os.makedirs(local_dir, exist_ok=True)
for hub_file in [
"dw-ll_ucoco_384.onnx",
"yolox_l.onnx",
]:
path = Path(hub_file)
saved_path = local_dir / path
if os.path.exists(saved_path):
continue
hf_hub_download(
repo_id="yzd-v/DWPose",
subfolder=PurePosixPath(path.parent),
filename=PurePosixPath(path.name),
local_dir=local_dir,
)
def prepare_vae():
print(f"Preparing vae weights...")
local_dir = "./pretrained_weights/sd-vae-ft-mse"
os.makedirs(local_dir, exist_ok=True)
for hub_file in [
"config.json",
"diffusion_pytorch_model.bin",
]:
path = Path(hub_file)
saved_path = local_dir / path
if os.path.exists(saved_path):
continue
hf_hub_download(
repo_id="stabilityai/sd-vae-ft-mse",
subfolder=PurePosixPath(path.parent),
filename=PurePosixPath(path.name),
local_dir=local_dir,
)
def prepare_anyone():
print(f"Preparing AnimateAnyone weights...")
local_dir = "./pretrained_weights"
os.makedirs(local_dir, exist_ok=True)
for hub_file in [
"denoising_unet.pth",
"motion_module.pth",
"pose_guider.pth",
"reference_unet.pth",
]:
path = Path(hub_file)
saved_path = local_dir / path
if os.path.exists(saved_path):
continue
hf_hub_download(
repo_id="patrolli/AnimateAnyone",
subfolder=PurePosixPath(path.parent),
filename=PurePosixPath(path.name),
local_dir=local_dir,
)
if __name__ == '__main__':
prepare_base_model()
prepare_image_encoder()
prepare_dwpose()
prepare_vae()
prepare_anyone()
|