Linarix-v2 / README.md
akrao9's picture
Update README.md
149e08b verified
|
Raw History Blame Contribute Delete
4.55 kB
---
license: other
library_name: diffusers
pipeline_tag: text-to-image
tags:
- text-to-image
- diffusion
- flow-matching
- linear-attention
- boomer
---
# Linarix-v2 Text-to-Image Diffusion Model
## Usage
> **Requires `diffusers >= 0.38.0`** — earlier versions have a `trust_remote_code` RCE
> ([advisory](https://github.com/huggingface/diffusers/security/advisories/GHSA-98h9-4798-4q5v)).
> For production, pin a commit hash with `revision=` so the remote code cannot change
> under you.
### Install
```bash
pip install -U "diffusers>=0.38.0" transformers accelerate safetensors torchvision scipy
pip install "flash-linear-attention @ git+https://github.com/fla-org/flash-linear-attention.git@3c4c54ae7397d37130d7101edd0f4eb596af896d"
```
FLA is **required**, not optional:Image attention runs on PyTorch SDPA by design — `flash-attn` is not used and
installing it changes nothing. The STORK scheduler is bundled with this repo no separate install.
### Generate
```python
import torch
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(
"Akrao9/Linarix-v2",
custom_pipeline="pipeline_boomer",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
).to("cuda")
image = pipe("a lighthouse on a rocky cliff above crashing waves at golden hour")[0]
image.save("output.png")
```
Every sampler setting defaults to the value this model was tuned and showcased at
(STORK4, 20 steps, `cfg_scale=4.0`,
`flow_shift=5.0`), so passing nothing reproduces the grid above. Override
only what you want to change:
```python
image = pipe(
"a quiet cobblestone street in an old European town, evening",
seed=42, # None (default) draws a fresh seed each call
cfg_scale=3.0, # lower = softer, less saturated; raise for prompt adherence
steps=32, # more steps buy little past the default
)[0]
```
The transformer weights come from this repo. The DC-AE VAE and `Qwen/Qwen3.5-4B` text
encoder are fetched from their upstream repos on first use — run `hf auth login` first
if this repo is gated for you.
### Batched inference
Pass a list of prompts to generate a batch in one call:
```python
images = pipe([
"a lighthouse above crashing waves",
"a red fox in fresh snow",
"a steam locomotive on a stone bridge",
])
images[0].save("a.png")
```
Two things matter for throughput. **VAE slicing is on by default**, decoding one image
at a time so batched-decode peak memory stays flat; toggle with
`pipe.disable_vae_slicing()`, or add `pipe.enable_vae_tiling()` for large images on low
VRAM (both work before the VAE is lazily loaded). And **keep components resident** on
the GPU when benchmarking — the default `offload_text_encoder=True` moves the text
encoder to CPU after each call, which is the right trade for VRAM but adds per-call
transfer overhead that dominates small batches.
## Samples
![Linarix-v2 samples](showcase.png)
All 1024px, EMA weights, STORK4 / 20 steps,
`derivative_order=1`, `substeps=14`,
`cfg_scale=4.0`, `cfg_rescale=0.5`,
`cfg_interval=[0.1, 0.9]`, and
`flow_shift=5.0`. Prompts (left→right, top→bottom):
1. a snow-covered mountain village at blue hour, warm windows glowing
2. a desert canyon at sunset, layered red rock walls
3. a wooden pier stretching into a misty lake at dawn
4. a stone castle on a green hilltop under drifting clouds
5. an elderly fisherman mending nets on a harbour wall
6. a ginger cat asleep on a sunlit windowsill
7. a vintage motorcycle parked on a rain-slicked city street at night
8. a field of sunflowers under a bright summer sky
9. a narrow canal in Venice with weathered facades, late afternoon
10. a steaming bowl of ramen on a dark wooden table
11. a great horned owl perched on a bare branch at dusk
12. a glass greenhouse full of ferns, soft diffused light
<!-- ## Licensing
The weights are released under a custom license; the terms are not finalised, so no
open-source license is asserted here. Treat the tag as "all rights reserved pending the
published terms" and ask before relying on these weights in anything you ship.
The runtime code bundled in this repo (`pipeline_boomer.py`, `modeling_boomer_fla.py`,
`qwen_connector.py`) is covered by the same pending terms. `STORKScheduler.py` and
`STORK_constants/` are third-party (Tan et al. 2025, arXiv:2505.24210) and keep their
own upstream license.
The text encoder (`Qwen/Qwen3.5-4B`) and the VAE (`mit-han-lab/dc-ae-f32c32-sana-1.1-diffusers`) are separate
downloads under their own licenses; nothing here relicenses them. -->