পাঠ ১৯ · ২৮-এর মধ্যে · মডিউল ৩
Home / AI Courses / Generative AI / DreamBooth & LoRA

DreamBooth ও LoRA fine-tune

DreamBooth & LoRA — personalizing diffusion models
৭ মিনিট পড়া মাঝারি+ · Intermediate+ Personalization

এই পাঠে যা শিখবেন

  • Personalization problem — কেন pretrained SD-এ আপনার মুখ/style নেই
  • DreamBooth (Ruiz 2022) — full fine-tune approach, prior preservation
  • LoRA (Hu 2021) — low-rank decomposition, math ও practical use
  • Civitai ecosystem, LoRA stacking, modern alternatives (DoRA, OFT)

১ · Personalization problem

Stable Diffusion LAION-5B-এ trained — billions image। কিন্তু:

  • আপনার মুখ — training data-তে নেই।
  • আপনার pet-এর exact look।
  • বাংলাদেশের traditional rickshaw art style।
  • Brand-specific aesthetic।

Fine-tuning দরকার — কিন্তু full SD train করা impossibly expensive। DreamBooth ও LoRA সমাধান দিল।

২ · DreamBooth — Ruiz et al. 2022

Google Research ("DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation", CVPR 2023)। 3-5 image-এ subject "implant"।

Two key tricks

১) Rare token: Unique identifier ("sks", "v1k", "[V]") — rare/unused token যাতে existing concept-এর সাথে interfere না।
২) Prior preservation loss: "[V] dog"-এ overfit করে generic "dog" ভুলে যাবে — তাই simultaneously generic class images-এ regularize।

Training data:

  • 3-5 images of subject (different angles, backgrounds)।
  • Caption: "a photo of [V] dog"।
  • Class images (200-500 generic dogs from SD itself) for prior।

Loss:

$$\mathcal{L}_{DB} = \mathbb{E}\big[\|\epsilon - \epsilon_\theta(\mathbf{x}_t^{[V]}, t, \text{"a [V] dog"})\|^2\big] + \lambda\,\mathbb{E}\big[\|\epsilon - \epsilon_\theta(\mathbf{x}_t^{prior}, t, \text{"a dog"})\|^2\big]$$

$\lambda \approx 1$। প্রথম term subject এনকোড করে, দ্বিতীয় term generic class preserve।

৩ · LoRA — Hu et al. 2021

Microsoft ("LoRA: Low-Rank Adaptation of Large Language Models", ICLR 2022)। Originally for LLMs (GPT, BERT)। ২০২৩-এ SD community adopt।

Core mathematical idea: Pretrained weight $W \in \mathbb{R}^{d \times d}$ freeze। Update via:

$$W' = W + \Delta W = W + BA, \quad B \in \mathbb{R}^{d \times r}, \; A \in \mathbb{R}^{r \times d}, \; r \ll d$$

$r$ = "rank" — typically 4, 8, 16, 32। SD1.5-এ $d \approx 768$, $r=8$ → 99% fewer params।

Key advantages:

  • Parameter efficient: $2dr$ params (BA) vs $d^2$ (full fine-tune)। 100× smaller।
  • No inference overhead: Merge $W' = W + BA$ once → same speed as base।
  • Swappable: Different LoRAs apply to same base model।
  • Composable: Stack multiple LoRAs ($\sum_i \alpha_i B_i A_i$)।
  • Cheap training: Colab T4-তে 1-4 hours।

৪ · LoRA-এর initialization

Critical detail:

  • $A$ — Gaussian random small (e.g., $\mathcal{N}(0, 0.01^2)$)।
  • $B$ — zero।
  • Initial $BA = 0$ — same as ControlNet zero-conv idea। SD intact at training start।

৫ · কোথায় LoRA apply করা হয়

SD U-Net-এর সব linear layer-এ — কিন্তু সবচেয়ে effective:

  • Cross-attention $W_q, W_k, W_v, W_o$ — text-image alignment-এ মূল ভূমিকা।
  • Self-attention parameters।
  • Sometimes feed-forward layers।

Most SD LoRAs (Civitai) — only cross-attention। Smaller, often sufficient।

DreamBooth (full fine-tune) vs LoRA (low-rank adapter) DreamBooth: train all SD params SD U-Net (all weights) W ∈ ℝ^{d×d} d ≈ 1024 ~860M params trained Rare token "sks dog" + Prior preservation loss 3-5 images, 200 prior images Storage: ~3-7 GB Training: 30-60 min on A100 VRAM: 16+ GB Pros: highest fidelity Cons: large, slow, not composable LoRA: train ΔW = BA (low-rank) SD frozen + tiny adapter 🔒 W d×d frozen + B d×r · A (r×d) ~5M params trained (r=8) B init = 0 (start at no-op) 10-100 images sufficient Storage: 10-200 MB Training: 10-60 min on T4 VRAM: 6-12 GB Pros: small, composable, fast Cons: slightly less subject fidelity LoRA-stacking: SD + face_lora(α=0.7) + style_lora(β=0.5) + outfit_lora(γ=0.3) DoRA, OFT, GLoRA — modern variants improving on LoRA
DreamBooth full fine-tune (~3-7 GB)। LoRA learns small $\Delta W = BA$ (~10-200 MB) — 100× smaller, composable, swappable। Civitai-এর million+ LoRAs এই principle-এ।

৬ · LoRA training — diffusers

Python · diffusers
# Using HuggingFace train_dreambooth_lora.py
# pip install diffusers[training] accelerate

# Prepare your data
data_dir = "./my_subject/"            # 5-15 images (1024×1024)
class_dir = "./class_dog/"            # 200 generic class images

!accelerate launch examples/dreambooth/train_dreambooth_lora.py \
  --pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5" \
  --instance_data_dir=$data_dir \
  --instance_prompt="a photo of sks dog" \
  --class_data_dir=$class_dir \
  --class_prompt="a photo of dog" \
  --with_prior_preservation \
  --resolution=512 \
  --train_batch_size=1 \
  --gradient_accumulation_steps=4 \
  --learning_rate=1e-4 \
  --lr_scheduler="constant" \
  --max_train_steps=1000 \
  --rank=8 \
  --output_dir="./my_lora"

# Inference
from diffusers import StableDiffusionPipeline
import torch
pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16
).to("cuda")
pipe.load_lora_weights("./my_lora")

img = pipe("a photo of sks dog wearing a graduation cap, professional photo",
           num_inference_steps=30, guidance_scale=7.5).images[0]

    
Colab T4 (free) — ~30-45 min for LoRA training। Pro T4/A100 — ~10-20 min। Output: my_lora/pytorch_lora_weights.safetensors।

৭ · LoRA stacking

Python · LoRA stacking
pipe.load_lora_weights("face_lora.safetensors", adapter_name="face")
pipe.load_lora_weights("style_lora.safetensors", adapter_name="style")
pipe.load_lora_weights("outfit_lora.safetensors", adapter_name="outfit")

# Activate with weights
pipe.set_adapters(
    ["face", "style", "outfit"],
    adapter_weights=[0.8, 0.5, 0.3]
)

img = pipe("a portrait of  in jamdani saree, vintage Bangla film style",
           num_inference_steps=30).images[0]

    

৮ · Modern variants (২০২৪-২৫)

  • DoRA (Liu 2024): Decompose magnitude + direction। Better than LoRA at same rank।
  • OFT (Orthogonal Fine-Tuning): Preserve angular structure। Faster convergence।
  • GLoRA: Generalized LoRA — multi-component decomposition।
  • LoHA, LoKr: Hadamard product, Kronecker decomposition variants।
  • Textual Inversion (Gal 2022): Even smaller — train new token embedding। 5-50 KB।
  • InstantID, PhotoMaker: No training — face image at inference time।
LoRA quality dataset-dependent। 10-30 high-quality, varied images > 100 mediocre। Background variation, lighting variation, angle variation critical।

ভাবনার প্রশ্ন

প্রতিটি প্রশ্ন নিজে কিছুক্ষণ ভাবুন — তারপর "→ উত্তর" চাপুন।

প্র ০১ "Low-rank assumption" — কেন full rank update লাগে না? Linear algebra-এর কোন property exploit করছি এবং কোন situation-এ এটি break হয়?

LoRA-এর core hypothesis — fine-tuning-এর জন্য low intrinsic rank সাধারণত যথেষ্ট। এটি গভীর observation।

Hypothesis (Hu et al. 2021):

  • Pretrained model already knows "general world knowledge"।
  • Fine-tuning task-specific tweak — full rank space-এ পুরো নয়।
  • Empirically: $\Delta W$ effective rank low — $r \ll d$ যথেষ্ট।

