62 lines
8.3 KiB
Python
62 lines
8.3 KiB
Python
import os
|
|
import folder_paths
|
|
import sys
|
|
|
|
magic_animate_models_dir = os.path.join(folder_paths.models_dir, "MagicAnimate")
|
|
os.makedirs(magic_animate_models_dir, exist_ok=True)
|
|
|
|
appearance_encoder_path = os.path.join(magic_animate_models_dir, "appearance_encoder")
|
|
densepose_controlnet_path = os.path.join(magic_animate_models_dir, "densepose_controlnet")
|
|
temporal_attention_path = os.path.join(magic_animate_models_dir, "temporal_attention")
|
|
|
|
if not os.path.exists(appearance_encoder_path): # not os.path.exists(temporal_attention_path):
|
|
print("Downloading Magic Animate's appearance encoder...")
|
|
os.makedirs(appearance_encoder_path, exist_ok=True)
|
|
assert os.system(f"cd {appearance_encoder_path} && wget -q --show-progress --content-disposition 'https://huggingface.co/zcxu-eric/MagicAnimate/resolve/main/appearance_encoder/diffusion_pytorch_model.safetensors?download=true'") == 0, "ERROR: Failed to download Magic Animate models. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {appearance_encoder_path} && wget -q --show-progress --content-disposition 'https://huggingface.co/zcxu-eric/MagicAnimate/resolve/main/appearance_encoder/config.json?download=true' -O config.json") == 0, "ERROR: Failed to download Magic Animate models. Please check your internet connection and restart ComfyUI."
|
|
|
|
if not os.path.exists(densepose_controlnet_path):
|
|
print("Downloading Magic Animate's densepose controlnet...")
|
|
os.makedirs(densepose_controlnet_path, exist_ok=True)
|
|
assert os.system(f"cd {densepose_controlnet_path} && wget -q --show-progress --content-disposition 'https://huggingface.co/zcxu-eric/MagicAnimate/resolve/main/densepose_controlnet/diffusion_pytorch_model.safetensors?download=true'") == 0, "ERROR: Failed to download Magic Animate models. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {densepose_controlnet_path} && wget -q --show-progress --content-disposition 'https://huggingface.co/zcxu-eric/MagicAnimate/resolve/main/densepose_controlnet/config.json?download=true' -O config.json") == 0, "ERROR: Failed to download Magic Animate models. Please check your internet connection and restart ComfyUI."
|
|
|
|
if not os.path.exists(temporal_attention_path):
|
|
print("Downloading Magic Animate's temporal attention...")
|
|
os.makedirs(temporal_attention_path, exist_ok=True)
|
|
assert os.system(f"cd {temporal_attention_path} && wget -q --show-progress --content-disposition 'https://huggingface.co/zcxu-eric/MagicAnimate/resolve/main/temporal_attention/temporal_attention.ckpt?download=true'") == 0, "ERROR: Failed to download Magic Animate models. Please check your internet connection and restart ComfyUI."
|
|
|
|
sd_15_path = os.path.join(magic_animate_models_dir, "stable-diffusion-v1-5")
|
|
if not os.path.exists(sd_15_path):
|
|
print("Downloading stable-diffusion-v1-5 checkpoints from Huggingface...")
|
|
# assert os.system(f"cd {magic_animate_models_dir} && git clone https://huggingface.co/runwayml/stable-diffusion-v1-5") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
os.makedirs(sd_15_path, exist_ok=True)
|
|
os.makedirs(os.path.join(sd_15_path, "text_encoder"), exist_ok=True)
|
|
os.makedirs(os.path.join(sd_15_path, "tokenizer"), exist_ok=True)
|
|
os.makedirs(os.path.join(sd_15_path, "unet"), exist_ok=True)
|
|
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'text_encoder')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/text_encoder/config.json?download=true' -O config.json") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'text_encoder')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/text_encoder/model.safetensors?download=true'") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'tokenizer')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/tokenizer/merges.txt?download=true' -O merges.txt") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'tokenizer')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/tokenizer/special_tokens_map.json?download=true' -O special_tokens_map.json") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'tokenizer')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/tokenizer/tokenizer_config.json?download=true' -O tokenizer_config.json") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'tokenizer')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/tokenizer/vocab.json?download=true' -O vocab.json") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'unet')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/unet/config.json?download=true' -O config.json") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {os.path.join(sd_15_path, 'unet')} && wget -q --show-progress --content-disposition 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/unet/diffusion_pytorch_model.bin?download=true'") == 0, "ERROR: Failed to download stable-diffusion-v1-5 model files from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
|
|
sd_vae_ft_mse_path = os.path.join(magic_animate_models_dir, "sd-vae-ft-mse")
|
|
if not os.path.exists(sd_vae_ft_mse_path):
|
|
print("Downloading sd-vae-ft-mse model from Huggingface...")
|
|
os.makedirs(sd_vae_ft_mse_path, exist_ok=True)
|
|
assert os.system(f"cd {sd_vae_ft_mse_path} && wget --content-disposition -q --show-progress 'https://huggingface.co/stabilityai/sd-vae-ft-mse/resolve/main/config.json?download=true' -O config.json") == 0, "ERROR: Failed to download sd-vae-ft-mse model from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {sd_vae_ft_mse_path} && wget --content-disposition -q --show-progress 'https://huggingface.co/stabilityai/sd-vae-ft-mse/resolve/main/diffusion_pytorch_model.safetensors?download=true'") == 0, "ERROR: Failed to download sd-vae-ft-mse model from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
|
|
control_v11p_sd15_openpose_path = os.path.join(magic_animate_models_dir, "control_v11p_sd15_openpose")
|
|
if not os.path.exists(control_v11p_sd15_openpose_path):
|
|
print("Downloading control_v11p_sd15_openpose model from Huggingface...")
|
|
os.makedirs(control_v11p_sd15_openpose_path, exist_ok=True)
|
|
assert os.system(f"cd {control_v11p_sd15_openpose_path} && wget --content-disposition -q --show-progress 'https://huggingface.co/lllyasviel/control_v11p_sd15_openpose/resolve/main/diffusion_pytorch_model.safetensors?download=true'") == 0, "ERROR: Failed to download control_v11p_sd15_openpose model from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
assert os.system(f"cd {control_v11p_sd15_openpose_path} && wget --content-disposition -q --show-progress 'https://huggingface.co/lllyasviel/control_v11p_sd15_openpose/resolve/main/config.json?download=true' -O config.json") == 0, "ERROR: Failed to download control_v11p_sd15_openpose model from Huggingface. Please check your internet connection and restart ComfyUI."
|
|
|