Skip to content
syguan96Public
forked from vivo/BluePixel

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

BluePixelModel

Native 4K Image Editing Model based on Flux 2 Klein and DCAE

🤗 Hugging Face • 📜 Apache 2.0 License • 中文

Introduction

We are excited to open-source BluePixelModel, a native 4K image editing model upgraded from a 1K-pretrained Flux 2 Klein editor.

Four key features of BluePixelModel:

  • Native 4K Direct Output — Both input and output are 4096×4096, with no cascaded super-resolution or post-processing.
  • 4-Step Fast Inference — Compresses the 50-step teacher model into a 4-step student model via background-anchored step distillation.
  • Efficient 4K Training — Uses DCAE-F64 (f=64) to keep the 4K DiT token count at the 1K level, completing initial 4K adaptation on 32 Kunlunxin XPUs in about 4 days.
  • Continual Learning — Absorbs long-tail vertical editing skills through ACE-LoRA + OPD, avoiding task interference and catastrophic forgetting.

News

  • 2026.10.13: BluePixelModel inference code and documentation are open-sourced; model weights coming soon on Hugging Face.

Quick Start

Requirements

pip install -r requirements.txt

Single Image Editing

import torch
from vins_infer import load_pipeline

pipe = load_pipeline(
    "BluePixel-1.0",
    device="cuda",
    vae_tiling=False,
    lora_scale=None,
    shift=0,
    mu_mode="empirical",
)

result = pipe(
    image="input.png",
    instruction="make the hair red",
    num_inference_steps=4,
    guidance_scale=3.0,
).images[0]

result.save("output.jpg")

Batch Inference

Prepare a jsonl file with one task per line, each containing image_name (input image path) and edit_prompt (editing instruction) fields:

{"image_name": "/path/to/input.png", "edit_prompt": "make the hair red"}

Run:

CUDA_VISIBLE_DEVICES=0 python vins_infer.py \
    --model-dir BluePixel-1.0 \
    --jsonl /path/to/your_tasks.jsonl \
    --out-dir ./output \
    --target-pixels 16777216 \
    --steps 4 \
    --guidance 3.0 \
    --seed 42 \
    --mu-mode empirical \
    --instruction-field edit_prompt

Resume is enabled by default: re-running the same command automatically skips completed tasks (--no-resume forces a fresh run).

Recommended Resolutions

BluePixelModel natively supports 4K. Control output pixel count via --target-pixels:

target_pixels = {
    "1K": 1024 * 1024,      # 1048576
    "2K": 1440 * 1440,      # 2073600
    "4K": 4096 * 4096,      # 16777216
}

Default Parameters

Parameter Default Description
num_inference_steps 4 Number of denoising steps
guidance_scale 3.0 CFG guidance scale
target_pixels 16777216 Target pixel count (4K = 4096×4096)
mu_mode "empirical" μ-shift mode

Memory Optimization

For devices with limited memory, enable VAE tiling:

pipe = load_pipeline(
    "BluePixel-1.0", device="cuda", vae_tiling=True, mu_mode="empirical"
)

Or add --vae-tiling in the command line.

Command-line Arguments

Argument Type Default Description
--model-dir str Required Path to model weights directory
--jsonl str Required Task list jsonl file
--out-dir str Auto-derived Output directory
--target-pixels int 16777216 Target pixel count (4K = 4096×4096)
--steps int 4 Number of denoising steps
--guidance float 3.0 CFG guidance scale
--seed int 42 Random seed
--seeds str None Comma-separated multiple random seeds
--shift float 0.0 DiT shift parameter
--mu-mode str empirical μ-shift mode (empirical / training)
--instruction-field str edit_prompt Name of the editing instruction field
--device-id int 0 CUDA device id (usually set via CUDA_VISIBLE_DEVICES)
--lora-scale float None LoRA scale factor
--sft-ckpt str None SFT full model checkpoint path
--sft-lora-ckpt str None SFT LoRA checkpoint path
--vae-tiling flag False Enable VAE tiling to save memory
--limit int None Only process the first N tasks
--lock-timeout int 1800 File lock timeout in seconds
--metadata-file str metadata.jsonl Output metadata file name
--no-resume flag False Force fresh run, do not skip completed tasks
--dry-run flag False Print task plan only, do not run inference
--check flag False Only check task status, do not run inference

Training

The model is trained based on Flux 2 Klein. The overall process is divided into four stages:

Stage Objective Key Method
Preparation 4K resolution adaptation DCAE-F64 + progressive compression migration (f=8 → 32 → 64)
Enhancement SFT Editing quality improvement Progressive resolution SFT + benchmark-driven tuning + ACE-OPD
RL Aesthetic and instruction alignment Two-stage DiffusionNFT optimization
Distillation Faster inference Background-Anchored Step Distillation

Preparation: 4K Resolution Adaptation

