Step-by-Step Guide to Fine-Tuning SDXL for the Advertising, Media and Entertainment Sector

March 20, 2024

The advertising, media, and entertainment sector is an ever-evolving landscape characterized by a growing demand for creativity, personalization, and immediate engagement. Fine-tuning SDXL (Stable Diffusion XL) for this sector is pivotal to ensure that the generated content is not only relevant and resonant with diverse audiences but also adheres to the unique compliance and brand voice standards prevalent in these industries. 

Precise calibration of SDXL can enhance content discovery, optimize ad targeting, and automate routine creative processes, thereby unlocking new levels of efficiency and innovation.

This fine-tuning process is essential to capture the nuances that drive consumer behavior, ensuring that every piece of content—be it an advertisement, a movie script, or a viral marketing campaign—resonates deeply with and contributes to a compelling user experience.

Using DreamBooth to Fine-Tune SDXL

DreamBooth is a technology developed by Google researchers that allows for the personalization of AI models, particularly for the generation of images from text descriptions. It is a method of fine-tuning AI models, like Stable Diffusion, using just a few images of a specific subject. This process involves creating a ‘personalized’ text-to-image model that can generate novel renditions of the subject in various contexts and styles.

The way DreamBooth works is by taking a small number of images of a subject and using them to fine-tune a pre-trained text-to-image model. This involves introducing a unique identifier associated with the subject within the text prompts used during the fine-tuning process. The model then learns to associate this identifier with the appearance of the subject from the provided images, allowing it to generate new images of the subject when prompted with text containing the identifier.

Launching a GPU Node on E2E Networks

E2E Networks' GPU nodes provide robust and scalable computing resources tailored for high-performance workloads, particularly in the realms of machine learning, deep learning, and data processing. These nodes are equipped with powerful NVIDIA GPUs like A100s, V100s and H100s, renowned for their ability to accelerate computational tasks by parallelizing processes, thereby significantly reducing the time required for data-intensive operations.

Head over to the myaccounts section of the platform to sign up for a GPU node.

Key Features of This Blog

In this blog post, we will guide you through a detailed, step-by-step process to fine-tune SDXL with the innovative DreamBooth technique. Our objective is to create two specialized LoRA adapters: the first one dedicated to an e-commerce product, which will be instrumental in generating bespoke advertising images, and the second one focused on a male model, intended for crafting versatile images suitable for media and entertainment photoshoots.

By the end of this tutorial, you will be equipped with the know-how to leverage the capabilities of SDXL, fine-tuned with DreamBooth, to produce high-quality, tailored imagery for these specific use cases. Whether you're looking to enhance your advertising visuals or enrich your portfolio of entertainment photography, this step-by-step guide will provide you with the tools and insights needed to achieve your creative goals. Let's get started on this journey to unlock the full potential of AI-enhanced image creation.

Make sure you have the AutoTrain module installed on your system to be able to use DreamBooth.


%pip install -U autotrain-advanced

Use Case 1: Loading and Generating General Purpose Images Using SDXL



from diffusers import DiffusionPipeline, AutoencoderKL
import torch

vae = AutoencoderKL.from_pretrained(
    "madebyollin/sdxl-vae-fp16-fix",
    torch_dtype=torch.float16
)
pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    vae=vae,
    torch_dtype=torch.float16,
    variant="fp16",
    use_safetensors=True,
)
pipe.to("cuda")

 After loading the base model and the encoder, we create a pipeline for inferencing.
prompt = "A roman gladiator fighting in an arena."

image = pipe(prompt=prompt, num_inference_steps=25, num_images_per_prompt = 4)

Create a helper function to display the images in your Jupyter notebook environment:


from PIL import Image

def image_grid(imgs, rows, cols, resize=256):
    assert len(imgs) == rows * cols

    if resize is not None:
        imgs = [img.resize((resize, resize)) for img in imgs]

    w, h = imgs[0].size
    grid_w, grid_h = cols * w, rows * h
    grid = Image.new("RGB", size=(grid_w, grid_h))

    for i, img in enumerate(imgs):
        x = i % cols * w
        y = i // cols * h
        grid.paste(img, box=(x, y))

    return grid


image_grid(image.images, 2, 2)


Use Case 2: Fine-Tuning on Handbag Images

We are going to create a fine-tuned LoRA adapter for the 4 images of the handbag shown below:

You can load the above images in your Jupyter notebook using this command:


import glob
imgs = [Image.open(path) for path in glob.glob("handbag/*.jpg")]

Training a LoRA adapter for our handbag images:



!autotrain dreambooth \
--model 'stabilityai/stable-diffusion-xl-base-1.0' \
--project-name 'Dreambooth-SDXL-handbag' \
--image-path '/home/vardhanam/sdxl_fine_tune/handbag' \
--prompt "A photo of brown_handbag_1234" \
--resolution 1024 \
--batch-size 1 \
--num-steps 500 \
--gradient-accumulation 4 \
--lr 1e-4 \
--fp16 \
--push-to-hub \
--token 'YOUR_HF_TOKEN' \
--repo-id 'vardhanam/handbag_sdxl_lora'

Note that we are calling our handbag brown_handbag_1234 as it is a unique keyword that will be used by the fine-tuned model to identify and generate images of our bag.


> INFO    Namespace(version=False, revision=None, tokenizer=None, image_path='/home/vardhanam/sdxl_fine_tune/handbag', class_image_path=None, prompt='A photo of brown_handbag_1234', class_prompt=None, num_class_images=100, class_labels_conditioning=None, prior_preservation=None, prior_loss_weight=1.0, resolution=1024, center_crop=None, train_text_encoder=None, sample_batch_size=4, num_steps=500, checkpointing_steps=100000, resume_from_checkpoint=None, scale_lr=None, scheduler='constant', warmup_steps=0, num_cycles=1, lr_power=1.0, dataloader_num_workers=0, use_8bit_adam=None, adam_beta1=0.9, adam_beta2=0.999, adam_weight_decay=0.01, adam_epsilon=1e-08, max_grad_norm=1.0, allow_tf32=None, prior_generation_precision=None, local_rank=-1, xformers=None, pre_compute_text_embeddings=None, tokenizer_max_length=None, text_encoder_use_attention_mask=None, rank=4, xl=None, fp16=True, bf16=None, validation_prompt=None, num_validation_images=4, validation_epochs=50, checkpoints_total_limit=None, validation_images=None, logging=None, train=None, deploy=None, inference=None, username=None, backend='local-cli', token='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', repo_id='vardhanam/handbag_sdxl_lora', push_to_hub=True, model='stabilityai/stable-diffusion-xl-base-1.0', project_name='Dreambooth-SDXL-handbag', seed=42, epochs=1, gradient_accumulation=4, disable_gradient_checkpointing=None, lr=0.0001, log='none', data_path=None, train_split='train', valid_split=None, batch_size=1, func=)
> INFO    Running DreamBooth Training
> WARNING Parameters supplied but not used: train_split, deploy, version, valid_split, data_path, train, inference, backend, func, log
> INFO    Dataset: Dreambooth-SDXL-handbag (dreambooth)

> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/handbag/2.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/handbag/3.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/handbag/1.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/handbag/4.jpg
> INFO    Starting local training...
> INFO    {"model":"stabilityai/stable-diffusion-xl-base-1.0","revision":null,"tokenizer":null,"image_path":"Dreambooth-SDXL-handbag/autotrain-data","class_image_path":null,"prompt":"A photo of brown_handbag_1234","class_prompt":null,"num_class_images":100,"class_labels_conditioning":null,"prior_preservation":false,"prior_loss_weight":1.0,"project_name":"Dreambooth-SDXL-handbag","seed":42,"resolution":1024,"center_crop":false,"train_text_encoder":false,"batch_size":1,"sample_batch_size":4,"epochs":1,"num_steps":500,"checkpointing_steps":100000,"resume_from_checkpoint":null,"gradient_accumulation":4,"disable_gradient_checkpointing":false,"lr":0.0001,"scale_lr":false,"scheduler":"constant","warmup_steps":0,"num_cycles":1,"lr_power":1.0,"dataloader_num_workers":0,"use_8bit_adam":false,"adam_beta1":0.9,"adam_beta2":0.999,"adam_weight_decay":0.01,"adam_epsilon":1e-8,"max_grad_norm":1.0,"allow_tf32":false,"prior_generation_precision":null,"local_rank":-1,"xformers":false,"pre_compute_text_embeddings":false,"tokenizer_max_length":null,"text_encoder_use_attention_mask":false,"rank":4,"xl":true,"fp16":true,"bf16":false,"token":"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","repo_id":"vardhanam/handbag_sdxl_lora","push_to_hub":true,"username":null,"validation_prompt":null,"num_validation_images":4,"validation_epochs":50,"checkpoints_total_limit":null,"validation_images":null,"logging":false}
> INFO    ['python', '-m', 'autotrain.trainers.dreambooth', '--training_config', 'Dreambooth-SDXL-handbag/training_params.json']
WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.1.0+cu121 with CUDA 1201 (you have 2.2.1+cu121)
    Python  3.10.13 (you have 3.10.0)
