diff --git a/sd-concepts-library Exporter.ipynb b/sd-concepts-library Exporter.ipynb new file mode 100644 index 0000000..85fcbb1 --- /dev/null +++ b/sd-concepts-library Exporter.ipynb @@ -0,0 +1,107 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "269953b9-0933-4acc-b3b9-f6637d55008d", + "metadata": {}, + "source": [ + "# `sd-concepts-library` Exporter\n", + "\n", + "Download every Stable Diffusion textual inversion model from `sd-concepts-library`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d83832f8-2ed8-470b-826e-164befb0753c", + "metadata": { + "scrolled": true, + "tags": [] + }, + "outputs": [], + "source": [ + "# Install\n", + "!pip install huggingface-hub wget\n", + "!apt update\n", + "!apt install -y git-lfs\n", + "!mkdir -p /notebooks/sd-concepts-library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f6dbd2aa-56ec-4ac8-987e-848afe017a68", + "metadata": { + "scrolled": true, + "tags": [] + }, + "outputs": [], + "source": [ + "%cd /notebooks/sd-concepts-library\n", + "import requests\n", + "import os\n", + "import wget\n", + "from huggingface_hub import HfApi\n", + "\n", + "api = HfApi()\n", + "models_list = api.list_models(author=\"sd-concepts-library\", sort=\"likes\", direction=-1)\n", + "print('Downloading', len(models_list), 'models...')\n", + "\n", + "i = 1\n", + "for model_info in models_list:\n", + " print(f'\\nCloning {model_info.modelId} | {i}/{len(models_list)}')\n", + " url = f'https://huggingface.co/{model_info.modelId}'\n", + " !git clone $url\n", + " i = i + 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8ad2bafd-dcad-4012-a6e4-ee298715019f", + "metadata": {}, + "outputs": [], + "source": [ + "!apt update\n", + "!apt install -y p7zip-full\n", + "from datetime import datetime\n", + "import os\n", + "datetime_str = datetime.now().strftime('%m-%d-%Y_%H:%M:%S')\n", + "%cd /notebooks/\n", + "print('Compressing, please wait...')\n", + "os.system(f'7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on sd-concepts-library_{datetime_str}.7z sd-concepts-library/')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cb7bdb05-8a84-4184-8d4c-31404a554d53", + "metadata": {}, + "outputs": [], + "source": [ + "!rm -rf /notebooks/sd-concepts-library" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}