Text-to-Image
Diffusers
Safetensors
English
Chinese
flow-matching
qwen-image
ascend
lora
recursive-self-improvement
Instructions to use DALabCommunity/Haidass-Image-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use DALabCommunity/Haidass-Image-Instruct with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("DALabCommunity/Haidass-Image-Base-v1_0.6B_512px", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("DALabCommunity/Haidass-Image-Instruct") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
|
Download DETAILS.md from DALabCommunity/Haidass-Image-Instruct: direct link, hf CLI and curl.
- Browser
- Download file 35.7 kB
-
https://huggingface.co/DALabCommunity/Haidass-Image-Instruct/resolve/main/DETAILS.md
- Command line
-
hf download hf://DALabCommunity/Haidass-Image-Instruct/DETAILS.md
-
curl -L -o DETAILS.md https://huggingface.co/DALabCommunity/Haidass-Image-Instruct/resolve/main/DETAILS.md
35.7 kB
| # Haidass-Image-Instruct 0.1.0 — Technical Details | |
| [← Back to README](README.md) · **English** · [简体中文](DETAILS_zh.md) | |
| This document holds the full technical details moved out of [README.md](README.md): architecture, complete benchmark tables and footnotes, full ≤1B comparison tables with paper links, evaluation notes and known limitations, component breakdowns, the counting `k` curve, training hyperparameters, agent post-training workflow, full inference commands (including PowerShell and `generate_batch`), runtime and hardware, and gallery/version provenance. | |
| ## Gallery note | |
| *48 images in `assets/gallery.jpg` were selected from 150 candidates drawn from the evaluation runs (MJHQ-30K, OneIG-Bench, DPG-Bench, CVTG-2K, the held-out counting set, and PixelGen-rewritten GenEval), generated at 512 × 512 on Ascend NPU (batch size as in each evaluation; lettering uses the writing route, and counting images come from the fixed candidate pools via the counting head). The same seed gives a different image on CUDA or CPU because the initial noise is drawn differently.* | |
| ## Architecture | |
| | Component | Specification | | |
| |---|---| | |
| | Generation backbone | Single-stream diffusion transformer (`PackedSingleStreamDiT`, Qwen-Image-2.1 based), flow matching; 34 layers, 9 heads × 128 dim, ~598M parameters; stored as 315 FP32 tensors (`dit.safetensors`, merged EMA from Flow-GRPO update 240) | | |
| | Text encoder | [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B), frozen, last-layer hidden states, max 256 tokens, right-padded, EOS token for the unconditional branch | | |
| | VAE | Qwen-Image-2.1 VAE (64-channel latents), frozen | | |
| | Writing LoRA | PEFT LoRA (`r = 128`, `alpha = 256`, EMA FP32, covering 238 linear layers across all 34 layers); activates automatically with letter-by-letter spelling annotation when the prompt requests quoted English display text | | |
| | Counting head | Two-layer MLP (hidden size 64) reading 4 × 4 spatially averaged layer-25 features at step 5 of the 50-step schedule to predict 8 object-count classes (`0–6` and `7+`); activates automatically at 50 steps when the prompt specifies one unambiguous object count | | |
| | Resolution | 512 × 512 | | |
| Default per-prompt routing follows one fixed priority order: if a prompt requests quoted display text (generally in the same sentence as a carrier or writing word), the writing route runs (writing LoRA + letter-by-letter spelling); otherwise, if the prompt parses to one unambiguous object count at 50 sampling steps, the counting route runs (8 initial noises run 5 of 50 steps and the counting head selects one to finish to step 50); all other prompts run a single 50-step pass on the backbone. When a prompt contains both quoted text and a count, the writing route takes precedence. | |
| ## Main results | |
| All 0.1.0 numbers below are measured on the **whole model under default inference** (512 × 512, Euler 50 steps, CFG 8.0, timestep shift 1.0, automatic routing, no LLM prompt rewriting). For backbone-only and component-by-component numbers, see [What each part contributes](#what-each-part-contributes). | |
| | Benchmark | Scale / protocol | Base (`60463`) | **Haidass-Image-Instruct 0.1.0** | | |
| |---|---|---:|---:| | |
| | **Original GenEval** (seed 42, official)¹ | 0–1 (553 × 4) | 0.600 | **0.859** | | |
| | **Original GenEval** (seed 43)¹ | 0–1 (553 × 4) | — | **0.869** | | |
| | **Original GenEval** (2 seed batches)¹ | 0–1 (553 × 8) | — | **0.864** | | |
| | **PixelGen-rephrased GenEval**² (2 seed batches) | 0–100 (553 × 8) | 67.05 | **86.34** | | |
| | Held-out composition (8 COCO classes unseen in training)³ | 0–100 (400 × 4) | 59.00 | **87.94** | | |
| | Held-out counting (8 unseen classes, exact count)³ | % (200 × 4) | — | **67.00%** | | |
| | **DPG-Bench** | 0–100 (1,065 × 4) | 83.98 | **84.28** | | |
| | **CVTG-2K** word accuracy / NED / CLIPScore | % / 0–1 / 0–1 (2,000) | 0.22% / 0.212 / — | **45.08%** / **0.716** / **0.760** | | |
| | **OneIG-Bench (EN)** Alignment | 0–100 (695 × 4) | 80.11 | **81.82** | | |
| | **OneIG-Bench (EN)** Text | 0–100 (200 × 4) | 0.68 | **34.75** | | |
| | **OneIG-Bench (EN)** Reasoning | 0–100 (225 × 4) | 19.11 | **19.08** | | |
| | **OneIG-Bench (EN)** Style | 0–100 (114 × 4) | 39.46 | **40.31** | | |
| | **OneIG-Bench (EN)** Diversity | 0–100 (1,120 × 4) | 26.56 | **17.60** | | |
| | **OneIG-Bench (EN)** Overall (5-dim avg) | 0–100 (1,120 × 4) | 33.18 | **38.71** | | |
| | **MJHQ-30K FID ↓** (Sana protocol)⁴ | FID (30,000) | 13.38 | **10.33** | | |
| | **MJHQ-30K CLIP** | CLIP (30,000) | 25.35 | **26.10** | | |
| ¹ Under default inference, counting prompts use 8-pick candidate selection via the counting head and all other prompts use a single draw. | |
| ² "PixelGen-rephrased GenEval" refers to PixelGen's rewritten 553 GenEval prompts with the leading `"The image shows "` removed. | |
| ³ Internal evaluation sets built from 8 COCO classes removed from the v4 supervised retraining data, the Flow-GRPO prompts, and the counting-head training data (not removed from the base model's pre-training data or the writing-LoRA data); not included in this repository. | |
| ⁴ Evaluated under the Sana protocol (512 × 512, JPEG Q75, `pytorch-fid` 2,048-d Inception features). Base `60463` PixelGen-rephrased GenEval (`67.05`; batch-4: `66.93`) and MJHQ (`13.38` / `25.35`) used sequential single-image generation; Base CVTG-2K (`0.22%`) used prompts without spelling annotation. | |
| ## Comparison with ≤1B models | |
| External rows below are limited to models published on or after 2026-05-30. Their numbers are verified against each model's primary paper, technical report, or official release page. Parameter counts list the visual generator backbone only. All external models use single-draw generation without prompt rewriting; our model uses BLIP3o-60K with **7,190 near-duplicates removed** (and two sentence-level cleaning scans with zero hits). Single-draw backbone-only scores for 0.1.0 are reported in [What each part contributes](#what-each-part-contributes). | |
| ### Original GenEval (553 prompts, 0–1 scale) | |
| | Model | Date | Params | Resolution | Inference mode | BLIP3o-60K | GenEval ↑ | | |
| |---|---|---:|---:|---|---|---:| | |
| | [RG-T2I-L/16](https://arxiv.org/html/2610.12978) | 2026-10 | 912M | 512 × 512 | single draw | Yes (120K mix) | 0.89 | | |
| | [MiniT2I-L/16](https://peppaking8.github.io/minit2i/) | 2026-06 | 912M | 512 × 512 | single draw | Yes (120K mix) | 0.883 | | |
| | [AMD Nitro-P](https://rocm.blogs.amd.com/artificial-intelligence/nitro-p/README.html) | 2026-11 | 679M | 512 × 512 | single draw | Yes (120K mix) | 0.88 | | |
| | [UNIFIED-L](https://arxiv.org/html/2611.29064) | 2026-11 | 554M | 256 × 256 | single draw | Yes | 0.878 | | |
| | [HiT-B/16](https://arxiv.org/html/2611.22962) | 2026-11 | 250M | 512 × 512 | single draw | Yes (120K mix) | 0.878 | | |
| | [HiRAE-24](https://arxiv.org/html/2609.37775) | 2026-09 | 875M | 256 × 256 | single draw | Yes | 0.877 | | |
| | [JuZhou 1.0](https://arxiv.org/html/2606.28421) | 2026-06 | 385M | 1024 × 1024 | single draw | No | 0.70 | | |
| | **Haidass-Image-Instruct 0.1.0 (ours)**¹ | 2026-11 | 0.6B | 512 × 512 | counting prompts 8-pick; others single draw | Yes (7,190 near-dups removed) | **0.859** | | |
| ¹ **How counting prompts are generated in 0.1.0:** 8 initial noises each run 5 of the 50 steps; the counting head reads step-5 intermediate features (layer 25, 4 × 4 pooled) and predicts how many objects each candidate would end with (classes `0–6` and `7+`); the candidate most likely to show the requested number continues to step 50. The `0.859` row reports official seed 42 (`0.869` on seed 43; `0.864` across two seed batches). External rows use single-draw generation, so 0.1.0's default-inference row is listed separately at the bottom without a single-draw rank. Among ≤1B single-draw models published since 2026-05-30 without BLIP3o-60K or prompt rewriting, the highest score is JuZhou 1.0 (`0.70`); all 10 ≤1B models published since 2026-05-30 that score `0.85–0.89` (the six highest are listed above) fine-tuned on BLIP3o-60K or the MiniT2I 120K mix. | |
| ### DPG-Bench (1,065 prompts, 0–100 scale) | |
| | Model | Date | Params | Resolution | Inference mode | BLIP3o-60K | DPG-Bench ↑ | | |
| |---|---|---:|---:|---|---|---:| | |
| | [RG-T2I-L/16](https://arxiv.org/html/2610.12978) | 2026-10 | 912M | 512 × 512 | single draw | Yes (120K mix) | 87.1 | | |
| | [Looped-DiT B/16](https://arxiv.org/html/2609.40305) | 2026-09 | 260M | 512 × 512 | single draw | Yes (120K mix) | 87.0 | | |
| | [HiRAE-24](https://arxiv.org/html/2609.37775) | 2026-09 | 875M | 256 × 256 | single draw | Yes | 86.35 | | |
| | [AMD Nitro-P](https://rocm.blogs.amd.com/artificial-intelligence/nitro-p/README.html) | 2026-11 | 679M | 512 × 512 | single draw | Yes (120K mix) | 86.33 | | |
| | [MiniT2I-L/16](https://peppaking8.github.io/minit2i/) | 2026-06 | 912M | 512 × 512 | single draw | Yes (120K mix) | 85.9 | | |
| | [HiT-B/16](https://arxiv.org/html/2611.22962) | 2026-11 | 250M | 512 × 512 | single draw | Yes (120K mix) | 85.33 | | |
| | [UNIFIED-L](https://arxiv.org/html/2611.29064) | 2026-11 | 554M | 256 × 256 | single draw | Yes | 84.8 | | |
| | [NanoGen (FLUX.2-VAE)](https://arxiv.org/html/2606.24888) | 2026-06 | 612M | 256 × 256 | single draw | No | 84.1 | | |
| | **Haidass-Image-Instruct 0.1.0 (ours)** | 2026-11 | 0.6B | 512 × 512 | default routing (counting 8-pick; writing / backbone single draw) | Yes (7,190 near-dups removed) | **84.28** | | |
| ### OneIG-Bench (EN, 0–1 scale), MJHQ-30K FID (Sana protocol), and CVTG-2K | |
| | Benchmark & Model | Date | Params | Resolution | Inference mode | BLIP3o-60K | Score | | |
| |---|---|---:|---:|---|---|---:| | |
| | **OneIG (EN) Overall ↑** — [AnisoFlow-L/16 + DWD](https://arxiv.org/html/2611.22287) | 2026-11 | 940M | 1024 × 1024 | single draw | No | 0.533 | | |
| | **OneIG (EN) Overall ↑** — [AnisoFlow-L/16](https://arxiv.org/html/2611.17767) | 2026-11 | 918M | 1024 × 1024 | single draw | No | 0.528 | | |
| | **OneIG (EN) Overall ↑** — [JiT-L/16-T2I](https://arxiv.org/html/2611.17767) | 2026-11 | 917M | 512 × 512 | single draw | No | 0.512 | | |
| | **OneIG (EN) Overall ↑** — **Haidass-Image-Instruct 0.1.0 (ours)** | 2026-11 | 0.6B | 512 × 512 | default routing | Yes (7,190 near-dups removed) | **0.387** | | |
| | **MJHQ-30K FID ↓** — **Haidass-Image-Instruct 0.1.0 (ours)** | 2026-11 | 0.6B | 512 × 512 | default routing | Yes (7,190 near-dups removed) | **10.33** | | |
| | **CVTG-2K (WA / NED / CLIP) ↑** — **Haidass-Image-Instruct 0.1.0 (ours)** | 2026-11 | 0.6B | 512 × 512 | writing route (single draw) | Yes (7,190 near-dups removed) | **45.08% / 0.716 / 0.760** | | |
| Additional references (>1B models): on OneIG-Bench (EN), [SeFi-Image-1B](https://arxiv.org/html/2606.22568) (2026-06, ~1.18B, 1024 × 1024, single draw, BLIP3o-60K unspecified) scores `0.525` overall (`0.859 / 0.884 / 0.271 / 0.398 / 0.212`). On CVTG-2K, no other ≤1B model reports scores; [SeFi-Image-1B](https://arxiv.org/html/2606.22568) reports `71.8%` word accuracy, `0.862` NED, and `0.810` CLIPScore. On the PixelGen rewritten GenEval prompts, only [Halcyon](https://arxiv.org/html/2610.26863) (2026-10, 256 × 256, pre-trained only, single draw, no BLIP3o-60K) reports numbers (`Halcyon-0.52B` 0.52B: `44.91`; `Halcyon-4.00B + I2T 10%` 4.00B: `55.33`; `JiT-T2I-XXL/16++` 1.11B: `41.79`). | |
| ## Evaluation notes | |
| - **Data cleaning and 0.0.1 retirement.** Version 0.0.1's training data overlapped evaluation prompts; 0.1.0 retrains from base `60463` on sentence-level cleaned data (v4, two independent scans with zero hits, and all 8 held-out COCO classes removed). Version 0.0.1 remains archived at git tag `v0.0.1` and its scores are retired. | |
| - **Overlap control (`v5-A`).** Removing a further 35,949 images (12.4%) from the v4 pool whose object combination matches an evaluation prompt (same unordered object set, same structure, or left/right swapped) and retraining from base — while keeping per-source sampling totals fixed, so the remaining counting images were drawn 33 times on average versus 21.7 in v4 — yields no statistically significant difference on PixelGen-rephrased GenEval total (`82.79` vs `83.17`, `−0.38`, 95% CI `[−1.56, +0.79]`) or held-out composition (8 unseen classes, `−1.00`), while the PixelGen-rephrased GenEval position sub-score is `3.13` points lower (`[−6.00, −0.25]`). The `−3.13` position result reflects removing the overlapping images together with the changed per-source sampling (33 vs 21.7 draws per counting image); the two cannot be separated in `v5-A`. | |
| - **Checkpoint selection.** Among 11 CFG1 EMA RL candidates with completed two-batch PixelGen-rephrased GenEval and held-out composition evaluations, the pre-registered rule dropped any candidate with held-out composition significantly below v4 (zero dropped) and chose the highest two-batch PixelGen-rephrased GenEval: update `240` (`85.73`; updates `280`, `320`, and `334` scored `85.68`, `85.50`, and `85.54`). | |
| - **Shared detector and blind visual check.** Flow-GRPO training reward and the GenEval-family benchmarks use the same `Mask2Former` + `CLIP ViT-L/14` detector. In a blind visual review of 60 proportionally sampled flipped image pairs on PixelGen-rephrased GenEval standard seeds (update 240 vs v4), true improvements (~11 images extrapolated) and regressions (~14 images) roughly balanced out, while on the update-240 backbone vs v4, benchmarks with independent scorers — DPG-Bench (`+1.07`), OneIG Alignment (`+0.54`), OneIG Reasoning (`+0.39`), MJHQ-30K FID (`−0.19`), and MJHQ-30K CLIP (`+0.08`) — improved significantly. | |
| - **Benchmark definitions and protocols.** "PixelGen-rephrased GenEval" refers to `evaluations/geneval/evaluation_metadata_rephrased.jsonl` from [PixelGen](https://arxiv.org/abs/2602.02493) with `"The image shows "` stripped from each prompt. MJHQ-30K FID uses the Sana protocol (512 × 512, JPEG Q75) and is compared only with our own stages. CVTG-2K reports word accuracy, NED, and CLIPScore (VQAScore and Aesthetic Score are omitted). Held-out composition (400 prompts × 4 images), held-out counting (200 prompts × 4 images), and other internal sets are not released with this repository. | |
| - **Cross-seed diversity.** OneIG-Bench (EN) Diversity moves from `26.56` (base `60463`) to `17.74` (v4) to `17.60` (0.1.0; backbone-only update 240 is `17.21`). Post-training makes outputs for the same prompt more consistent across seeds. | |
| ### Known limitations | |
| - **English text only and carrier-word routing rule.** Writing supports English text. For general carriers and writing cues (`sign`, `poster`, `reads`, `says`, `labeled`, `cover`, etc.), quoted text must sit in the same sentence as the carrier word (Chinese corner quotes, colon-introduced text, and certain print-design carriers use separate rules): | |
| - *Triggers writing route:* `A teal enamel sign reading "OPEN LATE" in a rainy shop window` | |
| - *Does not trigger writing route (carrier word in a different sentence):* `A minimalist book cover on a wooden table. Display "MIDNIGHT GARDEN" across the center.` | |
| - Unquoted document/title-page prompts also do not trigger the writing route (in OneIG-Bench EN Text, 11 of 200 prompts did not trigger, accounting for 25.9% of target words; routed 189 prompts scored `21.45%` word accuracy vs `0.06%` on the 11 unrouted prompts). | |
| - **Digits, punctuation, and complex scenes with text.** On CVTG-2K, word accuracy is `7.69%` for words with digits or punctuation (1,730 words) vs `49.59%` for letters-only words (14,476 words). Because 82% of writing LoRA training data uses flat synthetic layouts, prioritizing clear lettering on quoted-text prompts in complex multi-object scenes can shrink the main subject: on 0.1.0, the whole model scores `84.28` on DPG-Bench, `0.31` lower than the same-batch backbone (`84.58`, `−0.31`, 95% CI `[−0.59, −0.02]`), mainly because the 70 quoted-text DPG prompts take the writing route (another 35 take the counting route) (at RL update 80, those 70 routed prompts gained `+22.00` on `other - text` with `−5.61` on `entity - whole`, shifting overall DPG by `−0.25`). Pass `--writing-lora off` when scene composition matters more than embedded text. | |
| - **Counting head scope.** The counting head predicts classes `0–6` and `7+` and runs at 50 sampling steps (other step counts fall back to a single draw). Its gain on long descriptive prompts (~132 words, PixelGen-rephrased GenEval counting, 80 prompts) is `+3.13` pp vs single draw (`95% CI [−1.82, +8.07]`, not statistically significant). When the parser extracts the wrong target count `N`, the head selects for that wrong count (`−37.50` pp vs single draw on 2 misparsed prompts). | |
| - **Route priority and cross-device seeds.** When a prompt contains both quoted display text and a parsed count, the writing route wins. Ascend NPU, CUDA, and CPU use different initial-noise generators, so the same seed produces different images across hardware backends. | |
| ## What each part contributes | |
| The tables below isolate (1) the formal backbone-only post-training stages, (2) what default routing (writing LoRA + counting head) adds on top of the update-240 backbone, and (3) the counting-head `k = 1 / 4 / 8 / 16` candidate curve (all EMA weights, 512 × 512, Euler 50 steps, CFG 8.0). | |
| ### Backbone-only formal scores (batch 4, single draw, no writing LoRA, no counting head) | |
| | Benchmark | Base (`60463`) | v4 cleaned SFT | **0.1.0 Backbone (RL update 240)** | Paired Δ vs v4 [95% CI] | | |
| |---|---:|---:|---:|---:| | |
| | PixelGen-rephrased GenEval (2 batches, 0–100) | 67.05 | 83.17 | **85.73** | +2.55 [+1.65, +3.46] | | |
| | Held-out composition (8 unseen classes, 0–100) | 59.00 | 81.56 | **83.56** | +2.00 [+0.90, +3.10] | | |
| | Original GenEval, seed 42 (0–1) | 0.600 | 0.797 | **0.834** | +0.037 [+0.025, +0.050] | | |
| | Original GenEval, seed 43 (0–1) | — | 0.804 | **0.848** | +0.044 [+0.032, +0.057] | | |
| | Original GenEval, 2 batches (0–1) | — | 0.800 | **0.841** | +0.041 [+0.031, +0.051] | | |
| | Held-out counting (exact-N, %) | — | 46.50% | **52.00%** | +5.50 [+2.63, +8.37] | | |
| | DPG-Bench (0–100) | 83.98 | 83.53 | **84.60** | +1.07 [+0.68, +1.46] | | |
| | OneIG (EN) Alignment / Reasoning (0–100) | 80.11 / 19.11 | 81.27 / 18.69 | **81.82 / 19.08** | +0.54 / +0.39 | | |
| | OneIG (EN) Style / Diversity / Text (0–100) | 39.46 / 26.56 / 0.68 | 40.60 / 17.74 / 0.32 | **40.33 / 17.21 / 0.42** | −0.27 / −0.53 / +0.10 | | |
| | OneIG (EN) Overall (0–100) | 33.18 | 31.73 | **31.77** | +0.04 [−0.16, +0.26] | | |
| | MJHQ-30K FID ↓ / CLIP (Sana protocol) | 13.38 / 25.35 | 10.53 / 26.02 | **10.33 / 26.10** | −0.19 / +0.08 | | |
| | CVTG-2K WA / NED / CLIPScore | 0.22% / 0.212 / — | 0.22% / 0.234 / 0.657 | **0.19% / 0.234 / 0.665** | — | | |
| On PixelGen-rephrased GenEval sub-tasks (v4 → update 240): single object `99.69 → 100.00`, two object `94.07 → 95.08`, counting `59.38 → 63.59` (`+4.22`), colors `92.02 → 94.68` (`+2.66`), position `77.13 → 79.50` (`+2.38`), and color attribution `76.75 → 81.50` (`+4.75`). | |
| ### Whole model vs. same-batch backbone (isolating writing LoRA + counting head) | |
| To isolate what the writing LoRA and counting head add without confounding generation batch size, routed prompts were generated one image at a time (`batch_size = 1`) for both the whole model and the same-batch backbone control, while all unrouted prompts reuse the formal `batch_size = 4` images and scores (zero paired difference on unrouted prompts): | |
| | Benchmark | Routed prompts (count / write) | Same-batch backbone | **Whole model (0.1.0)** | Whole − Same-batch [95% CI] | | |
| |---|---|---:|---:|---:| | |
| | PixelGen-rephrased GenEval (2 batches, 0–100) | 82 / 5 per batch | 85.79 | **86.34** | +0.54 [−0.28, +1.37] | | |
| | Original GenEval, seed 42 (0–1) | 73 / 0 | 0.838 | **0.859** | +0.021 [+0.011, +0.030] | | |
| | Original GenEval, seed 43 (0–1) | 73 / 0 | 0.849 | **0.869** | +0.020 [+0.011, +0.030] | | |
| | Original GenEval, 2 batches (0–1) | 73 / 0 per batch | 0.843 | **0.864** | +0.021 [+0.013, +0.029] | | |
| | Held-out composition (8 unseen classes, 0–100) | 100 / 0 | 83.50 | **87.94** | +4.44 [+3.04, +5.83] | | |
| | Held-out counting (exact-N, %) | 200 / 0 | 52.38% | **67.00%** | +14.63 [+10.47, +18.78] | | |
| | DPG-Bench (0–100) | 35 / 70 | 84.58 | **84.28** | −0.31 [−0.59, −0.02] | | |
| | OneIG (EN) Alignment (0–100) | 15 / 4 (of 695) | 81.80 | **81.82** | +0.02 [−0.03, +0.06] | | |
| | OneIG (EN) Text (0–100) | 0 / 189 (of 200) | 0.50 | **34.75** | +34.25 [+17.13, +45.34] | | |
| | OneIG (EN) Reasoning (0–100) | 0 / 0 (of 225) | 19.08 | **19.08** | 0.00 [0.00, 0.00] | | |
| | OneIG (EN) Style (0–100) | subset of 1 / 3 (of 114) | 40.32 | **40.31** | −0.02 [−0.04, +0.01] | | |
| | OneIG (EN) Diversity (0–100) | 15 / 193 (of 1,120) | 17.21 | **17.60** | +0.39 [+0.17, +0.61] | | |
| | OneIG (EN) Overall (0–100) | 15 / 193 (of 1,120) | 31.78 | **38.71** | +6.93 [+3.52, +9.14] | | |
| | MJHQ-30K FID ↓ (Sana protocol) | 185 / 0 | 10.335 | **10.335** | −0.001 [−0.008, +0.008] | | |
| | MJHQ-30K CLIP | 185 / 0 | 26.102 | **26.102** | +0.000 [−0.002, +0.002] | | |
| | CVTG-2K word accuracy (%) | 0 / 2,000 | 0.22% | **45.08%** | +44.87 [+43.43, +46.35] | | |
| | CVTG-2K NED | 0 / 2,000 | 0.234 | **0.716** | +0.482 [+0.472, +0.492] | | |
| | CVTG-2K CLIPScore | 0 / 2,000 | 0.664 | **0.760** | +0.096 [+0.091, +0.102] | | |
| | CVTG-2K exact image match (%) | 0 / 2,000 | 0.00% | **16.60%** | +16.60 [+15.00, +18.25] | | |
| In the standalone batch-4 writing LoRA evaluation on the same update-240 backbone (`45.11%` overall word accuracy on CVTG-2K; `35.30` on OneIG EN Text), word accuracy by region count is `54.55%` / `50.48%` / `47.44%` / `33.30%` for 2 / 3 / 4 / 5 text regions, and unseen words score `46.45%` vs `50.16%` for seen words (measured at RL update 80). | |
| ### Counting head `k = 1 / 4 / 8 / 16` curve (paired on update-240 backbone) | |
| On held-out counting (200 short prompts on 8 unseen classes, shared 16-candidate seed pool; single-draw accuracy in this batch-1 pool is `52.38%`, compared with `52.00%` in the formal batch-4 backbone run above — `+0.38` pp, 95% CI `[−0.69, +1.44]`, using the same 800 seeds and differing only by batch-1 vs batch-4 generation; times below are medians stitched from the shared 16-candidate curve run, `7.99 s` at `k = 8` vs. `7.97 s` in the dedicated `k = 8` run in [Runtime and hardware](#runtime-and-hardware)): | |
| | Candidates (`k`) | Counting head accuracy | Random `k`-pick | Head − Random [95% CI] | Median NPU time (s/img) | | |
| |---:|---:|---:|---:|---:| | |
| | 1 (single draw) | 52.38% | 52.38% | +0.00 | 5.91 | | |
| | 4 | 64.50% | 49.62% | +14.88 [+11.13, +18.62] | 6.86 | | |
| | **8 (default)** | **67.00%** | 52.62% | **+14.37 [+10.36, +18.39]** | **7.99** | | |
| | 16 | 67.38% | 51.00% | +16.38 [+11.97, +20.78] | 10.25 | | |
| Default `k = 8` gains `+14.63` pp over single draw (`[+10.47, +18.78]`); `k = 16` adds `0.38` pp for ~28% more runtime. On Original GenEval (73/80 triggered counting prompts), the standalone counting-head check (against the formal batch-4 backbone) lifted the counting sub-score from `59.06%` to `72.81%` (`+13.75` pp) on seed 42 and from `64.69%` to `77.19%` (`+12.50` pp) on seed 43, lifting overall scores by `+2.29` pp (`0.834 → 0.857`, `+0.023`) and `+2.08` pp (`0.848 → 0.869`, `+0.021`) — one-sixth of each counting gain (in the all-batch-1 whole-model table above, whole − same-batch backbone is `+2.08` / `+2.03` / `+2.06` pp across seed 42 / seed 43 / two batches). On 15 falsely triggered non-counting PixelGen-rephrased GenEval prompts, accuracy is `92.50%` vs `91.67%` single draw (`+0.83` pp, `[−0.80, +2.47]`). | |
| ## Training | |
| All stages ran on Huawei Ascend 910B NPUs starting from `Haidass-Image-Base-v1_0.6B_512px` (`60463`): | |
| | Stage | Data | Key hyperparameters | | |
| |---|---|---| | |
| | 1. Cleaned retrain (`v4`) | 289,726 rows (two cleaning scans, zero eval hits; 8 held-out classes removed; BLIP3o-60K with 7,190 near-duplicates removed); mix 70% public & compositional / 15% counting / 15% position & color binding | 16 NPUs, global batch 1,024, 2,500 steps; peak LR `5e-5`, 100-step warmup, cosine decay to 10%, weight decay `0.01`, EMA `0.998`; timesteps 90% logit-normal (mean `ln 2`) + 10% uniform; fixed caption-dropout hashing | | |
| | 2. Flow-GRPO RL (`CFG1` update 240) | 3,600-prompt bank across 6 GenEval skills (zero exact prompt-attribute combination overlap with PixelGen-rephrased GenEval; a later check found 231 RL prompts share object-class pairs with 59 evaluation prompts, and with those 59 removed, update 80 was still `+1.99` overall and `+3.62` on position; 8 held-out classes excluded); Mask2Former + CLIP ViT-L/14 partial-credit reward | Started from `v4` EMA; Flow-Factory GRPO + CPS (10 steps, noise `0.8`, backprop 3 of first 5 steps); 1 update/epoch, 32 groups × 18 = 576 images/update (8 NPUs); rollout CFG `1.0`; AdamW LR `3e-4`, WD `1e-4`, grad clip `1.0`, ratio clip `±1e-4`, adv clip `±5`, v-based KL `0.001`; LoRA `r = 32 / alpha = 64` (FP32 LoRA/AdamW/EMA, BF16 forward), EMA `0.99` every 4 epochs; stopped at 334, merged EMA at update `240` | | |
| | 3. Writing LoRA v4 | 6 OCR block-filtered sources (line-merged then block-grouped, 200-image blind visual pass per source; 82% flat synthetic layouts) with letter-by-letter spelling captions | Frozen backbone (trained from RL update 80, verified on update 240); PEFT `r = 128`, `alpha = 256`, LR `3e-4`, 4,500 steps cosine, EMA weights; LR and data mix tuned once on CVTG-2K after an initial `1e-4` run | | |
| | 4. Counting head | 25,448 images (~58 classes, 3 prompt styles, 7-way dedup zero hits, 8 held-out classes excluded); count labels from Qwen2.5-VL (99% agreement on blind visual check) | Step-5, layer-25 4 × 4 pooled features; 2-layer MLP (hidden `64`, L2 `α = 1e-3`, Adam, batch `128`, LR `0.001`, max_iter `60`), float64 scoring with deterministic seed-based tie-breaking | | |
| ## How post-training was run by agents | |
| The 0.1.0 post-training pipeline (`v4` cleaned retrain → Flow-GRPO → writing LoRA v4 → counting head) was planned, executed, and audited by a manager agent and executor agents running on 8 Atlas A2 servers (64 × Ascend 910B NPUs). Each stage used pre-registered pass/fail thresholds with paired 95% confidence intervals, an Experience Board recording both successful and discarded runs, an independent automated review of briefs and results, and blind visual checks with a multimodal vision-language model on training data samples and flipped evaluation pairs. | |
| Key empirical findings along the 0.1.0 path: (1) sentence-level cleaning paired with fixed warmup/cosine/weight-decay/EMA training lifted base PixelGen-rephrased GenEval from `67.05` to `83.17` and held-out composition from `59.00` to `81.56`; (2) switching Flow-GRPO to 1 optimizer update per epoch with FP32 LoRA/EMA states resolved policy-ratio clipping bias and yielded steady gains to update 240 (`85.73` PixelGen-rephrased GenEval, `84.60` DPG); (3) block-level OCR filtering with letter-spelled prompts lifted CVTG-2K word accuracy from `0.22%` to `45.08%`; and (4) training the counting head to predict exact object count classes (`0–6`, `7+`) rather than binary pass/fail raised held-out counting from `52.38%` to `67.00%`. | |
| ## Inference | |
| Default inference runs the whole 0.1.0 model automatically per prompt: | |
| 1. **Writing route** (quoted display text, generally with a same-sentence carrier word): activates `writing_lora/`, appends letter-by-letter spelling (e.g., `"OPEN LATE" (spelled: O P E N / L A T E)`), and runs 50 Euler steps. Prompts exceeding 256 tokens after spelling annotation emit a warning and record `truncated: true`. | |
| 2. **Counting route** (one unambiguous parsed object count at 50 steps, when the writing route does not fire): runs 8 initial noises for 5 of the 50 steps; `counting_head/head.npz` reads step-5 intermediate features (layer 25, 4 × 4 pooled) and predicts how many objects each candidate would end with (classes `0–6` and `7+`); the candidate with the highest `log P(count = N)` continues to step 50. Non-50 step counts emit a notice and fall back to a single draw. | |
| 3. **Backbone route** (all other prompts): runs 1 initial noise for 50 Euler steps on the backbone. | |
| ### Default sampling settings and repository layout | |
| | Setting | Default | Repository file | Purpose | | |
| |---|---|---|---| | |
| | Resolution | 512 × 512 | `dit.safetensors` | Generation backbone weights (FP32, merged EMA) | | |
| | Sampler & steps | Euler, 50 steps | `writing_lora/` | Writing LoRA weights (EMA FP32) and PEFT config | | |
| | Guidance (CFG) | 8.0 (`cfg_norm = none`) | `counting_head/` | Counting head weights (`head.npz`) and parser/ranker | | |
| | Timestep shift | 1.0 | `vae/` | Qwen-Image-2.1 VAE weights and config | | |
| | Unconditional prompt | EOS token | `config.json`, `runtime/` | Model, sampling, and routing configuration and code | | |
| | Precision | BF16 autocast; FP32 latents | `inference.py`, `requirements.txt`, `SHA256SUMS` | CLI / Python entry point, dependencies, and checksums | | |
| Repository download size: **4.15 GB** (3.86 GiB: DiT `2.39 GB`, VAE `1.35 GB`, writing LoRA `401 MB`, counting head `5.02 MB`). Text encoder [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) downloads about **1.52 GB** (1.41 GiB) automatically on first use, or can be supplied locally via `--text-encoder` (see [Offline use](#offline-use)). | |
| ### Installation and commands | |
| Download this repository (private access requires a Hugging Face token with read permission), open the model directory containing `inference.py` in an activated Python 3.11+ virtual environment, and install dependencies (`--device auto` checks CUDA, Ascend NPU, then CPU, or specify `cpu`, `cuda[:N]`, `npu[:N]`; Ascend requires compatible `torch_npu` and CANN; MPS is untested, so Mac users can select `cpu`): | |
| ```bash | |
| python -m pip install -r requirements.txt | |
| ``` | |
| Run the commands below from the downloaded model directory. Default inference uses `--device auto` and downloads `Qwen/Qwen3-0.6B` automatically on first run. Single-image mode writes (overwrites) the given `--output` PNG path and its matching sidecar JSON (default: `output.png` and `output.json`). Batch `--cases` mode reads a JSON array of objects with `id`, `caption`, and `seed` (plus optional 8-int `candidate_seeds` starting with `seed`, range `0..2,147,483,647`), writes `<output>/<id>/image.png` and `image.json` (default directory: `outputs`), and skips existing images when re-run on the same output directory — only `--cases` skips existing outputs. | |
| Save a 2-row `cases.json` in the model directory for the `--cases` and ablation commands below: | |
| ```json | |
| [ | |
| {"id": "sign", "caption": "A teal enamel sign reading 'OPEN LATE' in a rainy shop window", "seed": 42}, | |
| {"id": "apples", "caption": "A photo of four red apples on a wooden table", "seed": 42} | |
| ] | |
| ``` | |
| #### Bash | |
| ```bash | |
| # Default whole-model inference (ordinary, writing, and counting routes) | |
| python inference.py "A sunlit stone bridge over a calm mountain river" --device auto --seed 42 --output bridge.png | |
| python inference.py "A teal enamel sign reading 'OPEN LATE' in a rainy shop window" --device auto --seed 42 --output sign.png | |
| python inference.py "A photo of four red apples on a wooden table" --device auto --seed 42 --output apples.png | |
| # Batch mode with --cases (re-running the same command resumes and skips finished images) | |
| python inference.py --device auto --cases cases.json --output ./outputs | |
| python inference.py --device auto --cases cases.json --output ./outputs | |
| # Disable individual routes | |
| python inference.py --device auto --cases cases.json --count-head off --output ./out-count-off | |
| python inference.py --device auto --cases cases.json --writing-lora off --output ./out-writing-off | |
| python inference.py --device auto --cases cases.json --routing none --output ./out-routing-none | |
| ``` | |
| #### PowerShell | |
| ```powershell | |
| # Default whole-model inference (ordinary, writing, and counting routes) | |
| python inference.py "A sunlit stone bridge over a calm mountain river" --device auto --seed 42 --output bridge.png | |
| python inference.py "A teal enamel sign reading 'OPEN LATE' in a rainy shop window" --device auto --seed 42 --output sign.png | |
| python inference.py "A photo of four red apples on a wooden table" --device auto --seed 42 --output apples.png | |
| # Batch mode with --cases (re-running the same command resumes and skips finished images) | |
| python inference.py --device auto --cases cases.json --output .\outputs | |
| python inference.py --device auto --cases cases.json --output .\outputs | |
| # Disable individual routes | |
| python inference.py --device auto --cases cases.json --count-head off --output .\out-count-off | |
| python inference.py --device auto --cases cases.json --writing-lora off --output .\out-writing-off | |
| python inference.py --device auto --cases cases.json --routing none --output .\out-routing-none | |
| ``` | |
| #### Python API | |
| `generate` returns `(PIL.Image, dict)`; `generate_batch` returns a list of PIL images by default, or `(PIL.Image, dict)` tuples when `return_records=True`: | |
| ```python | |
| from inference import Generator | |
| model = Generator(device="auto") # downloads Qwen/Qwen3-0.6B on first use | |
| writing_image, writing_info = model.generate( | |
| 'A teal enamel sign reading "OPEN LATE" in a rainy shop window', | |
| seed=42, | |
| ) | |
| writing_image.save("sign.png") | |
| outputs = model.generate_batch( | |
| [ | |
| "A sunlit stone bridge over a calm mountain river", | |
| "A photo of four red apples on a wooden table", | |
| ], | |
| [42, 43], | |
| return_records=True, | |
| ) | |
| for name, (image, info) in zip(["bridge.png", "apples.png"], outputs): | |
| image.save(name) | |
| ``` | |
| #### Offline use | |
| Download this repository and `Qwen/Qwen3-0.6B` beforehand, set `HF_HUB_OFFLINE=1` (or point `HF_HOME` to a pre-populated Hugging Face cache), and pass `--text-encoder` pointing to the local `Qwen3-0.6B` directory (or `Generator(device="auto", text_encoder="<local dir>")` in Python): | |
| ```bash | |
| export HF_HUB_OFFLINE=1 | |
| python inference.py "A sunlit stone bridge over a calm mountain river" --device auto --text-encoder /path/to/Qwen3-0.6B --seed 42 --output bridge.png | |
| ``` | |
| ```powershell | |
| $env:HF_HUB_OFFLINE = '1' | |
| python inference.py "A sunlit stone bridge over a calm mountain river" --device auto --text-encoder .\Qwen3-0.6B --seed 42 --output bridge.png | |
| ``` | |
| ### Runtime and hardware | |
| Per-image Ascend 910B NPU times below are medians from dedicated batch-1 runs on a single NPU (including text encoding, denoising, and VAE decoding; the `7.97 s` counting time is from the dedicated `k = 8` run, while the `k = 1 / 4 / 8 / 16` curve above reports `7.99 s` from its stitched 16-candidate run; the first writing image in a process also includes a one-time LoRA load of about 4–5 s): | |
| | Route | Ascend 910B NPU (median / image) | | |
| |---|---:| | |
| | Backbone (1 × 50 steps) | 5.91 s | | |
| | Writing (LoRA + 1 × 50 steps) | 9.06 s | | |
| | Counting (8 × 5 steps + 1 × 45 steps) | 7.97 s | | |
| CPU and CUDA run the same code; their speed was not measured. Because Ascend NPU, CUDA, and CPU use different initial-noise generators, the same `--seed` produces different images across devices. | |
| ## Version history (full notes) | |
| - **0.1.0 (2026-11):** Final release. Retrained from `Haidass-Image-Base-v1_0.6B_512px` on sentence-level cleaned data (v4, two scans with zero evaluation hits), followed by Flow-GRPO reinforcement learning (CFG1 branch, update 240, merged EMA, selected by pre-registered rule), integrated with writing LoRA v4 (EMA) and the counting head under unified default routing. Weights are stored in FP32 (`dit.safetensors`). | |
| - **0.0.1 (preview, git tag `v0.0.1`):** Initial preview release (earlier post-trained raw weights trained on uncleaned data + writing LoRA v3). Archived at tag `v0.0.1`; its training data overlapped evaluation prompts, and its scores are retired in favor of 0.1.0. | |