...
🚀 INFO  | 2024-02-23 13:21:40 | autotrain.trainers.dreambooth.trainer:__init__:132 -  Training config = {'model': 'stabilityai/stable-diffusion-xl-base-1.0', 'revision': None, 'tokenizer': None, 'image_path': 'Dreambooth-SDXL-handbag/autotrain-data/concept1', 'class_image_path': None, 'prompt': 'A photo of brown_handbag_1234', 'class_prompt': None, 'num_class_images': 100, 'class_labels_conditioning': None, 'prior_preservation': False, 'prior_loss_weight': 1.0, 'project_name': 'Dreambooth-SDXL-handbag', 'seed': 42, 'resolution': 1024, 'center_crop': False, 'train_text_encoder': False, 'batch_size': 1, 'sample_batch_size': 4, 'epochs': 500, 'num_steps': 500, 'checkpointing_steps': 100000, 'resume_from_checkpoint': None, 'gradient_accumulation': 4, 'disable_gradient_checkpointing': False, 'lr': 0.0001, 'scale_lr': False, 'scheduler': 'constant', 'warmup_steps': 0, 'num_cycles': 1, 'lr_power': 1.0, 'dataloader_num_workers': 0, 'use_8bit_adam': False, 'adam_beta1': 0.9, 'adam_beta2': 0.999, 'adam_weight_decay': 0.01, 'adam_epsilon': 1e-08, 'max_grad_norm': 1.0, 'allow_tf32': False, 'prior_generation_precision': None, 'local_rank': -1, 'xformers': False, 'pre_compute_text_embeddings': False, 'tokenizer_max_length': None, 'text_encoder_use_attention_mask': False, 'rank': 4, 'xl': True, 'fp16': True, 'bf16': False, 'token': '*****', 'repo_id': 'vardhanam/handbag_sdxl_lora', 'push_to_hub': True, 'username': None, 'validation_prompt': None, 'num_validation_images': 4, 'validation_epochs': 50, 'checkpoints_total_limit': None, 'validation_images': None, 'logging': False}
Steps: 100%|█████████| 500/500 [50:28<00:00,  6.14s/it, loss=0.00574, lr=0.0001]Model weights saved in Dreambooth-SDXL-handbag/pytorch_lora_weights.safetensors
Steps: 100%|█████████| 500/500 [50:28<00:00,  6.06s/it, loss=0.00574, lr=0.0001]
pytorch_lora_weights.safetensors: 100%|████| 23.4M/23.4M [00:03<00:00, 6.97MB/s]


With the training complete, we can now use our fine-tuned adapters to begin inferencing.

First, load the base model and create an image generation pipeline:


from diffusers import DiffusionPipeline, AutoencoderKL
import torch

vae = AutoencoderKL.from_pretrained(
    "madebyollin/sdxl-vae-fp16-fix",
    torch_dtype=torch.float16
)
pipe_handbag = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    vae=vae,
    torch_dtype=torch.float16,
    variant="fp16",
    use_safetensors=True,
)
pipe_handbag.to("cuda");

Load the LoRA weights.


pipe_handbag.load_lora_weights('/home/vardhanam/sdxl_fine_tune/Dreambooth-SDXL-handbag/pytorch_lora_weights.safetensors')

Example 1


prompt = "a female model holding brown_handbag_1234 in her hands on a beach"
image = pipe_handbag(prompt=prompt, num_inference_steps=25, num_images_per_prompt = 4)


image_grid(image.images, 2, 2)


Example 2


prompt = "wide shot of brown_handbag_1234 displayed inside a glass container in a big shopping mall"


image = pipe_handbag(prompt=prompt, num_inference_steps=25, num_images_per_prompt = 4)
image_grid(image.images, 2, 2)

Example 3


prompt = "brown_handbag_1234 placed on a table inside the living room of a house with furniture"


image = pipe_handbag(prompt=prompt, num_inference_steps=25, num_images_per_prompt = 4)
image_grid(image.images, 2, 2)


Use Case 3: Fine-Tuning on a Male Model Images



import glob
imgs = [Image.open(path) for path in glob.glob("Male_Model/*.jpg")]


image_grid(imgs, 2, 3)

These are the input images for fine-tuning SDXL.

Command to train.


!autotrain dreambooth \
--model 'stabilityai/stable-diffusion-xl-base-1.0' \
--project-name 'Dreambooth-SDXL-Male-Model' \
--image-path '/home/vardhanam/sdxl_fine_tune/Male_Model' \
--prompt "A photo of male_model_xyz" \
--resolution 1024 \
--batch-size 1 \
--num-steps 500 \
--gradient-accumulation 4 \
--lr 1e-4 \
--fp16 \
--push-to-hub \
--token ''YOUR_HF_TOKEN' \
--repo-id 'vardhanam/male_model_xyz_sdxl_lora'


> INFO    Namespace(version=False, revision=None, tokenizer=None, image_path='/home/vardhanam/sdxl_fine_tune/Male_Model', class_image_path=None, prompt='A photo of male_model_xyz', class_prompt=None, num_class_images=100, class_labels_conditioning=None, prior_preservation=None, prior_loss_weight=1.0, resolution=1024, center_crop=None, train_text_encoder=None, sample_batch_size=4, num_steps=500, checkpointing_steps=100000, resume_from_checkpoint=None, scale_lr=None, scheduler='constant', warmup_steps=0, num_cycles=1, lr_power=1.0, dataloader_num_workers=0, use_8bit_adam=None, adam_beta1=0.9, adam_beta2=0.999, adam_weight_decay=0.01, adam_epsilon=1e-08, max_grad_norm=1.0, allow_tf32=None, prior_generation_precision=None, local_rank=-1, xformers=None, pre_compute_text_embeddings=None, tokenizer_max_length=None, text_encoder_use_attention_mask=None, rank=4, xl=None, fp16=True, bf16=None, validation_prompt=None, num_validation_images=4, validation_epochs=50, checkpoints_total_limit=None, validation_images=None, logging=None, train=None, deploy=None, inference=None, username=None, backend='local-cli', token='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', repo_id='vardhanam/male_model_xyz_sdxl_lora', push_to_hub=True, model='stabilityai/stable-diffusion-xl-base-1.0', project_name='Dreambooth-SDXL-Male-Model', seed=42, epochs=1, gradient_accumulation=4, disable_gradient_checkpointing=None, lr=0.0001, log='none', data_path=None, train_split='train', valid_split=None, batch_size=1, func=)
> INFO    Running DreamBooth Training
> WARNING Parameters supplied but not used: train, inference, deploy, data_path, backend, log, train_split, valid_split, func, version
> INFO    Dataset: Dreambooth-SDXL-Male-Model (dreambooth)

> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/Male_Model/man-8017574.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/Male_Model/man-8017568.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/Male_Model/man-8017576.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/Male_Model/man-8017562.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/Male_Model/man-8017641.jpg
> INFO    Saving concept images
> INFO    /home/vardhanam/sdxl_fine_tune/Male_Model/man-8017599.jpg
> INFO    Starting local training...
> INFO    {"model":"stabilityai/stable-diffusion-xl-base-1.0","revision":null,"tokenizer":null,"image_path":"Dreambooth-SDXL-Male-Model/autotrain-data","class_image_path":null,"prompt":"A photo of male_model_xyz","class_prompt":null,"num_class_images":100,"class_labels_conditioning":null,"prior_preservation":false,"prior_loss_weight":1.0,"project_name":"Dreambooth-SDXL-Male-Model","seed":42,"resolution":1024,"center_crop":false,"train_text_encoder":false,"batch_size":1,"sample_batch_size":4,"epochs":1,"num_steps":500,"checkpointing_steps":100000,"resume_from_checkpoint":null,"gradient_accumulation":4,"disable_gradient_checkpointing":false,"lr":0.0001,"scale_lr":false,"scheduler":"constant","warmup_steps":0,"num_cycles":1,"lr_power":1.0,"dataloader_num_workers":0,"use_8bit_adam":false,"adam_beta1":0.9,"adam_beta2":0.999,"adam_weight_decay":0.01,"adam_epsilon":1e-8,"max_grad_norm":1.0,"allow_tf32":false,"prior_generation_precision":null,"local_rank":-1,"xformers":false,"pre_compute_text_embeddings":false,"tokenizer_max_length":null,"text_encoder_use_attention_mask":false,"rank":4,"xl":true,"fp16":true,"bf16":false,"token":"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","repo_id":"vardhanam/male_model_xyz_sdxl_lora","push_to_hub":true,"username":null,"validation_prompt":null,"num_validation_images":4,"validation_epochs":50,"checkpoints_total_limit":null,"validation_images":null,"logging":false}
> INFO    ['python', '-m', 'autotrain.trainers.dreambooth', '--training_config', 'Dreambooth-SDXL-Male-Model/training_params.json']
You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
{'attention_type', 'dropout'} was not found in config. Values will be initialized to default values.
{'dynamic_thresholding_ratio', 'variance_type', 'thresholding', 'clip_sample_range'} was not found in config. Values will be initialized to default values.
🚀 INFO  | 2024-02-23 15:02:51 | autotrain.trainers.dreambooth.utils:enable_gradient_checkpointing:298 - Enabling gradient checkpointing.
🚀 INFO  | 2024-02-23 15:02:51 | autotrain.trainers.dreambooth.trainer:compute_text_embeddings:140 - Computing text embeddings for prompt: A photo of male_model_xyz
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:124 - ***** Running training *****
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:125 -  Num examples = 12
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:126 -  Num batches each epoch = 12
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:127 -  Num Epochs = 167
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:128 -  Instantaneous batch size per device = 1
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:129 -  Total train batch size (w. parallel, distributed & accumulation) = 4
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:130 -  Gradient Accumulation steps = 4
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:131 -  Total optimization steps = 500
🚀 INFO  | 2024-02-23 15:02:52 | autotrain.trainers.dreambooth.trainer:__init__:132 -  Training config = {'model': 'stabilityai/stable-diffusion-xl-base-1.0', 'revision': None, 'tokenizer': None, 'image_path': 'Dreambooth-SDXL-Male-Model/autotrain-data/concept1', 'class_image_path': None, 'prompt': 'A photo of male_model_xyz', 'class_prompt': None, 'num_class_images': 100, 'class_labels_conditioning': None, 'prior_preservation': False, 'prior_loss_weight': 1.0, 'project_name': 'Dreambooth-SDXL-Male-Model', 'seed': 42, 'resolution': 1024, 'center_crop': False, 'train_text_encoder': False, 'batch_size': 1, 'sample_batch_size': 4, 'epochs': 167, 'num_steps': 500, 'checkpointing_steps': 100000, 'resume_from_checkpoint': None, 'gradient_accumulation': 4, 'disable_gradient_checkpointing': False, 'lr': 0.0001, 'scale_lr': False, 'scheduler': 'constant', 'warmup_steps': 0, 'num_cycles': 1, 'lr_power': 1.0, 'dataloader_num_workers': 0, 'use_8bit_adam': False, 'adam_beta1': 0.9, 'adam_beta2': 0.999, 'adam_weight_decay': 0.01, 'adam_epsilon': 1e-08, 'max_grad_norm': 1.0, 'allow_tf32': False, 'prior_generation_precision': None, 'local_rank': -1, 'xformers': False, 'pre_compute_text_embeddings': False, 'tokenizer_max_length': None, 'text_encoder_use_attention_mask': False, 'rank': 4, 'xl': True, 'fp16': True, 'bf16': False, 'token': '*****', 'repo_id': 'vardhanam/male_model_xyz_sdxl_lora', 'push_to_hub': True, 'username': None, 'validation_prompt': None, 'num_validation_images': 4, 'validation_epochs': 50, 'checkpoints_total_limit': None, 'validation_images': None, 'logging': False}
Steps: 100%|█████████| 500/500 [58:04<00:00,  6.85s/it, loss=0.00341, lr=0.0001]Model weights saved in Dreambooth-SDXL-Male-Model/pytorch_lora_weights.safetensors
Steps: 100%|█████████| 500/500 [58:04<00:00,  6.97s/it, loss=0.00341, lr=0.0001]
pytorch_lora_weights.safetensors: 100%|████| 23.4M/23.4M [00:05<00:00, 4.16MB/s]


Let’s create a pipeline like before for inferencing.


from diffusers import DiffusionPipeline, AutoencoderKL
import torch

vae = AutoencoderKL.from_pretrained(
    "madebyollin/sdxl-vae-fp16-fix",
    torch_dtype=torch.float16
)
pipe_male_model = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    vae=vae,
    torch_dtype=torch.float16,
    variant="fp16",
    use_safetensors=True,
)
pipe_male_model.to("cuda");

pipe_male_model.load_lora_weights('/home/vardhanam/sdxl_fine_tune/Dreambooth-SDXL-Male-Model/pytorch_lora_weights.safetensors')

Example 1


prompt = "Photo of male_model_xyz in a newsconference with lots of microphones and other technical equipment"


image = pipe_male_model(prompt=prompt, num_inference_steps=25, num_images_per_prompt = 4)
image_grid(image.images, 2, 2)

Example 2


prompt = "Photo of male_model_xyz wearing sunglasses and posing in a garden"


image = pipe_male_model(prompt=prompt, num_inference_steps=25, num_images_per_prompt = 4)
image_grid(image.images, 2, 2)

Example 3


prompt = "Photo of male_model_xyz playing football in sporting clothes"