Linear algebra background:

  • $W \in \mathbb{R}^{d \times d}$ full rank → $d^2$ params।
  • $BA$ where $B \in \mathbb{R}^{d \times r}, A \in \mathbb{R}^{r \times d}$ → $2dr$ params।
  • Rank $\le r$ — only $r$ "directions of change"।
  • $r=8, d=1024$ → $16K$ params vs $1M$ — 64× saving।

Why intrinsically low rank:

  • Fine-tuning task often "shift in semantic direction" not "rebuild everything"।
  • Subject like "Photo of [V]" — change few semantic features in attention।
  • Style change — uniform transformation of color/texture features।
  • Brain-like — most neurons multipurpose, few specialize।

Empirical evidence:

  • Hu et al. 2021: GPT-3 fine-tuning, $r=1$ sometimes works for simple tasks!
  • Aghajanyan et al. 2020: Pretrained models have low "intrinsic dimension"।
  • Across vision, language: $r=4$ to $32$ usually sufficient।

When low-rank breaks:

  • Domain shift: Pretrained image → medical X-ray। Need full fine-tune; LoRA insufficient।
  • Multiple complex concepts: Single LoRA, many subjects/styles — rank exhausted।
  • Adversarial / OOD: Fine-tune significantly different objective।
  • Compositional changes: Some tasks require coupled changes — low rank captures averaged effect।

Rank choice trade-offs:

  • $r=4$: minimal, simple style transfer।
  • $r=8$: typical SD LoRA, single subject।
  • $r=16$: complex style + subject।
  • $r=32$: multi-subject or detailed art style।
  • $r=64+$: approaching full fine-tune capacity।

How to determine rank empirically:

  • Start with $r=8$, evaluate quality।
  • Underfitting (subject not captured) → increase $r$।
  • Overfitting (only training poses generated) → decrease $r$ or training steps।
  • Singular value analysis: train high-$r$ LoRA, examine SV decay — find effective rank।

Connection to LLM efficient fine-tuning:

  • QLoRA (Dettmers 2023): 4-bit quantize backbone + LoRA। $13$B model on RTX 3090।
  • Multi-LoRA serving: thousands of users, one base model + per-user LoRA।
  • FedLoRA: federated learning, only LoRA shared।

Theoretical extensions:

  • DoRA: Decompose $W$ into magnitude $m$ and direction $V/\|V\|$। Train both separately।
  • OFT: Constrain $\Delta W$ to be orthogonal — preserve singular value structure।
  • VeRA: Shared random matrices across layers, only diagonal scaling trainable। 1000× fewer params।

SVD perspective:

  • $\Delta W = U\Sigma V^T$ — SVD of "what changes"।
  • Top-$r$ singular values capture most variance।
  • $BA$ = rank-$r$ approximation।
  • Like PCA for weight updates।

Open research:

  • Optimal rank per layer (heterogeneous LoRA)।
  • Adaptive rank during training।
  • LoRA composition theory — when does sum of LoRAs work cleanly?
  • Connection to neural tangent kernel।

মূল উপলব্ধি: Low-rank assumption empirically remarkable। Fine-tuning ≠ full retrain; subset of "directions" changes। এই insight modern AI-এর parameter-efficient revolution-এর foundation। বাংলাদেশের context-এ — limited compute সাথে cutting-edge customization possible LoRA দিয়ে।

প্র ০২ DreamBooth-এর "prior preservation loss" essential — কেন? Without it কী fail হয়? Class images-এর number, quality — কী standard?

Prior preservation — DreamBooth-এর সবচেয়ে subtle কিন্তু critical component।

Without prior preservation:

  • Train on 5 images "[V] dog"।
  • Model learns: "dog" → looks like [V]।
  • Generic "a dog" prompt → also generates [V]!
  • Generic class concept overwritten।
  • Catastrophic forgetting of "dog" concept।

The problem in detail:

  • SD's "dog" representation — distributed across attention weights।
  • Fine-tuning for [V] dog updates same weights।
  • Loss only on [V] dog images → updates skewed।
  • Generic prior concept polluted।

