2022-10-01 13:41:10 -06:00
|
|
|
{
|
|
|
|
"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 ."
|
|
|
|
]
|
|
|
|
},
|
2022-10-07 13:17:53 -06:00
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "e201a6a3-b488-41c7-91d0-c9863f51e178",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"Now upload the images you want to feed into the AI to `/notebooks/textual inversion/source/`."
|
|
|
|
]
|
|
|
|
},
|
2022-10-01 13:41:10 -06:00
|
|
|
{
|
|
|
|
"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",
|
2022-10-03 10:11:53 -06:00
|
|
|
"init_word = 'bananas'\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"\n",
|
2022-10-03 10:11:53 -06:00
|
|
|
"project_name = 'bananas'\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"\n",
|
2022-10-03 10:11:53 -06:00
|
|
|
"actual_resume = '/storage/models/sd-v1-4.ckpt'\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"\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",
|
2022-10-03 10:11:53 -06:00
|
|
|
"init_word = 'bananas'\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"\n",
|
2022-10-03 10:11:53 -06:00
|
|
|
"project_path = '/notebooks/textual inversion/logs/<name of folder you last trained>'\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"\n",
|
2022-10-03 10:11:53 -06:00
|
|
|
"actual_resume = '/storage/models/sd-v1-4.ckpt'\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"\n",
|
|
|
|
"# ============================================================================================================\n",
|
|
|
|
"\n",
|
|
|
|
"from datetime import datetime\n",
|
2022-10-03 10:11:53 -06:00
|
|
|
"datetime_str = datetime.now().strftime('%m-%d-%Y_%H-%M-%S')\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"\n",
|
2022-10-07 13:17:53 -06:00
|
|
|
"!rm -rf \"{source_image_directory}/.ipynb_checkpoints\"\n",
|
2022-10-01 13:41:10 -06:00
|
|
|
"!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
|
|
|
|
}
|