image = pipe_male_model(prompt=prompt, num_inference_steps=25, num_images_per_prompt = 4)
image_grid(image.images, 2, 2)

Conclusion

Through this comprehensive tutorial, we have successfully demonstrated how to leverage DreamBooth and LoRA adapters to fine-tune the powerful SDXL model for tailored applications in advertising and entertainment media. By training specialized adapters on specific products and human subject images, we unlocked SDXL's ability to generate high-quality, bespoke visual content aligned with our prompts. The fine-tuned models reliably produced novel, creative images matching the target domain, while retaining SDXL's core artistic capabilities. With the right tuning, AI imaging models like SDXL can become versatile tools for enhancing ideation, personalization, and efficiency across the dynamic advertising and media landscape. This tutorial provides the blueprint for unlocking that potential.

Code

The complete code for this article can be accessed here: https://github.com/vardhanam/SDXL_finetune/tree/main

Latest Blogs
This is a decorative image for: A Complete Guide To Customer Acquisition For Startups
October 18, 2022

A Complete Guide To Customer Acquisition For Startups

Any business is enlivened by its customers. Therefore, a strategy to constantly bring in new clients is an ongoing requirement. In this regard, having a proper customer acquisition strategy can be of great importance.

So, if you are just starting your business, or planning to expand it, read on to learn more about this concept.

The problem with customer acquisition

As an organization, when working in a diverse and competitive market like India, you need to have a well-defined customer acquisition strategy to attain success. However, this is where most startups struggle. Now, you may have a great product or service, but if you are not in the right place targeting the right demographic, you are not likely to get the results you want.

To resolve this, typically, companies invest, but if that is not channelized properly, it will be futile.

So, the best way out of this dilemma is to have a clear customer acquisition strategy in place.

How can you create the ideal customer acquisition strategy for your business?

  • Define what your goals are

You need to define your goals so that you can meet the revenue expectations you have for the current fiscal year. You need to find a value for the metrics –

  • MRR – Monthly recurring revenue, which tells you all the income that can be generated from all your income channels.
  • CLV – Customer lifetime value tells you how much a customer is willing to spend on your business during your mutual relationship duration.  
  • CAC – Customer acquisition costs, which tells how much your organization needs to spend to acquire customers constantly.
  • Churn rate – It tells you the rate at which customers stop doing business.

All these metrics tell you how well you will be able to grow your business and revenue.

  • Identify your ideal customers

You need to understand who your current customers are and who your target customers are. Once you are aware of your customer base, you can focus your energies in that direction and get the maximum sale of your products or services. You can also understand what your customers require through various analytics and markers and address them to leverage your products/services towards them.

  • Choose your channels for customer acquisition

How will you acquire customers who will eventually tell at what scale and at what rate you need to expand your business? You could market and sell your products on social media channels like Instagram, Facebook and YouTube, or invest in paid marketing like Google Ads. You need to develop a unique strategy for each of these channels. 

  • Communicate with your customers

If you know exactly what your customers have in mind, then you will be able to develop your customer strategy with a clear perspective in mind. You can do it through surveys or customer opinion forms, email contact forms, blog posts and social media posts. After that, you just need to measure the analytics, clearly understand the insights, and improve your strategy accordingly.

Combining these strategies with your long-term business plan will bring results. However, there will be challenges on the way, where you need to adapt as per the requirements to make the most of it. At the same time, introducing new technologies like AI and ML can also solve such issues easily. To learn more about the use of AI and ML and how they are transforming businesses, keep referring to the blog section of E2E Networks.

Reference Links

https://www.helpscout.com/customer-acquisition/

https://www.cloudways.com/blog/customer-acquisition-strategy-for-startups/

https://blog.hubspot.com/service/customer-acquisition

This is a decorative image for: Constructing 3D objects through Deep Learning
October 18, 2022

Image-based 3D Object Reconstruction State-of-the-Art and trends in the Deep Learning Era

3D reconstruction is one of the most complex issues of deep learning systems. There have been multiple types of research in this field, and almost everything has been tried on it — computer vision, computer graphics and machine learning, but to no avail. However, that has resulted in CNN or convolutional neural networks foraying into this field, which has yielded some success.

The Main Objective of the 3D Object Reconstruction

Developing this deep learning technology aims to infer the shape of 3D objects from 2D images. So, to conduct the experiment, you need the following:

  • Highly calibrated cameras that take a photograph of the image from various angles.
  • Large training datasets can predict the geometry of the object whose 3D image reconstruction needs to be done. These datasets can be collected from a database of images, or they can be collected and sampled from a video.