Prior preservation loss:

  • Generate 200-500 images via base SD: "a photo of dog" (different breeds, scenes)।
  • Add to training as "class data"।
  • Loss: $\mathcal{L}_{[V]}$ + $\lambda \mathcal{L}_{class}$।
  • Forces model to keep generating diverse "dog" images while learning [V]।
  • $\lambda \approx 1$ standard balance।

Class images standards:

  • Number:
    • Minimum: 100 (some quality loss)।
    • Standard: 200।
    • Optimal: 300-500।
    • $200 = 100 \times \text{train_steps}/\text{class_steps}$ rule।
  • Generation:
    • Generate via base SD before training (auto if not exists)।
    • Prompt: "a photo of [class]" (e.g., "a photo of dog")।
    • Same resolution as instance images।
    • Random seeds, different prompts variations।
  • Quality:
    • Generate at high quality (50+ steps, CFG 7.5)।
    • Filter NSFW, malformed before use।
    • Diverse poses, backgrounds।

Class word selection:

  • Specific enough to be useful: "dog" not "animal"।
  • Broad enough to capture concept: "person" not "doctor"।
  • Model knows it well: avoid rare or compound words।

Common class words:

  • "person", "man", "woman" — for human subjects।
  • "dog", "cat" — for pets।
  • "toy", "object" — for items।
  • "painting", "illustration" — for artistic styles।

Rare token selection:

  • "sks" — DreamBooth paper default (rarely used token)।
  • "v1k", "ohwx" — community alternatives।
  • Avoid common words: "myself", "boy" — already loaded with semantics।
  • Test: SD's tokenizer — is your token a single token, infrequent in training data?

Without prior preservation — failure modes:

  • Concept collapse: Generic "dog" generates [V] dog। Useless model।
  • Style overfitting: All dogs look like [V]'s breed only।
  • Background imprinting: [V]'s usual background appears in unrelated prompts।
  • Pose limitation: Only [V]'s typical poses generated।

With prior preservation — clean separation:

  • "sks dog" → specifically [V]।
  • "dog" → generic dog।
  • "sks dog as superhero" → [V] dog in superhero scene (compositional)।

LoRA — does it need prior preservation?

  • Less critical because main weights frozen।
  • Still recommended for high-quality LoRA।
  • Civitai community often skips for hobby LoRAs — quality variable।
  • Production LoRA training — use prior preservation।

Alternative regularization:

  • EMA of base model — periodic weight averaging।
  • Lower learning rate + fewer steps — less drift।
  • Selected layer training — only last layers।

Practical training tips:

  • Step count: 800-1500 for DreamBooth, 500-2000 for LoRA।
  • Learning rate: $1$-$5 \times 10^{-6}$ DreamBooth, $1$-$5 \times 10^{-4}$ LoRA।
  • Validate every 100 steps with sample generation।
  • Stop at first sign of subject capture without overfitting।

Multi-subject DreamBooth:

  • Multiple [V1], [V2] tokens, multiple class images।
  • More complex regularization needed।
  • Custom Diffusion (Kumari 2023) — better multi-subject।

মূল উপলব্ধি: Prior preservation = "remember what you knew". Generally fine-tuning ML's eternal challenge — gain new without losing old. DreamBooth's solution elegant — synthetic class data preserves general knowledge while learning specific। আজকের সব efficient fine-tuning এই principle অনুসরণ করে।

প্র ০৩ Civitai ecosystem-এ ১০০,০০০+ LoRAs — কোন categories জনপ্রিয়, quality কীভাবে judge করা হয়, copyright/IP issues কী? Community-driven model culture-এর pros and cons?

Civitai (২০২২ launched) — image generation-এর GitHub। Massive ecosystem, complex dynamics।

Civitai categories:

  • Character LoRAs (~30%): Anime characters, video game characters, public figures।
  • Style LoRAs (~25%): Specific artists' styles, art movements, photographic looks।
  • Concept LoRAs (~15%): Specific objects, scenes, lighting setups, time periods।
  • Outfit/clothing (~10%): Specific costumes, fashion styles।
  • Pose/expression (~5%): Combined with ControlNet usually।
  • NSFW (~10%): Adult content (separate filtering)।
  • Quality enhancers (~5%): "DetailedXL", anti-aging filters, etc.।

