From 8abcc2241e82c4cf2875d9da5c8395d773f5133f Mon Sep 17 00:00:00 2001 From: Cyberes Date: Thu, 22 Sep 2022 00:34:11 -0600 Subject: [PATCH] Create download_sd-concepts-library.py Former-commit-id: 4c06bc0c34fc045dbdfb051fc2409340b5e7d80a [formerly 1c60d6e71d3309f635731495564e9dee4447555b] Former-commit-id: 8bfadbfc602e5c1acb8fde7d4c87cb36ee809929 --- Other/download_sd-concepts-library.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Other/download_sd-concepts-library.py diff --git a/Other/download_sd-concepts-library.py b/Other/download_sd-concepts-library.py new file mode 100644 index 0000000..a5bb38d --- /dev/null +++ b/Other/download_sd-concepts-library.py @@ -0,0 +1,27 @@ +# Download all textual inversion models sd-concepts-library +# https://huggingface.co/sd-concepts-library +# Make sure to add your username and password below. + +hf_username '' +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() +models_list = api.list_models(author="sd-concepts-library", sort="likes", direction=-1) +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/', '') + os.system(f'git clone --depth=1 https://{hf_username}:{hf_password}@huggingface.co/{model_info.modelId} repositories/{model_name}') + os.system(f'rm -rf repositories/{model_name}/.git*') + os.system(f'mv repositories/{model_name}/learned_embeds.bin {model_name}.pt') + i = i + 1