Merge with main
This commit is contained in:
commit
c01b806054
|
@ -20,7 +20,7 @@
|
||||||
### **INTRODUCTIONS!**
|
### **INTRODUCTIONS!**
|
||||||
Hi! My name is Joe Penna.
|
Hi! My name is Joe Penna.
|
||||||
|
|
||||||
You might have seen a few YouTube of mine under *MysteryGuitarMan*. I'm now a feature filmmaker. You might have seen [ARCTIC](https://www.youtube.com/watch?v=N5aD9ppoQIo&t=6s) or [STOWAWAY](https://www.youtube.com/watch?v=A_apvQkWsVY).
|
You might have seen a few YouTube videos of mine under *MysteryGuitarMan*. I'm now a feature film director. You might have seen [ARCTIC](https://www.youtube.com/watch?v=N5aD9ppoQIo&t=6s) or [STOWAWAY](https://www.youtube.com/watch?v=A_apvQkWsVY).
|
||||||
|
|
||||||
For my movies, I need to be able to train specific actors, props, locations, etc. So, I did a bunch of changes to @XavierXiao's repo in order to train people's faces.
|
For my movies, I need to be able to train specific actors, props, locations, etc. So, I did a bunch of changes to @XavierXiao's repo in order to train people's faces.
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,17 @@
|
||||||
"source": [
|
"source": [
|
||||||
"# Dreambooth\n",
|
"# Dreambooth\n",
|
||||||
"### Notebook implementation by Joe Penna (@MysteryGuitarM on Twitter) - Improvements by David Bielejeski\n",
|
"### Notebook implementation by Joe Penna (@MysteryGuitarM on Twitter) - Improvements by David Bielejeski\n",
|
||||||
"https://github.com/JoePenna/Dreambooth-Stable-Diffusion\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"### If on runpod / vast.ai / etc, spin up an A6000 or A100 pod using a Stable Diffusion template with Jupyter pre-installed."
|
"### Instructions\n",
|
||||||
|
"- Sign up for RunPod here: https://runpod.io/?ref=n8yfwyum\n",
|
||||||
|
" - Note: That's my personal referral link. Please don't use it if we are mortal enemies.\n",
|
||||||
|
"\n",
|
||||||
|
"- Click *Deploy* on either `SECURE CLOUD` or `COMMUNITY CLOUD`\n",
|
||||||
|
"\n",
|
||||||
|
"- Follow the rest of the instructions in this video: https://www.youtube.com/watch?v=7m__xadX0z0#t=5m33.1s\n",
|
||||||
|
"\n",
|
||||||
|
"Latest information on:\n",
|
||||||
|
"https://github.com/JoePenna/Dreambooth-Stable-Diffusion"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -87,6 +95,9 @@
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"## Download the 1.4 sd model\n",
|
"## Download the 1.4 sd model\n",
|
||||||
|
@ -96,23 +107,20 @@
|
||||||
" filename=\"sd-v1-4.ckpt\",\n",
|
" filename=\"sd-v1-4.ckpt\",\n",
|
||||||
" use_auth_token=True\n",
|
" use_auth_token=True\n",
|
||||||
")"
|
")"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"## Move the sd-v1-4.ckpt to the root of this directory as \"model.ckpt\"\n",
|
"## Move the sd-v1-4.ckpt to the root of this directory as \"model.ckpt\"\n",
|
||||||
"actual_locations_of_model_blob = !readlink -f {downloaded_model_path}\n",
|
"actual_locations_of_model_blob = !readlink -f {downloaded_model_path}\n",
|
||||||
"!mv {actual_locations_of_model_blob[-1]} model.ckpt"
|
"!mv {actual_locations_of_model_blob[-1]} model.ckpt"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
@ -147,12 +155,12 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# GENERATE 400 images\n",
|
"# GENERATE 200 images\n",
|
||||||
"!python scripts/stable_txt2img.py \\\n",
|
"!python scripts/stable_txt2img.py \\\n",
|
||||||
" --seed 10 \\\n",
|
" --seed 10 \\\n",
|
||||||
" --ddim_eta 0.0 \\\n",
|
" --ddim_eta 0.0 \\\n",
|
||||||
" --n_samples 1 \\\n",
|
" --n_samples 1 \\\n",
|
||||||
" --n_iter 400 \\\n",
|
" --n_iter 200 \\\n",
|
||||||
" --scale 10.0 \\\n",
|
" --scale 10.0 \\\n",
|
||||||
" --ddim_steps 50 \\\n",
|
" --ddim_steps 50 \\\n",
|
||||||
" --ckpt model.ckpt \\\n",
|
" --ckpt model.ckpt \\\n",
|
||||||
|
@ -233,31 +241,39 @@
|
||||||
"\n",
|
"\n",
|
||||||
"* 2-3 full body\n",
|
"* 2-3 full body\n",
|
||||||
"* 3-5 upper body \n",
|
"* 3-5 upper body \n",
|
||||||
"* 5-12 close-up on face"
|
"* 5-12 close-up on face\n",
|
||||||
|
"\n",
|
||||||
|
"The images should be:\n",
|
||||||
|
"\n",
|
||||||
|
"- as close as possible to the kind of images you're trying to make (most of the time, that means no selfies).\n",
|
||||||
|
"- "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"#@markdown Add here the URLs to the images of the concept you are adding\n",
|
"#@markdown Add here the URLs to the images of the subject you are adding\n",
|
||||||
"urls = [\n",
|
"urls = [\n",
|
||||||
" \"https://i.imgur.com/test1.png\",\n",
|
" \"https://i.imgur.com/test1.png\",\n",
|
||||||
" \"https://i.imgur.com/test2.png\",\n",
|
" \"https://i.imgur.com/test2.png\",\n",
|
||||||
" \"https://i.imgur.com/test3.png\",\n",
|
" \"https://i.imgur.com/test3.png\",\n",
|
||||||
" \"https://i.imgur.com/test4.png\",\n",
|
" \"https://i.imgur.com/test4.png\",\n",
|
||||||
" \"https://i.imgur.com/test5.png\",\n",
|
" \"https://i.imgur.com/test5.png\",\n",
|
||||||
" ## You can add additional images here\n",
|
" # You can add additional images here -- about 20-30 images in different \n",
|
||||||
"]"
|
"]"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"#@title Download and check the images you have just added\n",
|
"#@title Download and check the images you have just added\n",
|
||||||
|
@ -291,10 +307,7 @@
|
||||||
" os.mkdir(save_path)\n",
|
" os.mkdir(save_path)\n",
|
||||||
"[image.save(f\"{save_path}/{i}.png\", format=\"png\") for i, image in enumerate(images)]\n",
|
"[image.save(f\"{save_path}/{i}.png\", format=\"png\") for i, image in enumerate(images)]\n",
|
||||||
"image_grid(images, 1, len(images))"
|
"image_grid(images, 1, len(images))"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
@ -312,6 +325,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Edit the personalized.py file\n",
|
"## Edit the personalized.py file\n",
|
||||||
"Execute this cell `%load ldm/data/personalized.py`\n",
|
"Execute this cell `%load ldm/data/personalized.py`\n",
|
||||||
|
@ -324,28 +340,28 @@
|
||||||
"]\n",
|
"]\n",
|
||||||
"```\n",
|
"```\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Then paste this at the very top of the cell\n",
|
"I recommend using the name of a celebrity that:\n",
|
||||||
|
"1) kinda looks like you.\n",
|
||||||
|
"2) Stable Diffusion generates well (you can check by typing their name on DreamStudio)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"Then paste this at the very top of the cell:\n",
|
||||||
"```\n",
|
"```\n",
|
||||||
"%%writefile ldm/data/personalized.py\n",
|
"%%writefile ldm/data/personalized.py\n",
|
||||||
"```\n",
|
"```\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Then run the cell again. This will save your changes.\n"
|
"Then run the cell again. This will save your changes.\n"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%load ldm/data/personalized.py"
|
"%load ldm/data/personalized.py"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
|
@ -359,8 +375,13 @@
|
||||||
"source": [
|
"source": [
|
||||||
"# START THE TRAINING\n",
|
"# START THE TRAINING\n",
|
||||||
"project_name = \"project_name\"\n",
|
"project_name = \"project_name\"\n",
|
||||||
|
"\n",
|
||||||
|
"# oops, this next variable should be called \"max_steps\".\n",
|
||||||
|
"# It's how long you want your training to go.\n",
|
||||||
|
"# If you're seeing this message, I'm literally at my computer right now fixing this up:\n",
|
||||||
"batch_size = 1000\n",
|
"batch_size = 1000\n",
|
||||||
"class_word = \"woman\" # << match this word to the class word from regularization images above\n",
|
"\n",
|
||||||
|
"class_word = \"person\" # << match this word to the class word from regularization images above\n",
|
||||||
"reg_data_root = \"/workspace/Dreambooth-Stable-Diffusion/outputs/txt2img-samples/samples/\" + dataset\n",
|
"reg_data_root = \"/workspace/Dreambooth-Stable-Diffusion/outputs/txt2img-samples/samples/\" + dataset\n",
|
||||||
"\n",
|
"\n",
|
||||||
"!rm -rf training_samples/.ipynb_checkpoints\n",
|
"!rm -rf training_samples/.ipynb_checkpoints\n",
|
||||||
|
@ -388,30 +409,33 @@
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"directory_paths = !ls -d logs/*"
|
"directory_paths = !ls -d logs/*"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# This version should automatically prune around 10GB from the ckpt file\n",
|
"# This version should automatically prune around 10GB from the ckpt file\n",
|
||||||
"last_checkpoint_file = directory_paths[-1] + \"/checkpoints/last.ckpt\"\n",
|
"last_checkpoint_file = directory_paths[-1] + \"/checkpoints/last.ckpt\"\n",
|
||||||
"!python \"prune_ckpt.py\" --ckpt {last_checkpoint_file}"
|
"!python \"prune_ckpt.py\" --ckpt {last_checkpoint_file}"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"last_checkpoint_file_pruned = directory_paths[-1] + \"/checkpoints/last-pruned.ckpt\"\n",
|
"last_checkpoint_file_pruned = directory_paths[-1] + \"/checkpoints/last-pruned.ckpt\"\n",
|
||||||
|
@ -420,10 +444,7 @@
|
||||||
"file_name = date_string[-1] + \"_\" + project_name + \"_\" + str(len(training_samples)) + \"_training_images_\" + str(batch_size) + \"_batch_size_\" + class_word + \"_class_word.ckpt\"\n",
|
"file_name = date_string[-1] + \"_\" + project_name + \"_\" + str(len(training_samples)) + \"_training_images_\" + str(batch_size) + \"_batch_size_\" + class_word + \"_class_word.ckpt\"\n",
|
||||||
"!mkdir -p trained_models\n",
|
"!mkdir -p trained_models\n",
|
||||||
"!mv {last_checkpoint_file_pruned} trained_models/{file_name}"
|
"!mv {last_checkpoint_file_pruned} trained_models/{file_name}"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"collapsed": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
|
@ -434,6 +455,16 @@
|
||||||
"# Download your trained model file from `trained_models` and use in your favorite Stable Diffusion repo!"
|
"# Download your trained model file from `trained_models` and use in your favorite Stable Diffusion repo!"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9a90ac5c",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Big Important Note!\n",
|
||||||
|
"\n",
|
||||||
|
"The way to call your token"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "d28d0139",
|
"id": "d28d0139",
|
||||||
|
|
Loading…
Reference in New Issue