{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "60b8e4a2-4e54-4dae-9220-31fc24fa719f", "metadata": { "scrolled": true, "tags": [] }, "outputs": [], "source": [ "%cd /notebooks/\n", "# Download and run the Anaconda3 installer\n", "import sys\n", "!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh\n", "!bash ./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local\n", "sys.path.append('/usr/local/lib/python3.7/site-packages/')\n", "!rm Miniconda3-latest-Linux-x86_64.sh\n", "!conda init bash\n", "!mkdir -p /notebooks/textual\\ inversion/\n", "!mkdir -p /notebooks/Stable-textual-inversion_win/logs/" ] }, { "cell_type": "code", "execution_count": null, "id": "d5743d8c-f0ba-4f07-971b-b498b0e306f4", "metadata": { "scrolled": true, "tags": [] }, "outputs": [], "source": [ "import os.path\n", "if not os.path.exists('/notebooks/Stable-textual-inversion_win'):\n", " %cd /notebooks/\n", " !git clone https://github.com/nicolai256/Stable-textual-inversion_win.git\n", " !mkdir -p /notebooks/textual\\ inversion/\n", " \n", "# Uncomment this to copy the detault config\n", " # !cp /notebooks/Stable-textual-inversion_win/configs/stable-diffusion/v1-finetune.yaml /notebooks/textual\\ inversion\n", "else: # update repo if already exists\n", " print('stable-diffusion-webui already downloaded, updating...')\n", " %cd /notebooks/Stable-textual-inversion_win\n", " !git pull\n", " \n", "# Symlink the output dir to /notebooks/\n", "!mkdir -p /notebooks/textual\\ inversion/output/\n", "!ln -s /notebooks/Stable-textual-inversion_win/logs/ \"/notebooks/textual inversion/\"" ] }, { "cell_type": "code", "execution_count": null, "id": "53ee34a7-e5f3-4529-b3b9-2bdac9a45c54", "metadata": { "scrolled": true, "tags": [] }, "outputs": [], "source": [ "%cd /notebooks/Stable-textual-inversion_win/\n", "!conda env update -n base --file environment.yaml\n", "!conda activate ldm\n", "!pip install setuptools==59.5.0\n", "!pip install pillow==9.0.1\n", "!pip install torchmetrics==0.6.0\n", "!pip install -e ." ] }, { "cell_type": "code", "execution_count": null, "id": "fa5eda42-c1c6-47b9-80ce-39b777c77bb5", "metadata": { "scrolled": true, "tags": [] }, "outputs": [], "source": [ "# Config\n", "\n", "config_path = '/notebooks/textual inversion/v1-finetune.yaml'\n", "\n", "# Directory holding the images you want to feed into the AI\n", "source_image_directory = '/notebooks/textual inversion/source/'\n", "\n", "# Word to activate the embedding in the SD WebUI\n", "init_word = 'simonstalenhag'\n", "\n", "project_name = 'simonstalenhag'\n", "\n", "actual_resume = '/storage/models/trinart2_step115000.ckpt' # trinart2_step115000.ckpt sd-v1-4.ckpt\n", "\n", "# ============================================================================================================\n", "\n", "!rm -rf \"{source_image_directory}/.ipynb_checkpoints\"\n", "%cd /notebooks/Stable-textual-inversion_win/\n", "!python main.py \\\n", " --base \"{config_path}\" \\\n", " -t --no-test \\\n", " --actual_resume \"{actual_resume}\" \\\n", " --gpus=1 \\\n", " --data_root \"{source_image_directory}\" \\\n", " --init_word {init_word} \\\n", " -n {project_name} \\" ] }, { "cell_type": "code", "execution_count": null, "id": "be231cb1-a562-48ac-abb7-2cbee730c9a9", "metadata": {}, "outputs": [], "source": [ "# Resuming\n", "\n", "# Config\n", "\n", "config_path = '/notebooks/textual inversion/v1-finetune.yaml'\n", "\n", "# Directory holding the images you want to feed into the AI\n", "source_image_directory = '/notebooks/textual inversion/source/'\n", "\n", "# Word to activate the embedding in the SD WebUI\n", "init_word = 'simonstalenhag'\n", "\n", "project_path = '/notebooks/textual inversion/logs/source2022-10-01T03-52-45_simonstalenhag'\n", "\n", "actual_resume = '/storage/models/trinart2_step115000.ckpt' # trinart2_step115000.ckpt sd-v1-4.ckpt\n", "\n", "# ============================================================================================================\n", "\n", "from datetime import datetime\n", "datetime_str = datetime.now().strftime('%m-%d-%Y_%H:%M:%S')\n", "\n", "!python \"main.py\" \\\n", " --base \"{config_path}\" \\\n", " -t --no-test \\\n", " --actual_resume \"{actual_resume}\" \\\n", " --gpus=1 \\\n", " --data_root \"{source_image_directory}\" \\\n", " --init_word \"{init_word}\" \\\n", " --project \"{project_path}\" \\\n", " --embedding_manager_ckpt \"{project_path}/checkpoints/embeddings.pt\" \\\n", " --resume_from_checkpoint \"{project_path}/checkpoints/last.ckpt\" \\\n", " -n \"{init_word}_continue_{datetime_str}\"" ] } ], "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 }