Quality indicators:

  • Sample images: Author-provided samples — primary quality signal।
  • Download count: 1K-10K typical popular, 100K+ massive।
  • Likes/ratings: 5-star scale।
  • Reviews: Community comments — practical insight।
  • Trigger words: Documented or not।
  • Recommended weight: 0.6-1.0 typical।
  • Compatible base: SD1.5, SDXL, Pony, Flux variants।

Discovering good LoRAs:

  • Sort by "Most Liked" recently (avoid stale)।
  • Check author profile — consistent producer = quality signal।
  • Read top reviews — failure modes mentioned।
  • Test before integrating into workflow।

Copyright/IP issues:

  • Public figure LoRAs:
    • Right of publicity violations possible।
    • Some celebrities have requested takedowns।
    • Civitai has takedown procedure।
    • Usage in deepfake/nonconsensual content — illegal in many jurisdictions।
  • Character LoRAs:
    • Copyrighted characters (Disney, Marvel, anime) — IP infringement risk।
    • Fan-made content historically tolerated, but commercial use risky।
    • Disney has aggressively pursued AI character generation cases।
  • Artist style LoRAs:
    • Greg Rutkowski, Karla Ortiz cases — artists object to style replication।
    • Class action lawsuits ongoing (২০২৪)।
    • "In the style of [artist]" — moral if not always legal issue।
  • Brand assets:
    • Logos, trademarks — clear IP।
    • Fashion brands very protective।

Civitai's response:

  • Real person LoRAs flagged or removed on request।
  • Some studios proactively report (Disney, Square Enix)।
  • NSFW restrictions for real persons strengthened (২০২৪)।
  • License labeling required (CreativeML, Apache, etc.)।

License variations:

  • CreativeML Open RAIL++: SD1.5/SDXL standard, commercial OK with restrictions।
  • Apache 2.0: Permissive (Flux Schnell)।
  • Custom non-commercial: Many character LoRAs।
  • "Use with credit": Author-imposed condition।

Community culture pros:

  • Innovation speed: New techniques propagate within days।
  • Diversity: Niche styles served — academic AI labs would miss।
  • Education: Tutorials, workflows shared freely।
  • Democratization: Anyone can contribute, no gatekeeping।
  • Cultural representation: Underserved styles emerge organically।

Cons:

  • Quality variance: Many low-effort uploads।
  • Naming chaos: "Beautiful Woman v3 final FINAL" — SemVer absent।
  • Documentation poor: Trigger words, weights often unspecified।
  • NSFW prevalence: Substantial portion of platform।
  • Plagiarism: Re-uploads, repackaging without credit।
  • Misuse vectors: Real-person LoRAs facilitate harm।
  • Power consumption: Crypto-like environmental concerns at scale।

Production usage considerations:

  • Diligence: Verify license, author, source images legality।
  • Train your own: Lower legal risk, custom quality।
  • Self-host: Don't rely on platform availability।
  • Document usage: Audit trail for compliance।

Bangladesh context — opportunities:

  • Underserved styles: Quamrul Hassan, Zainul Abedin, rickshaw art, jamdani patterns।
  • Cultural specificity LoRAs: traditional dress, regional architecture, cuisine।
  • Bangla typography styles।
  • Train carefully with public domain or licensed sources।
  • Civitai distribution: international visibility for Bangla designers।

Ethical considerations for creators:

  • Don't train on copyrighted artist work without permission।
  • Avoid real-person LoRAs without consent।
  • Document data sources clearly।
  • Disclaim limitations and biases।
  • Support artists whose styles inspire you।

Future trends:

  • License standardization (RAIL family expanding)।
  • Provenance metadata (C2PA)।
  • Watermarking for AI-generated images (SynthID)।
  • Royalty systems for foundational artists (proposed)।
  • Regional regulation increasing।

মূল উপলব্ধি: Civitai community-driven AI ecosystem-এর powerful কিন্তু messy ভর। ১,০০,০০০+ LoRA = unprecedented creative resource, also legal/ethical minefield। বাংলাদেশের designer/researcher-এর জন্য — opportunity to participate as quality contributor, building cultural/regional LoRAs with proper licensing।

প্র ০৪ আপনি একটি Bangladeshi fashion brand-এর জন্য consistent virtual model develop করতে চান (একই face, multiple settings, outfits)। DreamBooth, LoRA, InstantID, IP-Adapter — কোন combo সবচেয়ে ভাল? Production workflow design করুন।

