DreamBooth experience

I want to try DreamBooth technology (It is when you use couple of your own images to tune AI generated images) and create an image dataset on HF for Dreambooth tasks. 

DS images for NN with inteligencia artificial and Development|lower


HOW TO USE DREAMBOOTH IMAGE GENERATOR WITH OWN DATASET

1. I will use folder based builder.

2. Supported image extensions .bmp, .pcx, .gif, .grib, .h5, .hdf, .png, .tif, .tiff, .jpg, .jpeg, .mpg, .mpeg, .tga, .webp, .wmf

3. I need folder structure like this [Any_folder_name] / [test_or_train] / [label_name_here] / image_name.jpg

4. To use:

from datasets import load_dataset

dataset = load_dataset("imagefolder", data_dir="/path/to/my_dataset")

4. To load your custom dataset into HF hub.

from datasets import load_dataset

dataset = load_dataset("imagefolder", data_dir="/path/to/my_folder", split="train")

dataset.push_to_hub("your_nickname/my_dataset_name")

5. If I have images with different sizes how to preprocess dataset. // It works for me

def transforms(examples):

examples["image"] = [image.convert("RGB").resize((300,300)) for image in examples["image"]]

return examples

dataset.set_transform(transforms) 

6. DreamBooth inner resize: // It doesn't work for my images. I need a collection of images that already have the same size.

self.transforms = transforms.Compose(

            [   transforms.Resize(size),

                transforms.CenterCrop(size),

                transforms.ToTensor(),

                transforms.Normalize([0.5], [0.5]),

            ]   )

7. I cannot get a good DreamBooth result with 18 face image dataset, 500 steps training, train_batch_size=1, lr=2e-06, use_8bit_adam=True.

7.1. Train for 1000 steps // Looks better

7.2. Use epochs instead of steps. What a dumb idea to use steps. For 18 images 10-20 epoch is optimal (it is 180-360 steps) with learning rate 2e-6. // Not true. Much more epochs needed.

7.3. Try 100 epochs. // It is much better then 20 epoch.

7.4. Switch off 8bit optimizer. // Not sufficient Colab RAM in this case.

7.5. Try 200 epochs. // Overtrain. Means with high gluidance value I get noisy image

7.6. Increase dataset to 80 images.

8. How to save pipeline on the hub.

8.1. Archive files from /content folder !tar -zcvf archive-name.tar.gz coppied-folder-path-name

8.2. Then download with

from google.colab import files

files.download('archive-name.tar.gz')