CoolFace
Modelpublic

Oysiyl/t2i-adapter-brightness-sdxl-10k

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes17downloads
Model Card

SDXL T2I Adapter - Brightness Control

Metadata

yaml
license: apache-2.0
base_model: stabilityai/stable-diffusion-xl-base-1.0
tags:
  - stable-diffusion-xl
  - stable-diffusion-xl-diffusers
  - text-to-image
  - diffusers
  - t2i-adapter
  - brightness
  - sdxl
library_name: diffusers
pipeline_tag: image-to-image
datasets:
  - latentcat/grayscale_image_aesthetic_3M

Overview

A T2I Adapter model trained on Stable Diffusion XL to control image generation through brightness/grayscale information. T2I Adapters provide a lightweight alternative to ControlNet with ~77M parameters (~300MB) compared to ~700M parameters (~3GB) for ControlNet, enabling much faster training and inference.

๐ŸŽ‰ NEW: Now includes 1024ร—1024 native SDXL resolution model!

Key Features:

  • โ€”๐ŸŽจ Control brightness and lighting in generated images
  • โ€”๐Ÿš€ 2.7x faster training than ControlNet (~18 minutes vs ~49 minutes @ 1024ร—1024)
  • โ€”๐Ÿ’พ 15x smaller model size (~300MB vs ~4.7GB)
  • โ€”๐Ÿ–ผ๏ธ Two versions: 512ร—512 and 1024ร—1024 (native SDXL)
  • โ€”๐Ÿ”„ Compatible with standard SDXL pipelines
  • โ€”๐Ÿ’ก Trained on high-quality aesthetic images
  • โ€”๐Ÿ”ฅ Strong pattern preservation at high conditioning scales

Intended Uses:

  • โ€”Artistic QR code generation (especially with 1024ร—1024 model at scale 2.0+)
  • โ€”Image recoloring and colorization
  • โ€”Lighting control in text-to-image generation
  • โ€”Brightness-based image manipulation
  • โ€”Photo enhancement and stylization
  • โ€”Watermark and pattern integration

Available Models

This repository contains two model versions:

512ร—512 Model (Original)

  • โ€”File: diffusion_pytorch_model.safetensors + config.json
  • โ€”Resolution: 512ร—512
  • โ€”Training: A100 40GB, 10k samples, ~11 minutes
  • โ€”Best for: General purpose, faster inference on limited hardware

1024ร—1024 Model (Native SDXL - Recommended)

  • โ€”File: diffusion_pytorch_model_1024.safetensors + config_1024.json
  • โ€”Resolution: 1024ร—1024 (native SDXL!)
  • โ€”Training: H100 80GB, 10k samples, ~18 minutes
  • โ€”Best for: Maximum quality, strong pattern preservation, artistic QR codes
  • โ€”Discovery: Shows superior brightness preservation at conditioning scales 1.5-2.5

Training Details

512ร—512 Model

ParameterValue
Base Modelstabilityai/stable-diffusion-xl-base-1.0
VAEmadebyollin/sdxl-vae-fp16-fix
Training Resolution512ร—512
Training Steps157 (1 epoch)
Batch Size8 per device
Gradient Accumulation8 (effective: 64)
Learning Rate1e-5
Mixed PrecisionFP16
HardwareNVIDIA A100 40GB
Training Time~11 minutes
Dataset10,000 samples from grayscaleimageaesthetic_3M

1024ร—1024 Model (NEW!)

ParameterValue
Base Modelstabilityai/stable-diffusion-xl-base-1.0
VAEmadebyollin/sdxl-vae-fp16-fix
Training Resolution1024ร—1024 (native SDXL)
Training Steps157 (1 epoch)
Batch Size8 per device
Gradient Accumulation8 (effective: 64)
Learning Rate1e-5
Mixed PrecisionFP16
HardwareNVIDIA H100 80GB
Training Time~18 minutes
Final Loss0.0796
Dataset10,000 samples from grayscaleimageaesthetic_3M

Installation

bash
pip install diffusers transformers accelerate torch

Usage

Option 1: 1024ร—1024 Model (Recommended for Best Quality)

python
from diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteScheduler
import torch
from PIL import Image

# Load T2I Adapter (1024ร—1024 model)
adapter = T2IAdapter.from_pretrained(
    "Oysiyl/t2i-adapter-brightness-sdxl-10k",
    subfolder=".",
    weight_name="diffusion_pytorch_model_1024.safetensors",
    torch_dtype=torch.float16
)