By using the apparatus and datasets, you will be able to proceed with the 3D reconstruction from 2D datasets.

State-of-the-art Technology Used by the Datasets for the Reconstruction of 3D Objects

The technology used for this purpose needs to stick to the following parameters:

  • Input

Training with the help of one or multiple RGB images, where the segmentation of the 3D ground truth needs to be done. It could be one image, multiple images or even a video stream.

The testing will also be done on the same parameters, which will also help to create a uniform, cluttered background, or both.

  • Output

The volumetric output will be done in both high and low resolution, and the surface output will be generated through parameterisation, template deformation and point cloud. Moreover, the direct and intermediate outputs will be calculated this way.

  • Network architecture used

The architecture used in training is 3D-VAE-GAN, which has an encoder and a decoder, with TL-Net and conditional GAN. At the same time, the testing architecture is 3D-VAE, which has an encoder and a decoder.

  • Training used

The degree of supervision used in 2D vs 3D supervision, weak supervision along with loss functions have to be included in this system. The training procedure is adversarial training with joint 2D and 3D embeddings. Also, the network architecture is extremely important for the speed and processing quality of the output images.

  • Practical applications and use cases

Volumetric representations and surface representations can do the reconstruction. Powerful computer systems need to be used for reconstruction.

Given below are some of the places where 3D Object Reconstruction Deep Learning Systems are used:

  • 3D reconstruction technology can be used in the Police Department for drawing the faces of criminals whose images have been procured from a crime site where their faces are not completely revealed.
  • It can be used for re-modelling ruins at ancient architectural sites. The rubble or the debris stubs of structures can be used to recreate the entire building structure and get an idea of how it looked in the past.
  • They can be used in plastic surgery where the organs, face, limbs or any other portion of the body has been damaged and needs to be rebuilt.
  • It can be used in airport security, where concealed shapes can be used for guessing whether a person is armed or is carrying explosives or not.
  • It can also help in completing DNA sequences.

So, if you are planning to implement this technology, then you can rent the required infrastructure from E2E Networks and avoid investing in it. And if you plan to learn more about such topics, then keep a tab on the blog section of the website

Reference Links

https://tongtianta.site/paper/68922

https://github.com/natowi/3D-Reconstruction-with-Deep-Learning-Methods

This is a decorative image for: Comprehensive Guide to Deep Q-Learning for Data Science Enthusiasts
October 18, 2022

A Comprehensive Guide To Deep Q-Learning For Data Science Enthusiasts

For all data science enthusiasts who would love to dig deep, we have composed a write-up about Q-Learning specifically for you all. Deep Q-Learning and Reinforcement learning (RL) are extremely popular these days. These two data science methodologies use Python libraries like TensorFlow 2 and openAI’s Gym environment.

So, read on to know more.

What is Deep Q-Learning?

Deep Q-Learning utilizes the principles of Q-learning, but instead of using the Q-table, it uses the neural network. The algorithm of deep Q-Learning uses the states as input and the optimal Q-value of every action possible as the output. The agent gathers and stores all the previous experiences in the memory of the trained tuple in the following order:

State> Next state> Action> Reward

The neural network training stability increases using a random batch of previous data by using the experience replay. Experience replay also means the previous experiences stocking, and the target network uses it for training and calculation of the Q-network and the predicted Q-Value. This neural network uses openAI Gym, which is provided by taxi-v3 environments.

Now, any understanding of Deep Q-Learning   is incomplete without talking about Reinforcement Learning.

What is Reinforcement Learning?

Reinforcement is a subsection of ML. This part of ML is related to the action in which an environmental agent participates in a reward-based system and uses Reinforcement Learning to maximize the rewards. Reinforcement Learning is a different technique from unsupervised learning or supervised learning because it does not require a supervised input/output pair. The number of corrections is also less, so it is a highly efficient technique.

Now, the understanding of reinforcement learning is incomplete without knowing about Markov Decision Process (MDP). MDP is involved with each state that has been presented in the results of the environment, derived from the state previously there. The information which composes both states is gathered and transferred to the decision process. The task of the chosen agent is to maximize the awards. The MDP optimizes the actions and helps construct the optimal policy.

For developing the MDP, you need to follow the Q-Learning Algorithm, which is an extremely important part of data science and machine learning.

What is Q-Learning Algorithm?

The process of Q-Learning is important for understanding the data from scratch. It involves defining the parameters, choosing the actions from the current state and also choosing the actions from the previous state and then developing a Q-table for maximizing the results or output rewards.