Virtual model — fashion industry-এর hot trend। Bangladesh-এর জন্য practical, accessible roadmap।

Business case:

  • Same model identity across hundreds of campaigns — brand consistency।
  • No model availability conflicts।
  • Multiple ethnicities, body types easily accessible।
  • Ethical: avoid real model exploitation, deepfake issues।
  • Cost: 10-100× less than real photoshoot।

Tool comparison:

(১) DreamBooth — full fine-tune:

  • Pros: Highest fidelity, captures subtle features।
  • Cons: 3-7 GB per checkpoint, training expensive, base model "permanently" altered।
  • Best for: Single critical subject (CEO, mascot)।
  • Cost: ৳১০-৩০K initial training, ৳৩-১০K per refresh।

(২) LoRA — preferred for production:

  • Pros: Small (50-200 MB), fast training, swappable, composable।
  • Cons: Slightly less subject fidelity than DreamBooth।
  • Best for: Multiple personas (3-5 virtual models)।
  • Cost: ৳৫-১৫K initial training per persona।

(৩) InstantID (Wang 2024):

  • Pros: Zero training! Just provide reference face image at inference।
  • Cons: Identity preservation moderate; background bleeding issues।
  • Best for: Quick prototyping, customer-uploaded faces (try-on)।
  • Cost: Per-image inference।

(৪) PhotoMaker (Tencent 2024):

  • Similar to InstantID — multiple reference images, better identity।
  • Slower but higher quality।

(৫) IP-Adapter (Ye et al. 2023):

  • "Image as prompt" — face image guides generation।
  • Combined with face mask = strong identity control।
  • Plus modality, can use image instead of text।

Recommended hybrid workflow:

  1. Phase 1: Persona development
    • Define 3-5 virtual model personas (varying age, ethnicity, body type for inclusivity)।
    • For each: generate "training base" — 100-200 high-quality SD generations of consistent face।
    • Use "face seed" technique: same SD seed + similar prompts → same face।
    • Curate best 30-50 images for LoRA training।
  2. Phase 2: Train LoRA per persona
    • SDXL base + face LoRA per persona।
    • Rank 16-32 (face capture detailed)।
    • Class images: "person" or "woman" depending।
    • Train 1500-2000 steps, validate every 200।
  3. Phase 3: Outfit/style LoRAs
    • Separate LoRAs for: jamdani saree style, kurta-pajama, modern western, etc.।
    • Brand aesthetic LoRA (lighting, mood)।
    • Each rank 8 sufficient।
  4. Phase 4: Generation pipeline
    • Pick face LoRA (persona) + outfit LoRA + style LoRA।
    • ControlNet OpenPose for varied poses।
    • Optional: IP-Adapter for additional reference (e.g., specific dress fabric)।
    • Inpainting for face refinement after initial generation।
  5. Phase 5: Quality control
    • Automated face similarity check (FaceNet vs reference)।
    • Hand/finger anomaly detection।
    • Human review for cultural appropriateness।

ComfyUI workflow:

  • Modular nodes: SDXL base → LoRA loader (face) → LoRA loader (style) → ControlNet (pose) → IP-Adapter (optional)।
  • JSON workflow saved, reused per campaign।
  • Batch process via API automation।

Tech stack:

  • Base: SDXL ($1024^2$, photo realism)।
  • LoRAs: 3-5 face, 5-10 outfit/style।
  • ControlNet: OpenPose, Canny।
  • Adapter: IP-Adapter for reference images।
  • Refiner: SDXL refiner for last 20% steps।
  • Upscaler: RealESRGAN-x4 to 4K।

Operating cost:

  • Training: One-time ৳৫০K-১.৫L।
  • Generation: ৳5-15 per final image (incl. compute, review)।
  • Maintenance: Quarterly LoRA refresh ৳১০-৩০K।
  • Compared to real photoshoot: ৳৫,০০০-৫০,০০০ per image। Massive savings।

Bangladesh-specific challenges & solutions:

  • Cultural specificity:
    • Train on Bangladeshi facial features (skin tone diversity)।
    • Source training images from Bangladeshi photography (with rights)।
    • Avoid generic South Asian stereotypes।
  • Outfit accuracy:
    • Saree drape style (Tangail, Dhakai, Mirpuri)।
    • Salwar kameez fits।
    • Religious wear (hijab, panjabi)।
    • Modern fusion (panjabi-jeans)।
  • Setting authenticity:
    • Local backgrounds: rural Bangladesh, Old Dhaka, Cox's Bazar, modern Dhaka।
    • Festival contexts: Eid, Pohela Boishakh, Pohela Falgun।
    • Climate: monsoon, summer, winter distinctness।