# Load SDXL pipeline
pipe = StableDiffusionXLAdapterPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    adapter=adapter,
    torch_dtype=torch.float16
)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
pipe.enable_xformers_memory_efficient_attention()
pipe.to("cuda")

# Load grayscale/brightness control image
control_image = Image.open("path/to/grayscale_image.png")
control_image = control_image.resize((1024, 1024))  # Resize to 1024ร—1024

# Generate image
prompt = "a beautiful landscape, highly detailed, vibrant colors"
negative_prompt = "blurry, low quality, distorted"

image = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image=control_image,
    num_inference_steps=30,
    adapter_conditioning_scale=2.0,  # Higher scales work great at 1024ร—1024!
    guidance_scale=7.5,
    height=1024,
    width=1024,
).images[0]

image.save("output.png")

Option 2: 512ร—512 Model (Original)

python
from diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteScheduler
import torch
from PIL import Image

# Load T2I Adapter (512ร—512 model - default)
adapter = T2IAdapter.from_pretrained(
    "Oysiyl/t2i-adapter-brightness-sdxl-10k",
    torch_dtype=torch.float16
)

# Load SDXL pipeline
pipe = StableDiffusionXLAdapterPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    adapter=adapter,
    torch_dtype=torch.float16
)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
pipe.enable_xformers_memory_efficient_attention()
pipe.to("cuda")

# Load grayscale/brightness control image
control_image = Image.open("path/to/grayscale_image.png")
control_image = control_image.resize((512, 512))

# Generate image
prompt = "a beautiful landscape, highly detailed, vibrant colors"
negative_prompt = "blurry, low quality, distorted"

image = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image=control_image,
    num_inference_steps=30,
    adapter_conditioning_scale=0.8,
    guidance_scale=7.5,
    height=512,
    width=512,
).images[0]

image.save("output.png")

Adapter Conditioning Scale Recommendations

The adapter_conditioning_scale parameter controls how strongly the adapter influences the generation:

For 512ร—512 Model:

  • โ€”0.3-0.5: Weak control, more creative freedom
  • โ€”0.6-0.8: Balanced control (recommended)
  • โ€”0.9-1.2: Strong control, closely follows brightness structure
  • โ€”1.3-2.0: Very strong control, minimal deviation

For 1024ร—1024 Model (NEW Findings!):

  • โ€”0.7-1.0: Artistic integration with subtle pattern hints
  • โ€”1.0-1.5: Balanced - visible structure with artistic elements
  • โ€”1.5-2.0: ๐Ÿ”ฅ EXCELLENT pattern preservation (recommended for QR codes!)
  • โ€”2.0-2.5: Maximum control - strong brightness patterns with artistic overlay

Discovery: The 1024ร—1024 model shows superior brightness preservation at scales 1.5-2.5, making it ideal for:

  • โ€”Artistic QR codes (scale 2.0 recommended)
  • โ€”Watermark integration
  • โ€”Pattern-based generation
  • โ€”Strong lighting control

Performance Comparison

1024ร—1024 vs 512ร—512 Model

Metric512ร—512 Model1024ร—1024 Model
Resolution512ร—5121024ร—1024 (native SDXL)
Training Time~11 min (A100)~18 min (H100)
Inference Speed~12 it/s @ 512~12 it/s @ 1024
Pattern PreservationGoodExcellent at high scales
Best Scale Range0.6-1.21.5-2.5
Use CaseGeneral purposeHigh quality, patterns, QR codes

T2I Adapter vs ControlNet (1024ร—1024)

FeatureT2I Adapter (1024)ControlNet (512)
Parameters~77M~700M
Model Size302MB4.7GB
Training Samples10,000 @ 1024100,000 @ 512
Training Time~18 minutes~49 minutes
Resolution1024ร—1024 (native)512ร—512 (upscaled)
Inference Speed @ 1024~12 it/s~8 it/s
Time per Image~2.5 seconds~4 seconds
Pattern Preservation @ Scale 2.0ExcellentGood

Winner for patterns: ๐Ÿ† T2I Adapter 1024ร—1024 at scale 2.0 shows stronger brightness pattern preservation than ControlNet!

When to Use Each Model

Use 512ร—512 Model when:

  • โ€”โœ… Limited VRAM (works on 8GB+ GPUs)
  • โ€”โœ… Faster inference needed
  • โ€”โœ… General brightness control
  • โ€”โœ… Natural image generation

