File size: 5,049 Bytes
c7626bd
 
 
4356381
c7626bd
 
 
 
 
 
4356381
 
 
c7626bd
 
 
 
c836618
c7626bd
c836618
c7626bd
c836618
c7626bd
c836618
 
c7626bd
c836618
c7626bd
c836618
c7626bd
c836618
 
 
 
c7626bd
c836618
 
4356381
 
 
 
c5fe00d
4356381
c836618
 
c5fe00d
c836618
c5fe00d
 
 
 
 
c836618
c5fe00d
c836618
 
c7626bd
 
 
 
 
c836618
 
 
c7626bd
c836618
 
c5fe00d
c836618
c7626bd
c5fe00d
 
c7626bd
c5fe00d
c836618
 
c7626bd
 
 
 
c836618
 
c5fe00d
c7626bd
 
c836618
 
 
 
 
 
 
 
 
 
 
 
c5fe00d
c836618
c7626bd
c5fe00d
c836618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7626bd
c836618
c7626bd
c5fe00d
c836618
 
c7626bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
license: mit
library_name: diffusers
pipeline_tag: text-to-image
tags:
  - diffusers
  - image-generation
  - class-conditional
  - imagenet
  - pixnerd
widget:
  - output:
      url: PixNerd-XL-16-512/demo.png
language:
  - en
---

# BiliSakura/PixNerd-diffusers

Self-contained PixNerd-XL/16 checkpoints for Hugging Face diffusers. **No external code repo is required** β€” each subfolder ships its own `pipeline.py`, component modules, and weights.

This repo is derived from the development bundle in [Visual-Generative-Foundation-Model-Collection](https://github.com/Bili-Sakura/Visual-Generative-Foundation-Model-Collection), but inference only needs:

- This model repo (`BiliSakura/PixNerd-diffusers`)
- PyPI `diffusers`, `torch`, `huggingface_hub`

This Hugging Face repo hosts **multiple self-contained checkpoints as subfolders**. Each subfolder includes its own `pipeline.py`, `model_index.json`, weights, and component code (`transformer/`, `scheduler/`).

## Available checkpoints

| Subfolder | Resolution | Source checkpoint |
| --- | --- | --- |
| [`PixNerd-XL-16-256/`](PixNerd-XL-16-256/) | 256Γ—256 | `epoch%3D319-step%3D1600000_emainit.ckpt` |
| [`PixNerd-XL-16-512/`](PixNerd-XL-16-512/) | 512Γ—512 | `res512_ft200k_epoch%3D325-step%3D1800000_emainit.ckpt` |

Both checkpoints are ImageNet class-conditional PixNerd-XL/16 exports with flow-matching sampling.

## Demo

![PixNerd-XL-16-512 demo](PixNerd-XL-16-512/demo.png)

Class 207 β€” golden retriever, 512Γ—512, 25 steps.

## ImageNet class labels

Each variant keeps an English `id2label` map directly in its own `model_index.json` (DiT-style).

- `pipe.id2label` β€” inspect id β†’ English label correspondence
- `pipe.labels` β€” reverse maps (English synonym β†’ id), sorted for browsing
- `pipe.get_label_ids("golden retriever")`
- `pipe(class_labels="golden retriever", ...)` β€” string labels resolved automatically
- `pipe(prompt="golden retriever", ...)` β€” deprecated alias for `class_labels`

Chinese labels are preserved in the main source repo under `src/labels/id2label_cn.json` for reference.

## Load from Hugging Face

```python
import torch
from diffusers import DiffusionPipeline

variant = "PixNerd-XL-16-256"  # or PixNerd-XL-16-512
resolution = 256 if variant.endswith("256") else 512

pipe = DiffusionPipeline.from_pretrained(
    f"BiliSakura/PixNerd-diffusers/{variant}",
    trust_remote_code=True,
    torch_dtype=torch.bfloat16,
).to("cuda")

# Scheduler defaults: timeshift=3.0, order=2 (see scheduler/scheduler_config.json)

images = pipe(
    class_labels="golden retriever",
    height=resolution,
    width=resolution,
    num_inference_steps=25,
    guidance_scale=4.0,
).images

print(pipe.id2label[207])          # "golden retriever"
pipe.get_label_ids("golden retriever")  # [207]
images = pipe(class_labels="golden retriever", height=resolution, width=resolution).images
```

## Load from a local clone

```python
import torch
from diffusers import DiffusionPipeline

repo = "models/BiliSakura/PixNerd-diffusers"
variant = "PixNerd-XL-16-256"

pipe = DiffusionPipeline.from_pretrained(
    f"{repo}/{variant}",
    trust_remote_code=True,
    torch_dtype=torch.bfloat16,
).to("cuda")

images = pipe(class_labels="golden retriever", height=256, width=256).images
```

## Repo layout

```text
BiliSakura/PixNerd-diffusers/
β”œβ”€β”€ README.md
β”œβ”€β”€ PixNerd-XL-16-256/
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ pipeline.py
β”‚   β”œβ”€β”€ model_index.json
β”‚   β”œβ”€β”€ conversion_metadata.json
β”‚   β”œβ”€β”€ transformer/
β”‚   └── scheduler/
└── PixNerd-XL-16-512/
    β”œβ”€β”€ README.md
    β”œβ”€β”€ pipeline.py
    β”œβ”€β”€ model_index.json
    β”œβ”€β”€ conversion_metadata.json
    β”œβ”€β”€ transformer/
    └── scheduler/
```

## Interface notes

- The pipeline uses `class_labels` for ImageNet class conditioning (`prompt` remains a deprecated alias).
- Pass integer ImageNet ids (`prompt=207`) or human-readable synonyms (`prompt="golden retriever"`).
- `height` and `width` should match checkpoint intent (256 or 512), but custom sizes work if divisible by patch size (16).
- Architecture and conversion provenance are recorded in each checkpoint's `conversion_metadata.json`.

## Limitations

- Intended for ImageNet class-conditional generation.
- No text encoder is included.
- Output quality depends on scheduler settings and inference step count.

## Citation

Source paper (ICLR 2026):

- [PixNerd: Pixel Neural Field Diffusion](http://arxiv.org/abs/2507.23268)
- [Hugging Face Papers page](https://huggingface.co/papers/2507.23268)

Source code:

- Original PixNerd codebase: [MCG-NJU/PixNerd](https://github.com/MCG-NJU/PixNerd)
- Diffusers conversion code used for this export: [Bili-Sakura/PixNerd-diffusers](https://github.com/Bili-Sakura/PixNerd-diffusers)

```bibtex
@article{2507.23268,
  Author = {Shuai Wang and Ziteng Gao and Chenhui Zhu and Weilin Huang and Limin Wang},
  Title = {PixNerd: Pixel Neural Field Diffusion},
  Year = {2025},
  Eprint = {arXiv:2507.23268},
}
```