Ethical guardrails:

  • Disclosure: "AI-generated model" labeling for transparency।
  • No real-person impersonation: Persona clearly synthetic, not based on identifiable individual।
  • Body diversity: Don't promote unrealistic standards।
  • Consent: If using any real photo references, ensure permission।
  • Cultural sensitivity: Review with local cultural advisors।
  • Religious sensitivity: Avoid clashing imagery (e.g., not all imagery adopted from one faith)।

Legal considerations:

  • Bangladesh Advertising Standards Council guidelines।
  • Consumer protection — accurate product representation।
  • Trademark — don't infringe brand likenesses।
  • Data Protection Act compliance for any user data।

Scaling strategy:

  • Phase 1 (3 months): Build 1 persona, 5 outfit LoRAs, 1,000 images।
  • Phase 2 (6 months): Expand to 5 personas, full catalog। 10,000 images।
  • Phase 3 (Year 1): Personalized try-on (customer face + brand outfits)।
  • Phase 4 (Year 2): Video generation (animated lookbook, Sora-class models)।

Risks & mitigation:

  • Quality drift: Regular refresh, A/B testing।
  • Public backlash: Transparency, gradual roll-out।
  • Tech obsolescence: Modular pipeline allows model swapping।
  • Competition: Custom LoRAs proprietary advantage।

Success metrics:

  • Customer engagement (CTR, conversion)।
  • Cost per visual asset।
  • Time to market (campaign launch speed)।
  • Brand consistency score (visual similarity across visuals)।

মূল উপলব্ধি: Virtual model = LoRA stacking + ControlNet + IP-Adapter এর symphonies। বাংলাদেশের fashion brands (Aarong, Yellow, Sailor, Cats Eye) — যারা first move করবে তারা cost-leader & innovator হবে। Tech mature; differentiation cultural authenticity, ethical execution, brand storytelling-এ। আগামী ৫ বছরে Bangladesh fashion-এ AI-imagery standard হবে — early movers competitive advantage।

অনুশীলন

  1. LoRA size calculation: SD1.5-এ cross-attention $W$ shape $768\times 768$। Rank $r=8$ LoRA params কত? Full $W$-এর তুলনায় কত গুণ ছোট?

    Full $W$: $768 \times 768 = 589{,}824$ params।

    LoRA: $B$ ($768 \times 8$) + $A$ ($8 \times 768$) = $6{,}144 + 6{,}144 = 12{,}288$ params।

    Ratio: $589824 / 12288 = 48$ — ৪৮× ছোট।

    Combined across all attention layers: SD1.5 cross-attn ~30M params total → LoRA ~3M।

  2. Train your first LoRA: Colab T4-এ 10-20 ছবি (যেকোনো subject) দিয়ে SD1.5 LoRA train করুন। কোন parameters tweak করলেন?

    Standard config:

    • Resolution 512, batch_size 1, gradient_accumulation 4।
    • learning_rate 1e-4, max_train_steps 1000।
    • rank 8, network_alpha 8।

    Common adjustments:

    • Subject not captured: increase steps to 1500, rank to 16।
    • Overfitting (only training-poses): decrease steps to 500।
    • Style LoRA: lower learning_rate 5e-5।
  3. LoRA composition: Stack 3 LoRAs in inference (face + style + outfit)। Conflict হলে কী strategies প্রয়োগ করবেন?
    • Reduce weights: each 0.5-0.7 instead of 1.0 (avoid additive over-influence)।
    • Test pairs first: face+style alone, then add outfit।
    • Use specific trigger words for each।
    • If conflict persists: train combined LoRA on merged dataset।
    • Rank-stable variants (LyCORIS, LoHA) sometimes compose better।

আরও পড়ুন · ABCL TECH-এ আপনার পরবর্তী পদক্ষেপ

Hands-on: Colab-এ train_dreambooth_lora.py চালান। Civitai-এ আপনার trained LoRA upload — community feedback নিন।
পূর্ববর্তী পাঠ
পাঠ ১৮ · ControlNet