Use 1024ร—1024 Model when:

  • โ€”โœ… Maximum quality required
  • โ€”โœ… Artistic QR code generation
  • โ€”โœ… Strong pattern preservation needed (scale 1.5-2.5)
  • โ€”โœ… Native SDXL resolution preferred
  • โ€”โœ… 16GB+ VRAM available

Use ControlNet when:

  • โ€”โœ… Sub-1.5 conditioning scales with precise control
  • โ€”โœ… Complex geometric precision at low scales
  • โ€”โœ… Production applications with strict requirements

Key Findings

๐ŸŽ‰ Major Discovery: The T2I Adapter trained at 1024ร—1024 resolution demonstrates superior brightness pattern preservation compared to the 512ร—512 version and even ControlNet at higher conditioning scales (1.5-2.5).

Evidence:

  • โ€”At scale 2.0, the 1024ร—1024 model preserves strong black/white patterns from input
  • โ€”Successfully maintains QR code structure while adding artistic elements
  • โ€”Shows chaotic but controlled pattern integration
  • โ€”Training at native SDXL resolution (1024ร—1024) provides better feature learning

Implications:

  • โ€”โœ… Ideal for artistic QR codes at scale 2.0
  • โ€”โœ… Excellent for brightness-based pattern control
  • โ€”โœ… Faster and smaller than ControlNet with comparable/better pattern preservation
  • โ€”โœ… Native SDXL resolution avoids upscaling artifacts

Checkpoints

This repository includes multiple checkpoints:

512ร—512 Model Checkpoints:

  1. 1.checkpoint-78/ - Middle checkpoint (~5,000 samples)
  2. 2.checkpoint-156/ - Near-final checkpoint (~10,000 samples)
  3. 3.Final model (diffusion_pytorch_model.safetensors) - Complete training

1024ร—1024 Model:

  1. 1.Final model (diffusion_pytorch_model_1024.safetensors) - Complete training at native SDXL resolution

Compare checkpoint quality to choose the best for your use case.

Example Use Cases

Artistic QR Code Generation (1024ร—1024 @ scale 2.0)

python
import qrcode
from PIL import Image

# Generate QR code
qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H)
qr.add_data("https://your-url.com")
qr_image = qr.make_image().resize((1024, 1024)).convert("RGB")

# Generate artistic QR with T2I Adapter
image = pipe(
    prompt="beautiful garden with flowers and butterflies",
    image=qr_image,
    adapter_conditioning_scale=2.0,  # Strong pattern preservation!
    height=1024,
    width=1024,
).images[0]

Brightness-Based Image Manipulation

python
# Convert photo to grayscale for brightness control
control = Image.open("photo.jpg").convert("L").convert("RGB").resize((1024, 1024))

# Recolor with new style
image = pipe(
    prompt="vibrant sunset colors, golden hour lighting",
    image=control,
    adapter_conditioning_scale=1.5,
    height=1024,
    width=1024,
).images[0]

Limitations

โš ๏ธ Training Efficiency Trade-offs:

  • โ€”Trained on only 10k samples (vs 100k for full ControlNet)
  • โ€”Single epoch training for rapid deployment
  • โ€”Best results at higher scales (1.5-2.5) for 1024ร—1024 model

For production use, consider:

  • โ€”Fine-tuning on domain-specific data
  • โ€”Training for multiple epochs for even better quality
  • โ€”Combining with other conditioning methods

Citation

bibtex
@misc{t2i-adapter-brightness-sdxl-10k,
  author = {Oysiyl},
  title = {SDXL T2I Adapter - Brightness Control (10k samples, 512 & 1024)},
  year = {2025},
  publisher = {HuggingFace},
  journal = {HuggingFace Model Hub},
  howpublished = {\url{https://huggingface.co/Oysiyl/t2i-adapter-brightness-sdxl-10k}}
}

License

Apache 2.0 License. Base SDXL model has separate license terms at stabilityai/stable-diffusion-xl-base-1.0

Training Code

This model was trained using the official Diffusers T2I Adapter training script with the following key configurations:

  • โ€”FP16 mixed precision training
  • โ€”xFormers memory-efficient attention
  • โ€”8-bit Adam optimizer
  • โ€”Gradient checkpointing for memory efficiency
  • โ€”MinSNR loss weighting (gamma=5.0)
  • โ€”FP16-fixed VAE for numerical stability

The 1024ร—1024 model was trained on H100 80GB without OOM errors, demonstrating excellent memory efficiency.

See the training script for implementation details.

Acknowledgments