The 4 steps that are involved in Q-Learning:

  1. Initializing parameters – The RL (reinforcement learning) model learns the set of actions that the agent requires in the state, environment and time.
  2. Identifying current state – The model stores the prior records for optimal action definition for maximizing the results. For acting in the present state, the state needs to be identified and perform an action combination for it.
  3. Choosing the optimal action set and gaining the relevant experience – A Q-table is generated from the data with a set of specific states and actions, and the weight of this data is calculated for updating the Q-Table to the following step.
  4. Updating Q-table rewards and next state determination – After the relevant experience is gained and agents start getting environmental records. The reward amplitude helps to present the subsequent step.  

In case the Q-table size is huge, then the generation of the model is a time-consuming process. This situation requires Deep Q-learning.

Hopefully, this write-up has provided an outline of Deep Q-Learning and its related concepts. If you wish to learn more about such topics, then keep a tab on the blog section of the E2E Networks website.

Reference Links

https://analyticsindiamag.com/comprehensive-guide-to-deep-q-learning-for-data-science-enthusiasts/

https://medium.com/@jereminuerofficial/a-comprehensive-guide-to-deep-q-learning-8aeed632f52f

This is a decorative image for: GAUDI: A Neural Architect for Immersive 3D Scene Generation
October 13, 2022

GAUDI: A Neural Architect for Immersive 3D Scene Generation

The evolution of artificial intelligence in the past decade has been staggering, and now the focus is shifting towards AI and ML systems to understand and generate 3D spaces. As a result, there has been extensive research on manipulating 3D generative models. In this regard, Apple’s AI and ML scientists have developed GAUDI, a method specifically for this job.

An introduction to GAUDI

The GAUDI 3D immersive technique founders named it after the famous architect Antoni Gaudi. This AI model takes the help of a camera pose decoder, which enables it to guess the possible camera angles of a scene. Hence, the decoder then makes it possible to predict the 3D canvas from almost every angle.

What does GAUDI do?

GAUDI can perform multiple functions –

  • The extensions of these generative models have a tremendous effect on ML and computer vision. Pragmatically, such models are highly useful. They are applied in model-based reinforcement learning and planning world models, SLAM is s, or 3D content creation.
  • Generative modelling for 3D objects has been used for generating scenes using graf, pigan, and gsn, which incorporate a GAN (Generative Adversarial Network). The generator codes radiance fields exclusively. Using the 3D space in the scene along with the camera pose generates the 3D image from that point. This point has a density scalar and RGB value for that specific point in 3D space. This can be done from a 2D camera view. It does this by imposing 3D datasets on those 2D shots. It isolates various objects and scenes and combines them to render a new scene altogether.
  • GAUDI also removes GANs pathologies like mode collapse and improved GAN.
  • GAUDI also uses this to train data on a canonical coordinate system. You can compare it by looking at the trajectory of the scenes.

How is GAUDI applied to the content?

The steps of application for GAUDI have been given below:

  • Each trajectory is created, which consists of a sequence of posed images (These images are from a 3D scene) encoded into a latent representation. This representation which has a radiance field or what we refer to as the 3D scene and the camera path is created in a disentangled way. The results are interpreted as free parameters. The problem is optimized by and formulation of a reconstruction objective.
  • This simple training process is then scaled to trajectories, thousands of them creating a large number of views. The model samples the radiance fields totally from the previous distribution that the model has learned.
  • The scenes are thus synthesized by interpolation within the hidden space.
  • The scaling of 3D scenes generates many scenes that contain thousands of images. During training, there is no issue related to canonical orientation or mode collapse.
  • A novel de-noising optimization technique is used to find hidden representations that collaborate in modelling the camera poses and the radiance field to create multiple datasets with state-of-the-art performance in generating 3D scenes by building a setup that uses images and text.

To conclude, GAUDI has more capabilities and can also be used for sampling various images and video datasets. Furthermore, this will make a foray into AR (augmented reality) and VR (virtual reality). With GAUDI in hand, the sky is only the limit in the field of media creation. So, if you enjoy reading about the latest development in the field of AI and ML, then keep a tab on the blog section of the E2E Networks website.

Reference Links

https://www.researchgate.net/publication/362323995_GAUDI_A_Neural_Architect_for_Immersive_3D_Scene_Generation

https://www.technology.org/2022/07/31/gaudi-a-neural-architect-for-immersive-3d-scene-generation/ 

https://www.patentlyapple.com/2022/08/apple-has-unveiled-gaudi-a-neural-architect-for-immersive-3d-scene-generation.html

Build on the most powerful infrastructure cloud

A vector illustration of a tech city using latest cloud technologies & infrastructure