From 722fd01fcfdba1d1ab9bf3505c1753f16d8467ae Mon Sep 17 00:00:00 2001 From: JoePenna <100188076+JoePenna@users.noreply.github.com> Date: Wed, 28 Sep 2022 07:12:33 -0700 Subject: [PATCH 1/3] Update dreambooth_runpod_joepenna.ipynb batch_size >> max_steps --- dreambooth_runpod_joepenna.ipynb | 121 +++++++++++++++++++------------ 1 file changed, 76 insertions(+), 45 deletions(-) diff --git a/dreambooth_runpod_joepenna.ipynb b/dreambooth_runpod_joepenna.ipynb index 6bfcf22..eccadea 100644 --- a/dreambooth_runpod_joepenna.ipynb +++ b/dreambooth_runpod_joepenna.ipynb @@ -9,9 +9,17 @@ "source": [ "# Dreambooth\n", "### Notebook implementation by Joe Penna (@MysteryGuitarM on Twitter) - Improvements by David Bielejeski\n", - "https://github.com/JoePenna/Dreambooth-Stable-Diffusion\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", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "## Download the 1.4 sd model\n", @@ -96,23 +107,20 @@ " filename=\"sd-v1-4.ckpt\",\n", " use_auth_token=True\n", ")" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "## 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", "!mv {actual_locations_of_model_blob[-1]} model.ckpt" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "markdown", @@ -147,12 +155,12 @@ }, "outputs": [], "source": [ - "# GENERATE 400 images\n", + "# GENERATE 200 images\n", "!python scripts/stable_txt2img.py \\\n", " --seed 10 \\\n", " --ddim_eta 0.0 \\\n", " --n_samples 1 \\\n", - " --n_iter 400 \\\n", + " --n_iter 200 \\\n", " --scale 10.0 \\\n", " --ddim_steps 50 \\\n", " --ckpt model.ckpt \\\n", @@ -233,31 +241,39 @@ "\n", "* 2-3 full 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", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "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", " \"https://i.imgur.com/test1.png\",\n", " \"https://i.imgur.com/test2.png\",\n", " \"https://i.imgur.com/test3.png\",\n", " \"https://i.imgur.com/test4.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", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "#@title Download and check the images you have just added\n", @@ -291,10 +307,7 @@ " os.mkdir(save_path)\n", "[image.save(f\"{save_path}/{i}.png\", format=\"png\") for i, image in enumerate(images)]\n", "image_grid(images, 1, len(images))" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "markdown", @@ -312,6 +325,9 @@ }, { "cell_type": "markdown", + "metadata": { + "collapsed": false + }, "source": [ "## Edit the personalized.py file\n", "Execute this cell `%load ldm/data/personalized.py`\n", @@ -324,28 +340,28 @@ "]\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", + "Then paste this at the very top of the cell:\n", "```\n", "%%writefile ldm/data/personalized.py\n", "```\n", "\n", "Then run the cell again. This will save your changes.\n" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "%load ldm/data/personalized.py" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", @@ -359,8 +375,13 @@ "source": [ "# START THE TRAINING\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", - "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", "\n", "!rm -rf training_samples/.ipynb_checkpoints\n", @@ -388,30 +409,33 @@ { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "directory_paths = !ls -d logs/*" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "# This version should automatically prune around 10GB from the ckpt file\n", "last_checkpoint_file = directory_paths[-1] + \"/checkpoints/last.ckpt\"\n", "!python \"prune_ckpt.py\" --ckpt {last_checkpoint_file}" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "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", "!mkdir -p trained_models\n", "!mv {last_checkpoint_file_pruned} trained_models/{file_name}" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", @@ -434,6 +455,16 @@ "# 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", "id": "d28d0139", From 67a5f3a5d2a351f3dd345c60049406f263dc592a Mon Sep 17 00:00:00 2001 From: JoePenna <100188076+JoePenna@users.noreply.github.com> Date: Wed, 28 Sep 2022 09:38:25 -0700 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 27f2b4f..8d0ebf7 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ### **INTRODUCTIONS!** 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. From 1e2a98f985e4e8ca9dfb16d1eefde9cabc1f6392 Mon Sep 17 00:00:00 2001 From: JoePenna <100188076+JoePenna@users.noreply.github.com> Date: Wed, 28 Sep 2022 10:10:04 -0700 Subject: [PATCH 3/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d0ebf7..1362372 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,6 @@ Now, if you wanna try to do this... please read the warnings below first: - Best practice is to change the token to a celebrity name. Here's my wife trained with the exact same settings, except for the token: -# Using the generated model The `ground truth` (real picture, caution: very beautiful woman)
@@ -58,6 +57,8 @@ Same prompt for all of these images below: | ----- | ------- | ----------------- | ----------- | | | | | | +# Using the generated model + ## Debugging your results Oh no!