Replace Flux 2 Klein's original f=8 VAE with DCAE-F64 (f=64), and migrate the compression ratio progressively f=8 → 32 → 64. At each level, three steps are performed:

Sub-stage Trainable Content Loss Function
Input projection distillation Train new input projection layer to align old and new VAE encodings Dual VAE alignment loss
Interface calibration Freeze DiT backbone; train only input / output projections Flow Matching Loss
Backbone adaptation Lightly adapt DiT backbone Flow Matching Loss
  • Approximately 200K samples, trained on 32 Kunlunxin XPUs for about 4 days.

Enhancement SFT

  • Progressive quality SFT: first train at 1024×1024, then transfer to native 4096×4096;
  • Benchmark-driven fine-tuning: data rebalancing + multi-epoch model merging;
  • Continual Learning (ACE-OPD): use ACE-LoRA to learn long-tail skills in groups; each group is distilled back into the base model via OPD, accumulating capabilities group by group.

RL: Reinforcement Learning Alignment

Optimize in two stages based on DiffusionNFT:

Stage Task Reward
Stage 1 T2I text-to-image PickScore (aesthetic optimization)
Stage 2 I2I image editing BluePixReward (instruction fidelity optimization)

Distillation: Inference Step Distillation

Compress the 50-step teacher into a 4-step student via background-anchored step distillation:

  • Anchor non-edited regions to the source latent to ensure background consistency;
  • 4K editing takes only about 8.7 seconds on a single Kunlunxin P800 XPU;
  • Achieves approximately 12× inference speedup compared to the 50-step teacher.

Model Architecture

Overall Configuration

Component Configuration
Base Model FLUX.2-Klein — 1K pretrained image editor
DiT 9B dual-stream + single-stream Transformer
Text Encoder Qwen3
VAE (Original) f=8, 2×2 patchify, 32 channels
VAE (Ours) DCAE-F64: f=64, 1×1 patchify, 128 channels
Output Resolution Native 4096×4096
Inference Steps 4 steps (student model)

4K Token Control

Input Resolution VAE Patchify Latent Size Token Count
1024×1024 f=8, 2×2 8× 128×128 ~4096
4096×4096 f=8, 2×2 8× 512×512 ~65536
4096×4096 f=64, 1×1 64× 64×64 ~4096

At 4K, DCAE-F64 reduces token count from 65536 to about 4096, comparable to 1K editing.

Inference Pipeline

Input Image (4096×4096) + Edit Prompt
         │
         ▼
   ┌─────────────────┐     ┌────────────────┐
   │  DCAE-F64 Encode │     │  Qwen3 Encode  │
   │    (64× ↓)       │     │  (L9/L18/L27)  │
   └───────┬─────────┘     └───────┬────────┘
           │                       │
           ▼                       ▼
     Image Latents (64×64)   Text Embeds
           │                       │
           └──────────┬────────────┘
                      ▼
             ┌─ 4-step Denoising ─┐
             │ FlowMatchEuler       │
             │ [Noisy, Source Img]  │
             │ Joint Attention      │
             │ CFG (scale=3.0)      │
             │ Empirical μ-shift    │
             └──────────┬───────────┘
                        ▼
             DCAE-F64 Decode (64× ↑)
                        │
                        ▼
              Output Image (4096×4096)

Project Structure

BluePixelModel/
├── vins_infer.py                     # Batch inference script (resume + file-lock multi-process)
├── run_vins_bench_v2.sh              # Single-GPU launch script (one-command test)
├── assets/
│   ├── test_input.jpg                # Test input image
│   └── test_examples.jsonl           # Example task list (3 editing instructions)
├── README.md
├── README_CN.md
└── LICENSE

Evaluation

Image Editing Benchmarks

Method Resolution Metric Score
BluePixelModel (50-step) 4K - -
BluePixelModel-Distill (4-step) 4K - -

Disclaimer, License & Citation

Disclaimer

We hereby solemnly declare that all parties using the open-source model are strongly urged not to engage in any behavior that harms national or social security or violates applicable laws. We also request that users do not apply BluePixelModel in products without proper security review and regulatory filing. Please ensure that all business activities are conducted lawfully and in compliance with all applicable regulations.

The model is provided "as is". While we have made every effort to ensure data compliance, the complexity of model training and data may still lead to unforeseen issues. We strongly recommend that users conduct thorough risk assessments to ensure lawful and compliant use. We assume no responsibility for any issues arising from the use of the BluePixelModel open-source model.

License

This project is licensed under the Apache 2.0 License.

For information about third-party dependencies and their licenses, please refer to the NOTICE file.

Citation

@misc{2026bluepixelmodel,
    title={BluePixelModel: 4K Resolution Image Editing via Flux 2 Klein with DCAE},
    author={BluePixelModel Team},
    howpublished = {\url{https://github.com/<org>/BluePixelModel}},
    year={2026}
}

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages