stable-diffusion-paperspace/Other/download_sd-concepts-librar...

31 lines
1.3 KiB
Python
Raw Normal View History

2022-09-22 00:34:11 -06:00
# Download all textual inversion models sd-concepts-library
# https://huggingface.co/sd-concepts-library
# Make sure to add your username and password below.
2022-09-22 00:39:11 -06:00
hf_username = ''
2022-09-22 00:34:11 -06:00
hf_password = ''
# Install/Setup:
# pip install huggingface-hub
# apt update && apt install -y git-lfs
# mkdir -p /sd-concepts-library/repositories
from huggingface_hub import HfApi
import os
api = HfApi()
2022-09-22 00:38:05 -06:00
models_list = api.list_models(author="sd-concepts-library")
2022-09-22 00:34:11 -06:00
print('Downloading', len(models_list), 'models...')
i = 1
for model_info in models_list:
print(f'\nCloning {model_info.modelId} | {i}/{len(models_list)}')
model_name = model_info.modelId.replace('sd-concepts-library/', '')
2022-09-22 00:35:22 -06:00
os.system(f'git clone --depth=1 https://{hf_username}:{hf_password}@huggingface.co/{model_info.modelId} repositories/{model_name}') # clone with no git history
os.system(f'rm -rf repositories/{model_name}/.git*') # delete all git stuff in the repository
os.system(f'mv repositories/{model_name}/learned_embeds.bin {model_name}.pt') # move the bin file out of the repository and rename it to a .pt file
2022-09-22 00:34:11 -06:00
i = i + 1
2022-09-22 00:38:05 -06:00
# Pro-tip: use this command to compress the files with 7zip max compression.
# 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on sd-concepts-library_complete.7z sd-concepts-library/