BiliSakura commited on
Commit
2d67f83
·
verified ·
1 Parent(s): 062bc3d

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ GAT-XL-2-256/demo.png filter=lfs diff=lfs merge=lfs -text
37
+ GAT-XL-2-256/demo_bf16.png filter=lfs diff=lfs merge=lfs -text
GAT-XL-2-256/demo.png ADDED

Git LFS Details

  • SHA256: 139ad980174ea9e6e52437a8974cfdee9b46cbc0481ef9d1264f3b488e4e01e9
  • Pointer size: 131 Bytes
  • Size of remote file: 105 kB
GAT-XL-2-256/demo_bf16.png ADDED

Git LFS Details

  • SHA256: 5bd7e2c6e622511035cf6dd010247debcda404e3cd56099f62beebbd79daaccb
  • Pointer size: 131 Bytes
  • Size of remote file: 105 kB
GAT-XL-2-256/generator/config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "GATGenerator",
3
+ "_diffusers_version": "0.38.0",
4
+ "class_dropout_prob": 0.0,
5
+ "depth": 28,
6
+ "fused_attn": true,
7
+ "hidden_size": 1152,
8
+ "in_channels": 4,
9
+ "input_size": 32,
10
+ "latent_size": 64,
11
+ "mlp_ratio": 4.0,
12
+ "num_classes": 1000,
13
+ "num_heads": 16,
14
+ "patch_size": 2,
15
+ "projector_dim": 2048,
16
+ "qk_norm": true,
17
+ "z_dims": [
18
+ 768
19
+ ]
20
+ }
GAT-XL-2-256/generator/diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:685b233351d3a1b28b6851394bd67d877eef5295fa1387480041239b4aed8e21
3
+ size 2413796224
GAT-XL-2-256/generator/modeling_gat.py ADDED
@@ -0,0 +1,503 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Hub custom module: GATGenerator for Generative Adversarial Transformers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from math import pi
7
+ from typing import Optional, Type
8
+
9
+ import numpy as np
10
+ import torch
11
+ import torch.nn as nn
12
+ import torch.nn.functional as F
13
+ from diffusers.configuration_utils import ConfigMixin, register_to_config
14
+ from diffusers.models.modeling_utils import ModelMixin
15
+ from diffusers.utils import BaseOutput
16
+ from einops import rearrange, repeat
17
+ from timm.models.vision_transformer import Mlp, PatchEmbed
18
+
19
+ class EqualLinear(nn.Module):
20
+ def __init__(self, in_dim, out_dim, bias=True, bias_init=0, lr_mult=1):
21
+ super().__init__()
22
+ self.weight = nn.Parameter(torch.zeros(out_dim, in_dim))
23
+ if bias:
24
+ self.bias = nn.Parameter(torch.zeros(out_dim).fill_(bias_init))
25
+ else:
26
+ self.register_parameter("bias", None)
27
+ self.lr_mult = lr_mult
28
+ self.init_weight(lr_mult=lr_mult)
29
+
30
+ def init_weight(self, lr_mult):
31
+ nn.init.xavier_uniform_(self.weight, gain=1 / lr_mult)
32
+ if self.bias is not None:
33
+ nn.init.constant_(self.bias, 0)
34
+
35
+ def forward(self, x):
36
+ bias = self.bias * self.lr_mult if self.bias is not None else None
37
+ return torch.nn.functional.linear(x, self.weight * self.lr_mult, bias=bias)
38
+
39
+
40
+ class Attention(nn.Module):
41
+ def __init__(
42
+ self,
43
+ dim: int,
44
+ num_heads: int = 8,
45
+ qkv_bias: bool = False,
46
+ qk_norm: bool = False,
47
+ proj_bias: bool = True,
48
+ attn_drop: float = 0.0,
49
+ proj_drop: float = 0.0,
50
+ norm_layer: Type[nn.Module] = nn.RMSNorm,
51
+ fused_attn: bool = False,
52
+ ) -> None:
53
+ super().__init__()
54
+ assert dim % num_heads == 0
55
+ self.num_heads = num_heads
56
+ self.head_dim = dim // num_heads
57
+ self.scale = self.head_dim ** -0.5
58
+ self.fused_attn = fused_attn
59
+
60
+ self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
61
+ self.q_norm = norm_layer(self.head_dim) if qk_norm else nn.Identity()
62
+ self.k_norm = norm_layer(self.head_dim) if qk_norm else nn.Identity()
63
+ self.attn_drop = nn.Dropout(attn_drop)
64
+ self.proj = nn.Linear(dim, dim, bias=proj_bias)
65
+ self.proj_drop = nn.Dropout(proj_drop)
66
+
67
+ def forward(self, x, rope=None, return_attention=False):
68
+ bsz, num_tokens, channels = x.shape
69
+ qkv = self.qkv(x).reshape(bsz, num_tokens, 3, self.num_heads, self.head_dim)
70
+ q, k, v = qkv.permute(2, 0, 3, 1, 4).unbind(0)
71
+
72
+ q = self.q_norm(q)
73
+ k = self.k_norm(k)
74
+ if rope is not None:
75
+ q = rope(q)
76
+ k = rope(k)
77
+
78
+ if self.fused_attn and not return_attention:
79
+ x = torch.nn.functional.scaled_dot_product_attention(
80
+ q,
81
+ k,
82
+ v,
83
+ dropout_p=self.attn_drop.p if self.training else 0.0,
84
+ )
85
+ attn = None
86
+ else:
87
+ attn = (q * self.scale) @ k.transpose(-2, -1)
88
+ attn = self.attn_drop(attn.softmax(dim=-1))
89
+ x = attn @ v
90
+
91
+ x = x.transpose(1, 2).reshape(bsz, num_tokens, channels)
92
+ x = self.proj_drop(self.proj(x))
93
+ if return_attention:
94
+ return x, attn
95
+ return x
96
+
97
+
98
+ class FourierFeature(nn.Module):
99
+ def __init__(self, hidden_size, resolution=16):
100
+ super().__init__()
101
+ self.linear = nn.Linear(2, hidden_size)
102
+ y = torch.linspace(-1, 1, steps=resolution)
103
+ x = torch.linspace(-1, 1, steps=resolution)
104
+ yy, xx = torch.meshgrid(y, x, indexing="ij")
105
+ coords = torch.stack([xx, yy], dim=-1).view(1, resolution * resolution, 2)
106
+ self.register_buffer("coords", coords)
107
+
108
+ def reset_parameters(self):
109
+ nn.init.uniform_(self.linear.weight, -np.sqrt(9 / 2), np.sqrt(9 / 2))
110
+
111
+ def forward(self, x):
112
+ return torch.sin(self.linear(self.coords.to(x.dtype))).repeat(x.shape[0], 1, 1)
113
+
114
+
115
+ class SwiGLUFFN(nn.Module):
116
+ def __init__(self, in_features: int, hidden_features: int | None = None, out_features: int | None = None, bias: bool = True):
117
+ super().__init__()
118
+ out_features = out_features or in_features
119
+ hidden_features = hidden_features or in_features
120
+ self.w12 = nn.Linear(in_features, 2 * hidden_features, bias=bias)
121
+ self.w3 = nn.Linear(hidden_features, out_features, bias=bias)
122
+
123
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
124
+ x12 = self.w12(x)
125
+ x1, x2 = x12.chunk(2, dim=-1)
126
+ hidden = F.silu(x1) * x2
127
+ return self.w3(hidden)
128
+
129
+
130
+ def broadcat(tensors, dim=-1):
131
+ num_tensors = len(tensors)
132
+ shape_lens = set(list(map(lambda t: len(t.shape), tensors)))
133
+ assert len(shape_lens) == 1, "tensors must all have the same number of dimensions"
134
+ shape_len = list(shape_lens)[0]
135
+ dim = (dim + shape_len) if dim < 0 else dim
136
+ dims = list(zip(*map(lambda t: list(t.shape), tensors)))
137
+ expandable_dims = [(i, val) for i, val in enumerate(dims) if i != dim]
138
+ assert all([*map(lambda t: len(set(t[1])) <= 2, expandable_dims)]), "invalid dimensions for broadcastable concatentation"
139
+ max_dims = list(map(lambda t: (t[0], max(t[1])), expandable_dims))
140
+ expanded_dims = list(map(lambda t: (t[0], (t[1],) * num_tensors), max_dims))
141
+ expanded_dims.insert(dim, (dim, dims[dim]))
142
+ expandable_shapes = list(zip(*map(lambda t: t[1], expanded_dims)))
143
+ tensors = list(map(lambda t: t[0].expand(*t[1]), zip(tensors, expandable_shapes)))
144
+ return torch.cat(tensors, dim=dim)
145
+
146
+
147
+ def rotate_half(x):
148
+ x = rearrange(x, "... (d r) -> ... d r", r=2)
149
+ x1, x2 = x.unbind(dim=-1)
150
+ x = torch.stack((-x2, x1), dim=-1)
151
+ return rearrange(x, "... d r -> ... (d r)")
152
+
153
+
154
+ class VisionRotaryEmbeddingFast(nn.Module):
155
+ def __init__(
156
+ self,
157
+ dim,
158
+ pt_seq_len=16,
159
+ ft_seq_len=None,
160
+ custom_freqs=None,
161
+ freqs_for="lang",
162
+ theta=10000,
163
+ max_freq=10,
164
+ num_freqs=1,
165
+ ):
166
+ super().__init__()
167
+ self.pt_seq_len = pt_seq_len
168
+
169
+ if custom_freqs:
170
+ freqs = custom_freqs
171
+ elif freqs_for == "lang":
172
+ freqs = 1.0 / (theta ** (torch.arange(0, dim, 2)[:(dim // 2)].float() / dim))
173
+ elif freqs_for == "pixel":
174
+ freqs = torch.linspace(1.0, max_freq / 2, dim // 2) * pi
175
+ elif freqs_for == "constant":
176
+ freqs = torch.ones(num_freqs).float()
177
+ else:
178
+ raise ValueError(f"unknown modality {freqs_for}")
179
+
180
+ if ft_seq_len is None:
181
+ ft_seq_len = pt_seq_len
182
+ t = torch.arange(ft_seq_len) / ft_seq_len * pt_seq_len
183
+
184
+ freqs = torch.einsum("..., f -> ... f", t, freqs)
185
+ freqs = repeat(freqs, "... n -> ... (n r)", r=2)
186
+ freqs = broadcat((freqs[:, None, :], freqs[None, :, :]), dim=-1)
187
+
188
+ freqs_cos = freqs.cos().view(-1, freqs.shape[-1])
189
+ freqs_sin = freqs.sin().view(-1, freqs.shape[-1])
190
+
191
+ self.register_buffer("freqs_cos", freqs_cos)
192
+ self.register_buffer("freqs_sin", freqs_sin)
193
+
194
+ def forward(self, t):
195
+ t_spatial = t[:, :, -self.pt_seq_len**2 :]
196
+ t_pe = t_spatial * self.freqs_cos + rotate_half(t_spatial) * self.freqs_sin
197
+ return torch.cat([t[:, :, : -self.pt_seq_len**2], t_pe], dim=2)
198
+
199
+
200
+ def get_2d_sincos_pos_embed(embed_dim, grid_size, cls_token=False, extra_tokens=0):
201
+ grid_h = np.arange(grid_size, dtype=np.float32)
202
+ grid_w = np.arange(grid_size, dtype=np.float32)
203
+ grid = np.meshgrid(grid_w, grid_h)
204
+ grid = np.stack(grid, axis=0)
205
+ grid = grid.reshape([2, 1, grid_size, grid_size])
206
+ pos_embed = get_2d_sincos_pos_embed_from_grid(embed_dim, grid)
207
+ if cls_token and extra_tokens > 0:
208
+ pos_embed = np.concatenate([np.zeros([extra_tokens, embed_dim]), pos_embed], axis=0)
209
+ return pos_embed
210
+
211
+
212
+ def get_2d_sincos_pos_embed_from_grid(embed_dim, grid):
213
+ assert embed_dim % 2 == 0
214
+ emb_h = get_1d_sincos_pos_embed_from_grid(embed_dim // 2, grid[0])
215
+ emb_w = get_1d_sincos_pos_embed_from_grid(embed_dim // 2, grid[1])
216
+ return np.concatenate([emb_h, emb_w], axis=1)
217
+
218
+
219
+ def get_1d_sincos_pos_embed_from_grid(embed_dim, pos):
220
+ assert embed_dim % 2 == 0
221
+ omega = np.arange(embed_dim // 2, dtype=np.float64)
222
+ omega /= embed_dim / 2.0
223
+ omega = 1.0 / 10000**omega
224
+ pos = pos.reshape(-1)
225
+ out = np.einsum("m,d->md", pos, omega)
226
+ emb_sin = np.sin(out)
227
+ emb_cos = np.cos(out)
228
+ return np.concatenate([emb_sin, emb_cos], axis=1)
229
+
230
+
231
+ def normalize_2nd_moment(x, dim=1, eps=1e-8):
232
+ return x * (x.square().mean(dim=dim, keepdim=True) + eps).rsqrt()
233
+
234
+
235
+ def modulate(x, scale, shift=None):
236
+ if shift is None:
237
+ return x * (1 + scale.unsqueeze(1))
238
+ return x * (1 + scale.unsqueeze(1)) + shift.unsqueeze(1)
239
+
240
+
241
+ @dataclass
242
+ class GATGeneratorOutput(BaseOutput):
243
+ sample: torch.Tensor
244
+
245
+
246
+ class _GenLabelEmbedder(nn.Module):
247
+ def __init__(self, num_classes, hidden_size, dropout_prob):
248
+ super().__init__()
249
+ use_cfg_embedding = dropout_prob > 0
250
+ self.embedding_table = nn.Embedding(num_classes + use_cfg_embedding, hidden_size)
251
+ self.num_classes = num_classes
252
+ self.dropout_prob = dropout_prob
253
+
254
+ def forward(self, labels, train):
255
+ return self.embedding_table(labels)
256
+
257
+
258
+ class GATBlock(nn.Module):
259
+ def __init__(self, hidden_size, w_dim, num_heads, mlp_ratio=4.0, **block_kwargs):
260
+ super().__init__()
261
+ self.norm1 = nn.RMSNorm(hidden_size, elementwise_affine=False, eps=1e-6)
262
+ self.attn = Attention(
263
+ hidden_size,
264
+ num_heads=num_heads,
265
+ qkv_bias=True,
266
+ qk_norm=block_kwargs["qk_norm"],
267
+ fused_attn=block_kwargs["fused_attn"],
268
+ )
269
+ self.norm2 = nn.RMSNorm(hidden_size, elementwise_affine=False, eps=1e-6)
270
+ mlp_hidden_dim = int(hidden_size * mlp_ratio)
271
+ approx_gelu = lambda: nn.GELU(approximate="tanh")
272
+ use_swiglu = True
273
+ if use_swiglu:
274
+ self.mlp = SwiGLUFFN(hidden_size, int(2 / 3 * mlp_hidden_dim))
275
+ else:
276
+ self.mlp = Mlp(
277
+ in_features=hidden_size,
278
+ hidden_features=mlp_hidden_dim,
279
+ act_layer=approx_gelu,
280
+ drop=0,
281
+ )
282
+ self.adaLN_modulation = nn.Sequential(
283
+ nn.SiLU(),
284
+ nn.Linear(w_dim, 4 * hidden_size, bias=True),
285
+ )
286
+
287
+ def forward(self, x, c, feat_rope=None):
288
+ scale_msa, gate_msa, scale_mlp, gate_mlp = self.adaLN_modulation(c).chunk(4, dim=1)
289
+ x = x + gate_msa.unsqueeze(1) * self.attn(modulate(self.norm1(x), scale_msa), rope=feat_rope)
290
+ x = x + gate_mlp.unsqueeze(1) * self.mlp(modulate(self.norm2(x), scale_mlp))
291
+ return x
292
+
293
+
294
+ class FinalLayer(nn.Module):
295
+ def __init__(self, hidden_size, w_dim, patch_size, out_channels):
296
+ super().__init__()
297
+ self.norm_final = nn.RMSNorm(hidden_size, elementwise_affine=False, eps=1e-6)
298
+ self.linear = nn.Linear(hidden_size, patch_size * patch_size * out_channels, bias=True)
299
+ self.adaLN_modulation = nn.Sequential(
300
+ nn.SiLU(),
301
+ nn.Linear(w_dim, hidden_size, bias=True),
302
+ )
303
+
304
+ def forward(self, x, c):
305
+ scale = self.adaLN_modulation(c)
306
+ x = modulate(self.norm_final(x), scale)
307
+ return self.linear(x)
308
+
309
+
310
+ class GATGenerator(ModelMixin, ConfigMixin):
311
+ @register_to_config
312
+ def __init__(
313
+ self,
314
+ input_size: int = 32,
315
+ patch_size: int = 2,
316
+ in_channels: int = 4,
317
+ latent_size: int = 64,
318
+ hidden_size: int = 1152,
319
+ depth: int = 28,
320
+ num_heads: int = 16,
321
+ mlp_ratio: float = 4.0,
322
+ class_dropout_prob: float = 0.0,
323
+ num_classes: int = 1000,
324
+ z_dims: Optional[list[int]] = None,
325
+ projector_dim: int = 2048,
326
+ fused_attn: bool = True,
327
+ qk_norm: bool = True,
328
+ ):
329
+ super().__init__()
330
+ z_dims = z_dims or [768]
331
+ block_kwargs = {"fused_attn": fused_attn, "qk_norm": qk_norm}
332
+
333
+ self.input_size = input_size
334
+ self.in_channels = in_channels
335
+ self.out_channels = in_channels
336
+ self.patch_size = patch_size
337
+ self.num_heads = num_heads
338
+ self.num_classes = num_classes
339
+ self.z_dims = z_dims
340
+ self.hidden_size = hidden_size
341
+ self.latent_size = latent_size
342
+ self.depth = depth
343
+ w_dim = self.hidden_size
344
+
345
+ self.x_embedder = PatchEmbed(input_size, patch_size, in_channels, hidden_size, bias=True)
346
+ self.y_embedder = _GenLabelEmbedder(num_classes, latent_size, class_dropout_prob)
347
+ self.num_patches = (input_size // patch_size) ** 2
348
+
349
+ st_resolution = self.input_size // self.patch_size
350
+ self.num_st_patches = st_resolution**2
351
+
352
+ self.use_fourierfeat = False
353
+ if self.use_fourierfeat:
354
+ self.pos_embed = FourierFeature(hidden_size, resolution=st_resolution)
355
+ else:
356
+ self.pos_embed = nn.Parameter(torch.zeros(1, st_resolution**2, hidden_size), requires_grad=False)
357
+
358
+ self.use_rope = True
359
+ if self.use_rope:
360
+ half_head_dim = hidden_size // num_heads // 2
361
+ hw_seq_len = input_size // patch_size
362
+ self.feat_rope = VisionRotaryEmbeddingFast(dim=half_head_dim, pt_seq_len=hw_seq_len)
363
+ else:
364
+ self.feat_rope = None
365
+
366
+ self.latent_embedder = nn.Sequential(
367
+ EqualLinear(latent_size * 2, w_dim, lr_mult=0.01),
368
+ nn.SiLU(),
369
+ EqualLinear(w_dim, w_dim, lr_mult=0.01),
370
+ )
371
+
372
+ rgb_every = self.depth // 4
373
+ self.rgb_indice = [(i + 1) * rgb_every - 1 for i in range(depth // rgb_every)]
374
+
375
+ self.blocks = nn.ModuleList(
376
+ [GATBlock(hidden_size, w_dim, num_heads, mlp_ratio=mlp_ratio, **block_kwargs) for _ in range(depth)]
377
+ )
378
+ self.final_layers = nn.ModuleList(
379
+ [FinalLayer(hidden_size, w_dim, patch_size, self.out_channels) for _ in range(len(self.rgb_indice))]
380
+ )
381
+
382
+ self.initialize_weights()
383
+
384
+ self.w_avg_beta = 0.995
385
+ self.register_buffer("w_avg", torch.zeros([num_classes, w_dim]))
386
+
387
+ def initialize_weights(self):
388
+ def _basic_init(module):
389
+ if isinstance(module, nn.Linear):
390
+ torch.nn.init.xavier_uniform_(module.weight)
391
+ if module.bias is not None:
392
+ nn.init.constant_(module.bias, 0)
393
+ if isinstance(module, nn.Conv2d):
394
+ torch.nn.init.xavier_uniform_(module.weight)
395
+ if module.bias is not None:
396
+ nn.init.constant_(module.bias, 0)
397
+
398
+ self.apply(_basic_init)
399
+
400
+ if self.use_fourierfeat:
401
+ self.pos_embed.reset_parameters()
402
+ else:
403
+ pos_embed = get_2d_sincos_pos_embed(self.pos_embed.shape[-1], int(self.num_st_patches**0.5))
404
+ self.pos_embed.data.copy_(torch.from_numpy(pos_embed).float().unsqueeze(0))
405
+
406
+ nn.init.normal_(self.y_embedder.embedding_table.weight, std=0.02)
407
+
408
+ layer_gain = 1e-1
409
+ for block in self.blocks:
410
+ nn.init.xavier_uniform_(block.adaLN_modulation[-1].weight, gain=layer_gain)
411
+ nn.init.constant_(block.adaLN_modulation[-1].bias, 0)
412
+
413
+ for final_layer in self.final_layers:
414
+ nn.init.xavier_uniform_(final_layer.adaLN_modulation[-1].weight, gain=layer_gain)
415
+ nn.init.constant_(final_layer.adaLN_modulation[-1].bias, 0)
416
+
417
+ if isinstance(self.x_embedder, PatchEmbed):
418
+ w = self.x_embedder.proj.weight.data
419
+ nn.init.xavier_uniform_(w.view([w.shape[0], -1]))
420
+ nn.init.constant_(self.x_embedder.proj.bias, 0)
421
+
422
+ def unpatchify(self, x, patch_size=None):
423
+ c = x.shape[-1] // (self.patch_size**2)
424
+ p = self.patch_size
425
+ h = w = int(x.shape[1] ** 0.5)
426
+ assert h * w == x.shape[1]
427
+ x = x.reshape(shape=(x.shape[0], h, w, p, p, c))
428
+ x = torch.einsum("nhwpqc->nchpwq", x)
429
+ return x.reshape(shape=(x.shape[0], c, h * p, w * p))
430
+
431
+ def ckpt_wrapper(self, module):
432
+ def ckpt_forward(*inputs):
433
+ return module(*inputs)
434
+
435
+ return ckpt_forward
436
+
437
+ def forward(
438
+ self,
439
+ x,
440
+ y,
441
+ z,
442
+ guidance_scale=1.0,
443
+ update_ema=False,
444
+ truncation_psi=0.0,
445
+ multiscale=False,
446
+ return_dict: bool = False,
447
+ ):
448
+ x = self.x_embedder(x) * 0.0 + self.pos_embed(z) if self.use_fourierfeat else self.pos_embed + self.x_embedder(x) * 0.0
449
+
450
+ y_idx = y
451
+ y = self.y_embedder(y, self.training)
452
+ c = torch.cat([normalize_2nd_moment(y.squeeze(1)), normalize_2nd_moment(z)], dim=1)
453
+ c = self.latent_embedder(c)
454
+
455
+ if truncation_psi != 0.0:
456
+ c = c.lerp(self.w_avg[y_idx], truncation_psi)
457
+
458
+ if self.w_avg_beta is not None and update_ema:
459
+ unique_labels = y_idx.unique()
460
+ for label in unique_labels:
461
+ mask = y_idx.squeeze() == label
462
+ avg_c = c[mask].mean(dim=0)
463
+ self.w_avg[label].copy_(avg_c.detach().lerp(self.w_avg[label].to(c.dtype), self.w_avg_beta))
464
+
465
+ if torch.is_tensor(guidance_scale):
466
+ scales = guidance_scale
467
+ else:
468
+ scales = torch.full((y.shape[0],), guidance_scale, device=y.device, dtype=z.dtype)
469
+
470
+ if (scales != 1.0).any():
471
+ indices = torch.arange(self.num_classes).to(y_idx.device)
472
+ y_null = self.y_embedder(indices, self.training)
473
+ y_null = y_null.unsqueeze(0).repeat(z.shape[0], 1, 1)
474
+ z_null = z.unsqueeze(1).repeat(1, self.num_classes, 1)
475
+ w_null = torch.cat([normalize_2nd_moment(y_null), normalize_2nd_moment(z_null)], dim=-1)
476
+ w_null = self.latent_embedder(w_null).detach().mean(dim=1)
477
+ c = w_null + scales.unsqueeze(1) * (c - w_null)
478
+
479
+ xs = []
480
+ for block in self.blocks:
481
+ x = torch.utils.checkpoint.checkpoint(
482
+ self.ckpt_wrapper(block), x, c, self.feat_rope, use_reentrant=False
483
+ )
484
+ xs.append(x)
485
+
486
+ self.recent_x_std = x.std()
487
+
488
+ rgbs = []
489
+ rgb_accum = 0
490
+ for i, final_layer in zip(self.rgb_indice, self.final_layers):
491
+ rgb = final_layer(xs[i], c)
492
+ rgb_accum = rgb_accum + self.unpatchify(rgb)
493
+ rgbs.append(rgb_accum)
494
+
495
+ if multiscale:
496
+ output = torch.stack(rgbs, dim=0)
497
+ else:
498
+ output = rgbs[-1]
499
+
500
+ if not return_dict:
501
+ return (output,)
502
+ return GATGeneratorOutput(sample=output)
503
+
GAT-XL-2-256/model_index.json ADDED
@@ -0,0 +1,1018 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": [
3
+ "pipeline",
4
+ "GATPipeline"
5
+ ],
6
+ "_diffusers_version": "0.38.0",
7
+ "generator": [
8
+ "modeling_gat",
9
+ "GATGenerator"
10
+ ],
11
+ "vae": [
12
+ "diffusers",
13
+ "AutoencoderKL"
14
+ ],
15
+ "truncation_psi": 0.3,
16
+ "id2label": {
17
+ "0": "tench, Tinca tinca",
18
+ "1": "goldfish, Carassius auratus",
19
+ "2": "great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias",
20
+ "3": "tiger shark, Galeocerdo cuvieri",
21
+ "4": "hammerhead, hammerhead shark",
22
+ "5": "electric ray, crampfish, numbfish, torpedo",
23
+ "6": "stingray",
24
+ "7": "cock",
25
+ "8": "hen",
26
+ "9": "ostrich, Struthio camelus",
27
+ "10": "brambling, Fringilla montifringilla",
28
+ "11": "goldfinch, Carduelis carduelis",
29
+ "12": "house finch, linnet, Carpodacus mexicanus",
30
+ "13": "junco, snowbird",
31
+ "14": "indigo bunting, indigo finch, indigo bird, Passerina cyanea",
32
+ "15": "robin, American robin, Turdus migratorius",
33
+ "16": "bulbul",
34
+ "17": "jay",
35
+ "18": "magpie",
36
+ "19": "chickadee",
37
+ "20": "water ouzel, dipper",
38
+ "21": "kite",
39
+ "22": "bald eagle, American eagle, Haliaeetus leucocephalus",
40
+ "23": "vulture",
41
+ "24": "great grey owl, great gray owl, Strix nebulosa",
42
+ "25": "European fire salamander, Salamandra salamandra",
43
+ "26": "common newt, Triturus vulgaris",
44
+ "27": "eft",
45
+ "28": "spotted salamander, Ambystoma maculatum",
46
+ "29": "axolotl, mud puppy, Ambystoma mexicanum",
47
+ "30": "bullfrog, Rana catesbeiana",
48
+ "31": "tree frog, tree-frog",
49
+ "32": "tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui",
50
+ "33": "loggerhead, loggerhead turtle, Caretta caretta",
51
+ "34": "leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea",
52
+ "35": "mud turtle",
53
+ "36": "terrapin",
54
+ "37": "box turtle, box tortoise",
55
+ "38": "banded gecko",
56
+ "39": "common iguana, iguana, Iguana iguana",
57
+ "40": "American chameleon, anole, Anolis carolinensis",
58
+ "41": "whiptail, whiptail lizard",
59
+ "42": "agama",
60
+ "43": "frilled lizard, Chlamydosaurus kingi",
61
+ "44": "alligator lizard",
62
+ "45": "Gila monster, Heloderma suspectum",
63
+ "46": "green lizard, Lacerta viridis",
64
+ "47": "African chameleon, Chamaeleo chamaeleon",
65
+ "48": "Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis",
66
+ "49": "African crocodile, Nile crocodile, Crocodylus niloticus",
67
+ "50": "American alligator, Alligator mississipiensis",
68
+ "51": "triceratops",
69
+ "52": "thunder snake, worm snake, Carphophis amoenus",
70
+ "53": "ringneck snake, ring-necked snake, ring snake",
71
+ "54": "hognose snake, puff adder, sand viper",
72
+ "55": "green snake, grass snake",
73
+ "56": "king snake, kingsnake",
74
+ "57": "garter snake, grass snake",
75
+ "58": "water snake",
76
+ "59": "vine snake",
77
+ "60": "night snake, Hypsiglena torquata",
78
+ "61": "boa constrictor, Constrictor constrictor",
79
+ "62": "rock python, rock snake, Python sebae",
80
+ "63": "Indian cobra, Naja naja",
81
+ "64": "green mamba",
82
+ "65": "sea snake",
83
+ "66": "horned viper, cerastes, sand viper, horned asp, Cerastes cornutus",
84
+ "67": "diamondback, diamondback rattlesnake, Crotalus adamanteus",
85
+ "68": "sidewinder, horned rattlesnake, Crotalus cerastes",
86
+ "69": "trilobite",
87
+ "70": "harvestman, daddy longlegs, Phalangium opilio",
88
+ "71": "scorpion",
89
+ "72": "black and gold garden spider, Argiope aurantia",
90
+ "73": "barn spider, Araneus cavaticus",
91
+ "74": "garden spider, Aranea diademata",
92
+ "75": "black widow, Latrodectus mactans",
93
+ "76": "tarantula",
94
+ "77": "wolf spider, hunting spider",
95
+ "78": "tick",
96
+ "79": "centipede",
97
+ "80": "black grouse",
98
+ "81": "ptarmigan",
99
+ "82": "ruffed grouse, partridge, Bonasa umbellus",
100
+ "83": "prairie chicken, prairie grouse, prairie fowl",
101
+ "84": "peacock",
102
+ "85": "quail",
103
+ "86": "partridge",
104
+ "87": "African grey, African gray, Psittacus erithacus",
105
+ "88": "macaw",
106
+ "89": "sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita",
107
+ "90": "lorikeet",
108
+ "91": "coucal",
109
+ "92": "bee eater",
110
+ "93": "hornbill",
111
+ "94": "hummingbird",
112
+ "95": "jacamar",
113
+ "96": "toucan",
114
+ "97": "drake",
115
+ "98": "red-breasted merganser, Mergus serrator",
116
+ "99": "goose",
117
+ "100": "black swan, Cygnus atratus",
118
+ "101": "tusker",
119
+ "102": "echidna, spiny anteater, anteater",
120
+ "103": "platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus",
121
+ "104": "wallaby, brush kangaroo",
122
+ "105": "koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus",
123
+ "106": "wombat",
124
+ "107": "jellyfish",
125
+ "108": "sea anemone, anemone",
126
+ "109": "brain coral",
127
+ "110": "flatworm, platyhelminth",
128
+ "111": "nematode, nematode worm, roundworm",
129
+ "112": "conch",
130
+ "113": "snail",
131
+ "114": "slug",
132
+ "115": "sea slug, nudibranch",
133
+ "116": "chiton, coat-of-mail shell, sea cradle, polyplacophore",
134
+ "117": "chambered nautilus, pearly nautilus, nautilus",
135
+ "118": "Dungeness crab, Cancer magister",
136
+ "119": "rock crab, Cancer irroratus",
137
+ "120": "fiddler crab",
138
+ "121": "king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica",
139
+ "122": "American lobster, Northern lobster, Maine lobster, Homarus americanus",
140
+ "123": "spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish",
141
+ "124": "crayfish, crawfish, crawdad, crawdaddy",
142
+ "125": "hermit crab",
143
+ "126": "isopod",
144
+ "127": "white stork, Ciconia ciconia",
145
+ "128": "black stork, Ciconia nigra",
146
+ "129": "spoonbill",
147
+ "130": "flamingo",
148
+ "131": "little blue heron, Egretta caerulea",
149
+ "132": "American egret, great white heron, Egretta albus",
150
+ "133": "bittern",
151
+ "134": "crane",
152
+ "135": "limpkin, Aramus pictus",
153
+ "136": "European gallinule, Porphyrio porphyrio",
154
+ "137": "American coot, marsh hen, mud hen, water hen, Fulica americana",
155
+ "138": "bustard",
156
+ "139": "ruddy turnstone, Arenaria interpres",
157
+ "140": "red-backed sandpiper, dunlin, Erolia alpina",
158
+ "141": "redshank, Tringa totanus",
159
+ "142": "dowitcher",
160
+ "143": "oystercatcher, oyster catcher",
161
+ "144": "pelican",
162
+ "145": "king penguin, Aptenodytes patagonica",
163
+ "146": "albatross, mollymawk",
164
+ "147": "grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus",
165
+ "148": "killer whale, killer, orca, grampus, sea wolf, Orcinus orca",
166
+ "149": "dugong, Dugong dugon",
167
+ "150": "sea lion",
168
+ "151": "Chihuahua",
169
+ "152": "Japanese spaniel",
170
+ "153": "Maltese dog, Maltese terrier, Maltese",
171
+ "154": "Pekinese, Pekingese, Peke",
172
+ "155": "Shih-Tzu",
173
+ "156": "Blenheim spaniel",
174
+ "157": "papillon",
175
+ "158": "toy terrier",
176
+ "159": "Rhodesian ridgeback",
177
+ "160": "Afghan hound, Afghan",
178
+ "161": "basset, basset hound",
179
+ "162": "beagle",
180
+ "163": "bloodhound, sleuthhound",
181
+ "164": "bluetick",
182
+ "165": "black-and-tan coonhound",
183
+ "166": "Walker hound, Walker foxhound",
184
+ "167": "English foxhound",
185
+ "168": "redbone",
186
+ "169": "borzoi, Russian wolfhound",
187
+ "170": "Irish wolfhound",
188
+ "171": "Italian greyhound",
189
+ "172": "whippet",
190
+ "173": "Ibizan hound, Ibizan Podenco",
191
+ "174": "Norwegian elkhound, elkhound",
192
+ "175": "otterhound, otter hound",
193
+ "176": "Saluki, gazelle hound",
194
+ "177": "Scottish deerhound, deerhound",
195
+ "178": "Weimaraner",
196
+ "179": "Staffordshire bullterrier, Staffordshire bull terrier",
197
+ "180": "American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier",
198
+ "181": "Bedlington terrier",
199
+ "182": "Border terrier",
200
+ "183": "Kerry blue terrier",
201
+ "184": "Irish terrier",
202
+ "185": "Norfolk terrier",
203
+ "186": "Norwich terrier",
204
+ "187": "Yorkshire terrier",
205
+ "188": "wire-haired fox terrier",
206
+ "189": "Lakeland terrier",
207
+ "190": "Sealyham terrier, Sealyham",
208
+ "191": "Airedale, Airedale terrier",
209
+ "192": "cairn, cairn terrier",
210
+ "193": "Australian terrier",
211
+ "194": "Dandie Dinmont, Dandie Dinmont terrier",
212
+ "195": "Boston bull, Boston terrier",
213
+ "196": "miniature schnauzer",
214
+ "197": "giant schnauzer",
215
+ "198": "standard schnauzer",
216
+ "199": "Scotch terrier, Scottish terrier, Scottie",
217
+ "200": "Tibetan terrier, chrysanthemum dog",
218
+ "201": "silky terrier, Sydney silky",
219
+ "202": "soft-coated wheaten terrier",
220
+ "203": "West Highland white terrier",
221
+ "204": "Lhasa, Lhasa apso",
222
+ "205": "flat-coated retriever",
223
+ "206": "curly-coated retriever",
224
+ "207": "golden retriever",
225
+ "208": "Labrador retriever",
226
+ "209": "Chesapeake Bay retriever",
227
+ "210": "German short-haired pointer",
228
+ "211": "vizsla, Hungarian pointer",
229
+ "212": "English setter",
230
+ "213": "Irish setter, red setter",
231
+ "214": "Gordon setter",
232
+ "215": "Brittany spaniel",
233
+ "216": "clumber, clumber spaniel",
234
+ "217": "English springer, English springer spaniel",
235
+ "218": "Welsh springer spaniel",
236
+ "219": "cocker spaniel, English cocker spaniel, cocker",
237
+ "220": "Sussex spaniel",
238
+ "221": "Irish water spaniel",
239
+ "222": "kuvasz",
240
+ "223": "schipperke",
241
+ "224": "groenendael",
242
+ "225": "malinois",
243
+ "226": "briard",
244
+ "227": "kelpie",
245
+ "228": "komondor",
246
+ "229": "Old English sheepdog, bobtail",
247
+ "230": "Shetland sheepdog, Shetland sheep dog, Shetland",
248
+ "231": "collie",
249
+ "232": "Border collie",
250
+ "233": "Bouvier des Flandres, Bouviers des Flandres",
251
+ "234": "Rottweiler",
252
+ "235": "German shepherd, German shepherd dog, German police dog, alsatian",
253
+ "236": "Doberman, Doberman pinscher",
254
+ "237": "miniature pinscher",
255
+ "238": "Greater Swiss Mountain dog",
256
+ "239": "Bernese mountain dog",
257
+ "240": "Appenzeller",
258
+ "241": "EntleBucher",
259
+ "242": "boxer",
260
+ "243": "bull mastiff",
261
+ "244": "Tibetan mastiff",
262
+ "245": "French bulldog",
263
+ "246": "Great Dane",
264
+ "247": "Saint Bernard, St Bernard",
265
+ "248": "Eskimo dog, husky",
266
+ "249": "malamute, malemute, Alaskan malamute",
267
+ "250": "Siberian husky",
268
+ "251": "dalmatian, coach dog, carriage dog",
269
+ "252": "affenpinscher, monkey pinscher, monkey dog",
270
+ "253": "basenji",
271
+ "254": "pug, pug-dog",
272
+ "255": "Leonberg",
273
+ "256": "Newfoundland, Newfoundland dog",
274
+ "257": "Great Pyrenees",
275
+ "258": "Samoyed, Samoyede",
276
+ "259": "Pomeranian",
277
+ "260": "chow, chow chow",
278
+ "261": "keeshond",
279
+ "262": "Brabancon griffon",
280
+ "263": "Pembroke, Pembroke Welsh corgi",
281
+ "264": "Cardigan, Cardigan Welsh corgi",
282
+ "265": "toy poodle",
283
+ "266": "miniature poodle",
284
+ "267": "standard poodle",
285
+ "268": "Mexican hairless",
286
+ "269": "timber wolf, grey wolf, gray wolf, Canis lupus",
287
+ "270": "white wolf, Arctic wolf, Canis lupus tundrarum",
288
+ "271": "red wolf, maned wolf, Canis rufus, Canis niger",
289
+ "272": "coyote, prairie wolf, brush wolf, Canis latrans",
290
+ "273": "dingo, warrigal, warragal, Canis dingo",
291
+ "274": "dhole, Cuon alpinus",
292
+ "275": "African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus",
293
+ "276": "hyena, hyaena",
294
+ "277": "red fox, Vulpes vulpes",
295
+ "278": "kit fox, Vulpes macrotis",
296
+ "279": "Arctic fox, white fox, Alopex lagopus",
297
+ "280": "grey fox, gray fox, Urocyon cinereoargenteus",
298
+ "281": "tabby, tabby cat",
299
+ "282": "tiger cat",
300
+ "283": "Persian cat",
301
+ "284": "Siamese cat, Siamese",
302
+ "285": "Egyptian cat",
303
+ "286": "cougar, puma, catamount, mountain lion, painter, panther, Felis concolor",
304
+ "287": "lynx, catamount",
305
+ "288": "leopard, Panthera pardus",
306
+ "289": "snow leopard, ounce, Panthera uncia",
307
+ "290": "jaguar, panther, Panthera onca, Felis onca",
308
+ "291": "lion, king of beasts, Panthera leo",
309
+ "292": "tiger, Panthera tigris",
310
+ "293": "cheetah, chetah, Acinonyx jubatus",
311
+ "294": "brown bear, bruin, Ursus arctos",
312
+ "295": "American black bear, black bear, Ursus americanus, Euarctos americanus",
313
+ "296": "ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus",
314
+ "297": "sloth bear, Melursus ursinus, Ursus ursinus",
315
+ "298": "mongoose",
316
+ "299": "meerkat, mierkat",
317
+ "300": "tiger beetle",
318
+ "301": "ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle",
319
+ "302": "ground beetle, carabid beetle",
320
+ "303": "long-horned beetle, longicorn, longicorn beetle",
321
+ "304": "leaf beetle, chrysomelid",
322
+ "305": "dung beetle",
323
+ "306": "rhinoceros beetle",
324
+ "307": "weevil",
325
+ "308": "fly",
326
+ "309": "bee",
327
+ "310": "ant, emmet, pismire",
328
+ "311": "grasshopper, hopper",
329
+ "312": "cricket",
330
+ "313": "walking stick, walkingstick, stick insect",
331
+ "314": "cockroach, roach",
332
+ "315": "mantis, mantid",
333
+ "316": "cicada, cicala",
334
+ "317": "leafhopper",
335
+ "318": "lacewing, lacewing fly",
336
+ "319": "dragonfly, darning needle, devils darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk",
337
+ "320": "damselfly",
338
+ "321": "admiral",
339
+ "322": "ringlet, ringlet butterfly",
340
+ "323": "monarch, monarch butterfly, milkweed butterfly, Danaus plexippus",
341
+ "324": "cabbage butterfly",
342
+ "325": "sulphur butterfly, sulfur butterfly",
343
+ "326": "lycaenid, lycaenid butterfly",
344
+ "327": "starfish, sea star",
345
+ "328": "sea urchin",
346
+ "329": "sea cucumber, holothurian",
347
+ "330": "wood rabbit, cottontail, cottontail rabbit",
348
+ "331": "hare",
349
+ "332": "Angora, Angora rabbit",
350
+ "333": "hamster",
351
+ "334": "porcupine, hedgehog",
352
+ "335": "fox squirrel, eastern fox squirrel, Sciurus niger",
353
+ "336": "marmot",
354
+ "337": "beaver",
355
+ "338": "guinea pig, Cavia cobaya",
356
+ "339": "sorrel",
357
+ "340": "zebra",
358
+ "341": "hog, pig, grunter, squealer, Sus scrofa",
359
+ "342": "wild boar, boar, Sus scrofa",
360
+ "343": "warthog",
361
+ "344": "hippopotamus, hippo, river horse, Hippopotamus amphibius",
362
+ "345": "ox",
363
+ "346": "water buffalo, water ox, Asiatic buffalo, Bubalus bubalis",
364
+ "347": "bison",
365
+ "348": "ram, tup",
366
+ "349": "bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis",
367
+ "350": "ibex, Capra ibex",
368
+ "351": "hartebeest",
369
+ "352": "impala, Aepyceros melampus",
370
+ "353": "gazelle",
371
+ "354": "Arabian camel, dromedary, Camelus dromedarius",
372
+ "355": "llama",
373
+ "356": "weasel",
374
+ "357": "mink",
375
+ "358": "polecat, fitch, foulmart, foumart, Mustela putorius",
376
+ "359": "black-footed ferret, ferret, Mustela nigripes",
377
+ "360": "otter",
378
+ "361": "skunk, polecat, wood pussy",
379
+ "362": "badger",
380
+ "363": "armadillo",
381
+ "364": "three-toed sloth, ai, Bradypus tridactylus",
382
+ "365": "orangutan, orang, orangutang, Pongo pygmaeus",
383
+ "366": "gorilla, Gorilla gorilla",
384
+ "367": "chimpanzee, chimp, Pan troglodytes",
385
+ "368": "gibbon, Hylobates lar",
386
+ "369": "siamang, Hylobates syndactylus, Symphalangus syndactylus",
387
+ "370": "guenon, guenon monkey",
388
+ "371": "patas, hussar monkey, Erythrocebus patas",
389
+ "372": "baboon",
390
+ "373": "macaque",
391
+ "374": "langur",
392
+ "375": "colobus, colobus monkey",
393
+ "376": "proboscis monkey, Nasalis larvatus",
394
+ "377": "marmoset",
395
+ "378": "capuchin, ringtail, Cebus capucinus",
396
+ "379": "howler monkey, howler",
397
+ "380": "titi, titi monkey",
398
+ "381": "spider monkey, Ateles geoffroyi",
399
+ "382": "squirrel monkey, Saimiri sciureus",
400
+ "383": "Madagascar cat, ring-tailed lemur, Lemur catta",
401
+ "384": "indri, indris, Indri indri, Indri brevicaudatus",
402
+ "385": "Indian elephant, Elephas maximus",
403
+ "386": "African elephant, Loxodonta africana",
404
+ "387": "lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens",
405
+ "388": "giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca",
406
+ "389": "barracouta, snoek",
407
+ "390": "eel",
408
+ "391": "coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch",
409
+ "392": "rock beauty, Holocanthus tricolor",
410
+ "393": "anemone fish",
411
+ "394": "sturgeon",
412
+ "395": "gar, garfish, garpike, billfish, Lepisosteus osseus",
413
+ "396": "lionfish",
414
+ "397": "puffer, pufferfish, blowfish, globefish",
415
+ "398": "abacus",
416
+ "399": "abaya",
417
+ "400": "academic gown, academic robe, judge robe",
418
+ "401": "accordion, piano accordion, squeeze box",
419
+ "402": "acoustic guitar",
420
+ "403": "aircraft carrier, carrier, flattop, attack aircraft carrier",
421
+ "404": "airliner",
422
+ "405": "airship, dirigible",
423
+ "406": "altar",
424
+ "407": "ambulance",
425
+ "408": "amphibian, amphibious vehicle",
426
+ "409": "analog clock",
427
+ "410": "apiary, bee house",
428
+ "411": "apron",
429
+ "412": "ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin",
430
+ "413": "assault rifle, assault gun",
431
+ "414": "backpack, back pack, knapsack, packsack, rucksack, haversack",
432
+ "415": "bakery, bakeshop, bakehouse",
433
+ "416": "balance beam, beam",
434
+ "417": "balloon",
435
+ "418": "ballpoint, ballpoint pen, ballpen, Biro",
436
+ "419": "Band Aid",
437
+ "420": "banjo",
438
+ "421": "bannister, banister, balustrade, balusters, handrail",
439
+ "422": "barbell",
440
+ "423": "barber chair",
441
+ "424": "barbershop",
442
+ "425": "barn",
443
+ "426": "barometer",
444
+ "427": "barrel, cask",
445
+ "428": "barrow, garden cart, lawn cart, wheelbarrow",
446
+ "429": "baseball",
447
+ "430": "basketball",
448
+ "431": "bassinet",
449
+ "432": "bassoon",
450
+ "433": "bathing cap, swimming cap",
451
+ "434": "bath towel",
452
+ "435": "bathtub, bathing tub, bath, tub",
453
+ "436": "beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon",
454
+ "437": "beacon, lighthouse, beacon light, pharos",
455
+ "438": "beaker",
456
+ "439": "bearskin, busby, shako",
457
+ "440": "beer bottle",
458
+ "441": "beer glass",
459
+ "442": "bell cote, bell cot",
460
+ "443": "bib",
461
+ "444": "bicycle-built-for-two, tandem bicycle, tandem",
462
+ "445": "bikini, two-piece",
463
+ "446": "binder, ring-binder",
464
+ "447": "binoculars, field glasses, opera glasses",
465
+ "448": "birdhouse",
466
+ "449": "boathouse",
467
+ "450": "bobsled, bobsleigh, bob",
468
+ "451": "bolo tie, bolo, bola tie, bola",
469
+ "452": "bonnet, poke bonnet",
470
+ "453": "bookcase",
471
+ "454": "bookshop, bookstore, bookstall",
472
+ "455": "bottlecap",
473
+ "456": "bow",
474
+ "457": "bow tie, bow-tie, bowtie",
475
+ "458": "brass, memorial tablet, plaque",
476
+ "459": "brassiere, bra, bandeau",
477
+ "460": "breakwater, groin, groyne, mole, bulwark, seawall, jetty",
478
+ "461": "breastplate, aegis, egis",
479
+ "462": "broom",
480
+ "463": "bucket, pail",
481
+ "464": "buckle",
482
+ "465": "bulletproof vest",
483
+ "466": "bullet train, bullet",
484
+ "467": "butcher shop, meat market",
485
+ "468": "cab, hack, taxi, taxicab",
486
+ "469": "caldron, cauldron",
487
+ "470": "candle, taper, wax light",
488
+ "471": "cannon",
489
+ "472": "canoe",
490
+ "473": "can opener, tin opener",
491
+ "474": "cardigan",
492
+ "475": "car mirror",
493
+ "476": "carousel, carrousel, merry-go-round, roundabout, whirligig",
494
+ "477": "carpenters kit, tool kit",
495
+ "478": "carton",
496
+ "479": "car wheel",
497
+ "480": "cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM",
498
+ "481": "cassette",
499
+ "482": "cassette player",
500
+ "483": "castle",
501
+ "484": "catamaran",
502
+ "485": "CD player",
503
+ "486": "cello, violoncello",
504
+ "487": "cellular telephone, cellular phone, cellphone, cell, mobile phone",
505
+ "488": "chain",
506
+ "489": "chainlink fence",
507
+ "490": "chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour",
508
+ "491": "chain saw, chainsaw",
509
+ "492": "chest",
510
+ "493": "chiffonier, commode",
511
+ "494": "chime, bell, gong",
512
+ "495": "china cabinet, china closet",
513
+ "496": "Christmas stocking",
514
+ "497": "church, church building",
515
+ "498": "cinema, movie theater, movie theatre, movie house, picture palace",
516
+ "499": "cleaver, meat cleaver, chopper",
517
+ "500": "cliff dwelling",
518
+ "501": "cloak",
519
+ "502": "clog, geta, patten, sabot",
520
+ "503": "cocktail shaker",
521
+ "504": "coffee mug",
522
+ "505": "coffeepot",
523
+ "506": "coil, spiral, volute, whorl, helix",
524
+ "507": "combination lock",
525
+ "508": "computer keyboard, keypad",
526
+ "509": "confectionery, confectionary, candy store",
527
+ "510": "container ship, containership, container vessel",
528
+ "511": "convertible",
529
+ "512": "corkscrew, bottle screw",
530
+ "513": "cornet, horn, trumpet, trump",
531
+ "514": "cowboy boot",
532
+ "515": "cowboy hat, ten-gallon hat",
533
+ "516": "cradle",
534
+ "517": "crane",
535
+ "518": "crash helmet",
536
+ "519": "crate",
537
+ "520": "crib, cot",
538
+ "521": "Crock Pot",
539
+ "522": "croquet ball",
540
+ "523": "crutch",
541
+ "524": "cuirass",
542
+ "525": "dam, dike, dyke",
543
+ "526": "desk",
544
+ "527": "desktop computer",
545
+ "528": "dial telephone, dial phone",
546
+ "529": "diaper, nappy, napkin",
547
+ "530": "digital clock",
548
+ "531": "digital watch",
549
+ "532": "dining table, board",
550
+ "533": "dishrag, dishcloth",
551
+ "534": "dishwasher, dish washer, dishwashing machine",
552
+ "535": "disk brake, disc brake",
553
+ "536": "dock, dockage, docking facility",
554
+ "537": "dogsled, dog sled, dog sleigh",
555
+ "538": "dome",
556
+ "539": "doormat, welcome mat",
557
+ "540": "drilling platform, offshore rig",
558
+ "541": "drum, membranophone, tympan",
559
+ "542": "drumstick",
560
+ "543": "dumbbell",
561
+ "544": "Dutch oven",
562
+ "545": "electric fan, blower",
563
+ "546": "electric guitar",
564
+ "547": "electric locomotive",
565
+ "548": "entertainment center",
566
+ "549": "envelope",
567
+ "550": "espresso maker",
568
+ "551": "face powder",
569
+ "552": "feather boa, boa",
570
+ "553": "file, file cabinet, filing cabinet",
571
+ "554": "fireboat",
572
+ "555": "fire engine, fire truck",
573
+ "556": "fire screen, fireguard",
574
+ "557": "flagpole, flagstaff",
575
+ "558": "flute, transverse flute",
576
+ "559": "folding chair",
577
+ "560": "football helmet",
578
+ "561": "forklift",
579
+ "562": "fountain",
580
+ "563": "fountain pen",
581
+ "564": "four-poster",
582
+ "565": "freight car",
583
+ "566": "French horn, horn",
584
+ "567": "frying pan, frypan, skillet",
585
+ "568": "fur coat",
586
+ "569": "garbage truck, dustcart",
587
+ "570": "gasmask, respirator, gas helmet",
588
+ "571": "gas pump, gasoline pump, petrol pump, island dispenser",
589
+ "572": "goblet",
590
+ "573": "go-kart",
591
+ "574": "golf ball",
592
+ "575": "golfcart, golf cart",
593
+ "576": "gondola",
594
+ "577": "gong, tam-tam",
595
+ "578": "gown",
596
+ "579": "grand piano, grand",
597
+ "580": "greenhouse, nursery, glasshouse",
598
+ "581": "grille, radiator grille",
599
+ "582": "grocery store, grocery, food market, market",
600
+ "583": "guillotine",
601
+ "584": "hair slide",
602
+ "585": "hair spray",
603
+ "586": "half track",
604
+ "587": "hammer",
605
+ "588": "hamper",
606
+ "589": "hand blower, blow dryer, blow drier, hair dryer, hair drier",
607
+ "590": "hand-held computer, hand-held microcomputer",
608
+ "591": "handkerchief, hankie, hanky, hankey",
609
+ "592": "hard disc, hard disk, fixed disk",
610
+ "593": "harmonica, mouth organ, harp, mouth harp",
611
+ "594": "harp",
612
+ "595": "harvester, reaper",
613
+ "596": "hatchet",
614
+ "597": "holster",
615
+ "598": "home theater, home theatre",
616
+ "599": "honeycomb",
617
+ "600": "hook, claw",
618
+ "601": "hoopskirt, crinoline",
619
+ "602": "horizontal bar, high bar",
620
+ "603": "horse cart, horse-cart",
621
+ "604": "hourglass",
622
+ "605": "iPod",
623
+ "606": "iron, smoothing iron",
624
+ "607": "jack-o-lantern",
625
+ "608": "jean, blue jean, denim",
626
+ "609": "jeep, landrover",
627
+ "610": "jersey, T-shirt, tee shirt",
628
+ "611": "jigsaw puzzle",
629
+ "612": "jinrikisha, ricksha, rickshaw",
630
+ "613": "joystick",
631
+ "614": "kimono",
632
+ "615": "knee pad",
633
+ "616": "knot",
634
+ "617": "lab coat, laboratory coat",
635
+ "618": "ladle",
636
+ "619": "lampshade, lamp shade",
637
+ "620": "laptop, laptop computer",
638
+ "621": "lawn mower, mower",
639
+ "622": "lens cap, lens cover",
640
+ "623": "letter opener, paper knife, paperknife",
641
+ "624": "library",
642
+ "625": "lifeboat",
643
+ "626": "lighter, light, igniter, ignitor",
644
+ "627": "limousine, limo",
645
+ "628": "liner, ocean liner",
646
+ "629": "lipstick, lip rouge",
647
+ "630": "Loafer",
648
+ "631": "lotion",
649
+ "632": "loudspeaker, speaker, speaker unit, loudspeaker system, speaker system",
650
+ "633": "loupe, jewelers loupe",
651
+ "634": "lumbermill, sawmill",
652
+ "635": "magnetic compass",
653
+ "636": "mailbag, postbag",
654
+ "637": "mailbox, letter box",
655
+ "638": "maillot",
656
+ "639": "maillot, tank suit",
657
+ "640": "manhole cover",
658
+ "641": "maraca",
659
+ "642": "marimba, xylophone",
660
+ "643": "mask",
661
+ "644": "matchstick",
662
+ "645": "maypole",
663
+ "646": "maze, labyrinth",
664
+ "647": "measuring cup",
665
+ "648": "medicine chest, medicine cabinet",
666
+ "649": "megalith, megalithic structure",
667
+ "650": "microphone, mike",
668
+ "651": "microwave, microwave oven",
669
+ "652": "military uniform",
670
+ "653": "milk can",
671
+ "654": "minibus",
672
+ "655": "miniskirt, mini",
673
+ "656": "minivan",
674
+ "657": "missile",
675
+ "658": "mitten",
676
+ "659": "mixing bowl",
677
+ "660": "mobile home, manufactured home",
678
+ "661": "Model T",
679
+ "662": "modem",
680
+ "663": "monastery",
681
+ "664": "monitor",
682
+ "665": "moped",
683
+ "666": "mortar",
684
+ "667": "mortarboard",
685
+ "668": "mosque",
686
+ "669": "mosquito net",
687
+ "670": "motor scooter, scooter",
688
+ "671": "mountain bike, all-terrain bike, off-roader",
689
+ "672": "mountain tent",
690
+ "673": "mouse, computer mouse",
691
+ "674": "mousetrap",
692
+ "675": "moving van",
693
+ "676": "muzzle",
694
+ "677": "nail",
695
+ "678": "neck brace",
696
+ "679": "necklace",
697
+ "680": "nipple",
698
+ "681": "notebook, notebook computer",
699
+ "682": "obelisk",
700
+ "683": "oboe, hautboy, hautbois",
701
+ "684": "ocarina, sweet potato",
702
+ "685": "odometer, hodometer, mileometer, milometer",
703
+ "686": "oil filter",
704
+ "687": "organ, pipe organ",
705
+ "688": "oscilloscope, scope, cathode-ray oscilloscope, CRO",
706
+ "689": "overskirt",
707
+ "690": "oxcart",
708
+ "691": "oxygen mask",
709
+ "692": "packet",
710
+ "693": "paddle, boat paddle",
711
+ "694": "paddlewheel, paddle wheel",
712
+ "695": "padlock",
713
+ "696": "paintbrush",
714
+ "697": "pajama, pyjama, pjs, jammies",
715
+ "698": "palace",
716
+ "699": "panpipe, pandean pipe, syrinx",
717
+ "700": "paper towel",
718
+ "701": "parachute, chute",
719
+ "702": "parallel bars, bars",
720
+ "703": "park bench",
721
+ "704": "parking meter",
722
+ "705": "passenger car, coach, carriage",
723
+ "706": "patio, terrace",
724
+ "707": "pay-phone, pay-station",
725
+ "708": "pedestal, plinth, footstall",
726
+ "709": "pencil box, pencil case",
727
+ "710": "pencil sharpener",
728
+ "711": "perfume, essence",
729
+ "712": "Petri dish",
730
+ "713": "photocopier",
731
+ "714": "pick, plectrum, plectron",
732
+ "715": "pickelhaube",
733
+ "716": "picket fence, paling",
734
+ "717": "pickup, pickup truck",
735
+ "718": "pier",
736
+ "719": "piggy bank, penny bank",
737
+ "720": "pill bottle",
738
+ "721": "pillow",
739
+ "722": "ping-pong ball",
740
+ "723": "pinwheel",
741
+ "724": "pirate, pirate ship",
742
+ "725": "pitcher, ewer",
743
+ "726": "plane, carpenters plane, woodworking plane",
744
+ "727": "planetarium",
745
+ "728": "plastic bag",
746
+ "729": "plate rack",
747
+ "730": "plow, plough",
748
+ "731": "plunger, plumbers helper",
749
+ "732": "Polaroid camera, Polaroid Land camera",
750
+ "733": "pole",
751
+ "734": "police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria",
752
+ "735": "poncho",
753
+ "736": "pool table, billiard table, snooker table",
754
+ "737": "pop bottle, soda bottle",
755
+ "738": "pot, flowerpot",
756
+ "739": "potters wheel",
757
+ "740": "power drill",
758
+ "741": "prayer rug, prayer mat",
759
+ "742": "printer",
760
+ "743": "prison, prison house",
761
+ "744": "projectile, missile",
762
+ "745": "projector",
763
+ "746": "puck, hockey puck",
764
+ "747": "punching bag, punch bag, punching ball, punchball",
765
+ "748": "purse",
766
+ "749": "quill, quill pen",
767
+ "750": "quilt, comforter, comfort, puff",
768
+ "751": "racer, race car, racing car",
769
+ "752": "racket, racquet",
770
+ "753": "radiator",
771
+ "754": "radio, wireless",
772
+ "755": "radio telescope, radio reflector",
773
+ "756": "rain barrel",
774
+ "757": "recreational vehicle, RV, R.V.",
775
+ "758": "reel",
776
+ "759": "reflex camera",
777
+ "760": "refrigerator, icebox",
778
+ "761": "remote control, remote",
779
+ "762": "restaurant, eating house, eating place, eatery",
780
+ "763": "revolver, six-gun, six-shooter",
781
+ "764": "rifle",
782
+ "765": "rocking chair, rocker",
783
+ "766": "rotisserie",
784
+ "767": "rubber eraser, rubber, pencil eraser",
785
+ "768": "rugby ball",
786
+ "769": "rule, ruler",
787
+ "770": "running shoe",
788
+ "771": "safe",
789
+ "772": "safety pin",
790
+ "773": "saltshaker, salt shaker",
791
+ "774": "sandal",
792
+ "775": "sarong",
793
+ "776": "sax, saxophone",
794
+ "777": "scabbard",
795
+ "778": "scale, weighing machine",
796
+ "779": "school bus",
797
+ "780": "schooner",
798
+ "781": "scoreboard",
799
+ "782": "screen, CRT screen",
800
+ "783": "screw",
801
+ "784": "screwdriver",
802
+ "785": "seat belt, seatbelt",
803
+ "786": "sewing machine",
804
+ "787": "shield, buckler",
805
+ "788": "shoe shop, shoe-shop, shoe store",
806
+ "789": "shoji",
807
+ "790": "shopping basket",
808
+ "791": "shopping cart",
809
+ "792": "shovel",
810
+ "793": "shower cap",
811
+ "794": "shower curtain",
812
+ "795": "ski",
813
+ "796": "ski mask",
814
+ "797": "sleeping bag",
815
+ "798": "slide rule, slipstick",
816
+ "799": "sliding door",
817
+ "800": "slot, one-armed bandit",
818
+ "801": "snorkel",
819
+ "802": "snowmobile",
820
+ "803": "snowplow, snowplough",
821
+ "804": "soap dispenser",
822
+ "805": "soccer ball",
823
+ "806": "sock",
824
+ "807": "solar dish, solar collector, solar furnace",
825
+ "808": "sombrero",
826
+ "809": "soup bowl",
827
+ "810": "space bar",
828
+ "811": "space heater",
829
+ "812": "space shuttle",
830
+ "813": "spatula",
831
+ "814": "speedboat",
832
+ "815": "spider web, spiders web",
833
+ "816": "spindle",
834
+ "817": "sports car, sport car",
835
+ "818": "spotlight, spot",
836
+ "819": "stage",
837
+ "820": "steam locomotive",
838
+ "821": "steel arch bridge",
839
+ "822": "steel drum",
840
+ "823": "stethoscope",
841
+ "824": "stole",
842
+ "825": "stone wall",
843
+ "826": "stopwatch, stop watch",
844
+ "827": "stove",
845
+ "828": "strainer",
846
+ "829": "streetcar, tram, tramcar, trolley, trolley car",
847
+ "830": "stretcher",
848
+ "831": "studio couch, day bed",
849
+ "832": "stupa, tope",
850
+ "833": "submarine, pigboat, sub, U-boat",
851
+ "834": "suit, suit of clothes",
852
+ "835": "sundial",
853
+ "836": "sunglass",
854
+ "837": "sunglasses, dark glasses, shades",
855
+ "838": "sunscreen, sunblock, sun blocker",
856
+ "839": "suspension bridge",
857
+ "840": "swab, swob, mop",
858
+ "841": "sweatshirt",
859
+ "842": "swimming trunks, bathing trunks",
860
+ "843": "swing",
861
+ "844": "switch, electric switch, electrical switch",
862
+ "845": "syringe",
863
+ "846": "table lamp",
864
+ "847": "tank, army tank, armored combat vehicle, armoured combat vehicle",
865
+ "848": "tape player",
866
+ "849": "teapot",
867
+ "850": "teddy, teddy bear",
868
+ "851": "television, television system",
869
+ "852": "tennis ball",
870
+ "853": "thatch, thatched roof",
871
+ "854": "theater curtain, theatre curtain",
872
+ "855": "thimble",
873
+ "856": "thresher, thrasher, threshing machine",
874
+ "857": "throne",
875
+ "858": "tile roof",
876
+ "859": "toaster",
877
+ "860": "tobacco shop, tobacconist shop, tobacconist",
878
+ "861": "toilet seat",
879
+ "862": "torch",
880
+ "863": "totem pole",
881
+ "864": "tow truck, tow car, wrecker",
882
+ "865": "toyshop",
883
+ "866": "tractor",
884
+ "867": "trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi",
885
+ "868": "tray",
886
+ "869": "trench coat",
887
+ "870": "tricycle, trike, velocipede",
888
+ "871": "trimaran",
889
+ "872": "tripod",
890
+ "873": "triumphal arch",
891
+ "874": "trolleybus, trolley coach, trackless trolley",
892
+ "875": "trombone",
893
+ "876": "tub, vat",
894
+ "877": "turnstile",
895
+ "878": "typewriter keyboard",
896
+ "879": "umbrella",
897
+ "880": "unicycle, monocycle",
898
+ "881": "upright, upright piano",
899
+ "882": "vacuum, vacuum cleaner",
900
+ "883": "vase",
901
+ "884": "vault",
902
+ "885": "velvet",
903
+ "886": "vending machine",
904
+ "887": "vestment",
905
+ "888": "viaduct",
906
+ "889": "violin, fiddle",
907
+ "890": "volleyball",
908
+ "891": "waffle iron",
909
+ "892": "wall clock",
910
+ "893": "wallet, billfold, notecase, pocketbook",
911
+ "894": "wardrobe, closet, press",
912
+ "895": "warplane, military plane",
913
+ "896": "washbasin, handbasin, washbowl, lavabo, wash-hand basin",
914
+ "897": "washer, automatic washer, washing machine",
915
+ "898": "water bottle",
916
+ "899": "water jug",
917
+ "900": "water tower",
918
+ "901": "whiskey jug",
919
+ "902": "whistle",
920
+ "903": "wig",
921
+ "904": "window screen",
922
+ "905": "window shade",
923
+ "906": "Windsor tie",
924
+ "907": "wine bottle",
925
+ "908": "wing",
926
+ "909": "wok",
927
+ "910": "wooden spoon",
928
+ "911": "wool, woolen, woollen",
929
+ "912": "worm fence, snake fence, snake-rail fence, Virginia fence",
930
+ "913": "wreck",
931
+ "914": "yawl",
932
+ "915": "yurt",
933
+ "916": "web site, website, internet site, site",
934
+ "917": "comic book",
935
+ "918": "crossword puzzle, crossword",
936
+ "919": "street sign",
937
+ "920": "traffic light, traffic signal, stoplight",
938
+ "921": "book jacket, dust cover, dust jacket, dust wrapper",
939
+ "922": "menu",
940
+ "923": "plate",
941
+ "924": "guacamole",
942
+ "925": "consomme",
943
+ "926": "hot pot, hotpot",
944
+ "927": "trifle",
945
+ "928": "ice cream, icecream",
946
+ "929": "ice lolly, lolly, lollipop, popsicle",
947
+ "930": "French loaf",
948
+ "931": "bagel, beigel",
949
+ "932": "pretzel",
950
+ "933": "cheeseburger",
951
+ "934": "hotdog, hot dog, red hot",
952
+ "935": "mashed potato",
953
+ "936": "head cabbage",
954
+ "937": "broccoli",
955
+ "938": "cauliflower",
956
+ "939": "zucchini, courgette",
957
+ "940": "spaghetti squash",
958
+ "941": "acorn squash",
959
+ "942": "butternut squash",
960
+ "943": "cucumber, cuke",
961
+ "944": "artichoke, globe artichoke",
962
+ "945": "bell pepper",
963
+ "946": "cardoon",
964
+ "947": "mushroom",
965
+ "948": "Granny Smith",
966
+ "949": "strawberry",
967
+ "950": "orange",
968
+ "951": "lemon",
969
+ "952": "fig",
970
+ "953": "pineapple, ananas",
971
+ "954": "banana",
972
+ "955": "jackfruit, jak, jack",
973
+ "956": "custard apple",
974
+ "957": "pomegranate",
975
+ "958": "hay",
976
+ "959": "carbonara",
977
+ "960": "chocolate sauce, chocolate syrup",
978
+ "961": "dough",
979
+ "962": "meat loaf, meatloaf",
980
+ "963": "pizza, pizza pie",
981
+ "964": "potpie",
982
+ "965": "burrito",
983
+ "966": "red wine",
984
+ "967": "espresso",
985
+ "968": "cup",
986
+ "969": "eggnog",
987
+ "970": "alp",
988
+ "971": "bubble",
989
+ "972": "cliff, drop, drop-off",
990
+ "973": "coral reef",
991
+ "974": "geyser",
992
+ "975": "lakeside, lakeshore",
993
+ "976": "promontory, headland, head, foreland",
994
+ "977": "sandbar, sand bar",
995
+ "978": "seashore, coast, seacoast, sea-coast",
996
+ "979": "valley, vale",
997
+ "980": "volcano",
998
+ "981": "ballplayer, baseball player",
999
+ "982": "groom, bridegroom",
1000
+ "983": "scuba diver",
1001
+ "984": "rapeseed",
1002
+ "985": "daisy",
1003
+ "986": "yellow ladys slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum",
1004
+ "987": "corn",
1005
+ "988": "acorn",
1006
+ "989": "hip, rose hip, rosehip",
1007
+ "990": "buckeye, horse chestnut, conker",
1008
+ "991": "coral fungus",
1009
+ "992": "agaric",
1010
+ "993": "gyromitra",
1011
+ "994": "stinkhorn, carrion fungus",
1012
+ "995": "earthstar",
1013
+ "996": "hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa",
1014
+ "997": "bolete",
1015
+ "998": "ear, spike, capitulum",
1016
+ "999": "toilet tissue, toilet paper, bathroom tissue"
1017
+ }
1018
+ }
GAT-XL-2-256/pipeline.py ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Hub custom pipeline: GATPipeline.
2
+ Load with native Hugging Face diffusers and trust_remote_code=True.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import json
8
+ from pathlib import Path
9
+ from typing import Dict, List, Optional, Tuple, Union
10
+
11
+ import torch
12
+ from diffusers.image_processor import VaeImageProcessor
13
+ from diffusers.models import AutoencoderKL
14
+ from diffusers.pipelines.pipeline_utils import DiffusionPipeline, ImagePipelineOutput
15
+ from diffusers.utils.torch_utils import randn_tensor
16
+
17
+
18
+ def _normalize_id2label(id2label: Optional[Dict[Union[int, str], str]]) -> Dict[int, str]:
19
+ if not id2label:
20
+ return {}
21
+ return {int(key): value for key, value in id2label.items()}
22
+
23
+
24
+ def _read_id2label_from_model_index(variant_path: Optional[str]) -> Dict[int, str]:
25
+ if not variant_path:
26
+ return {}
27
+ model_index_path = Path(variant_path).resolve() / "model_index.json"
28
+ if not model_index_path.exists():
29
+ return {}
30
+ raw = json.loads(model_index_path.read_text(encoding="utf-8"))
31
+ id2label = raw.get("id2label")
32
+ if not isinstance(id2label, dict):
33
+ return {}
34
+ return {int(key): value for key, value in id2label.items()}
35
+
36
+
37
+ def _build_label2id(id2label: Dict[int, str]) -> Dict[str, int]:
38
+ label2id: Dict[str, int] = {}
39
+ for class_id, value in id2label.items():
40
+ for synonym in value.split(","):
41
+ synonym = synonym.strip()
42
+ if synonym:
43
+ label2id[synonym] = int(class_id)
44
+ return dict(sorted(label2id.items()))
45
+
46
+
47
+ def _normalize_class_labels(
48
+ class_labels: Union[int, str, List[Union[int, str]], torch.LongTensor],
49
+ *,
50
+ device: torch.device,
51
+ label2id: Dict[str, int],
52
+ ) -> torch.LongTensor:
53
+ if torch.is_tensor(class_labels):
54
+ return class_labels.to(device=device, dtype=torch.long).reshape(-1)
55
+ if isinstance(class_labels, int):
56
+ class_label_ids = [class_labels]
57
+ elif isinstance(class_labels, str):
58
+ if not label2id:
59
+ raise ValueError("No English labels loaded. Provide `id2label` in the pipeline config.")
60
+ if class_labels not in label2id:
61
+ raise ValueError(f"Unknown English label: {class_labels}")
62
+ class_label_ids = [label2id[class_labels]]
63
+ elif class_labels and isinstance(class_labels[0], str):
64
+ if not label2id:
65
+ raise ValueError("No English labels loaded. Provide `id2label` in the pipeline config.")
66
+ missing = [item for item in class_labels if item not in label2id]
67
+ if missing:
68
+ raise ValueError(f"Unknown English label(s): {missing}")
69
+ class_label_ids = [label2id[item] for item in class_labels]
70
+ else:
71
+ class_label_ids = list(class_labels)
72
+ return torch.tensor(class_label_ids, device=device, dtype=torch.long).reshape(-1)
73
+
74
+
75
+ class GATPipeline(DiffusionPipeline):
76
+ r"""
77
+ Pipeline for one-step class-conditional image generation with Generative Adversarial Transformers (GAT).
78
+ """
79
+
80
+ model_cpu_offload_seq = "generator->vae"
81
+
82
+ def __init__(
83
+ self,
84
+ generator,
85
+ vae: AutoencoderKL,
86
+ truncation_psi: float = 0.3,
87
+ id2label: Optional[Dict[Union[int, str], str]] = None,
88
+ ):
89
+ super().__init__()
90
+ self.register_modules(generator=generator, vae=vae)
91
+ self.register_to_config(truncation_psi=truncation_psi)
92
+ self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1)
93
+ self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
94
+ self._id2label = _normalize_id2label(id2label)
95
+ self.labels = _build_label2id(self._id2label)
96
+ self._labels_loaded_from_model_index = bool(self._id2label)
97
+
98
+ @property
99
+ def id2label(self) -> Dict[int, str]:
100
+ self._ensure_labels_loaded()
101
+ return self._id2label
102
+
103
+ def _ensure_labels_loaded(self) -> None:
104
+ if self._labels_loaded_from_model_index:
105
+ return
106
+ loaded = _read_id2label_from_model_index(getattr(self.config, "_name_or_path", None))
107
+ if loaded:
108
+ self._id2label = loaded
109
+ self.labels = _build_label2id(self._id2label)
110
+ self._labels_loaded_from_model_index = True
111
+
112
+ def _default_image_size(self) -> int:
113
+ return int(self.generator.config.input_size) * self.vae_scale_factor
114
+
115
+ def prepare_latents(
116
+ self,
117
+ batch_size: int,
118
+ height: int,
119
+ width: int,
120
+ dtype: torch.dtype,
121
+ device: torch.device,
122
+ generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
123
+ latents: Optional[torch.Tensor] = None,
124
+ ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
125
+ if latents is not None:
126
+ noise = latents.to(device=device, dtype=dtype)
127
+ else:
128
+ latent_height = height // self.vae_scale_factor
129
+ latent_width = width // self.vae_scale_factor
130
+ in_channels = int(getattr(self.generator, "in_channels", 4))
131
+ noise = randn_tensor(
132
+ (batch_size, in_channels, latent_height, latent_width),
133
+ generator=generator,
134
+ device=device,
135
+ dtype=dtype,
136
+ )
137
+ latent_size = int(getattr(self.generator, "latent_size", 64))
138
+ z = randn_tensor(
139
+ (batch_size, latent_size),
140
+ generator=generator,
141
+ device=device,
142
+ dtype=dtype,
143
+ )
144
+ return noise, z, noise
145
+
146
+ def decode_latents(self, latents: torch.Tensor, output_type: str = "pil"):
147
+ if output_type == "latent":
148
+ return latents
149
+ scaling_factor = getattr(self.vae.config, "scaling_factor", 0.18215)
150
+ image = self.vae.decode(latents / scaling_factor).sample
151
+ if output_type == "pt":
152
+ return image
153
+ return self.image_processor.postprocess(image, output_type=output_type)
154
+
155
+ @torch.inference_mode()
156
+ def __call__(
157
+ self,
158
+ class_labels: Union[int, str, List[Union[int, str]], torch.LongTensor],
159
+ height: Optional[int] = None,
160
+ width: Optional[int] = None,
161
+ truncation_psi: Optional[float] = None,
162
+ guidance_scale: float = 1.0,
163
+ generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
164
+ latents: Optional[torch.Tensor] = None,
165
+ output_type: str = "pil",
166
+ return_dict: bool = True,
167
+ ) -> Union[ImagePipelineOutput, Tuple]:
168
+ default_size = self._default_image_size()
169
+ height = int(height or default_size)
170
+ width = int(width or default_size)
171
+ truncation_psi = self.config.truncation_psi if truncation_psi is None else truncation_psi
172
+
173
+ if output_type not in {"pil", "np", "pt", "latent"}:
174
+ raise ValueError("output_type must be one of: 'pil', 'np', 'pt', 'latent'.")
175
+
176
+ device = getattr(self, "_execution_device", None) or next(self.generator.parameters()).device
177
+ dtype = next(self.generator.parameters()).dtype
178
+ class_labels_tensor = _normalize_class_labels(
179
+ class_labels,
180
+ device=device,
181
+ label2id=self.labels,
182
+ )
183
+ batch_size = class_labels_tensor.shape[0]
184
+
185
+ x, z, latents = self.prepare_latents(
186
+ batch_size=batch_size,
187
+ height=height,
188
+ width=width,
189
+ dtype=dtype,
190
+ device=device,
191
+ generator=generator,
192
+ latents=latents,
193
+ )
194
+
195
+ output = self.generator(
196
+ x=x,
197
+ y=class_labels_tensor,
198
+ z=z,
199
+ guidance_scale=guidance_scale,
200
+ truncation_psi=truncation_psi,
201
+ return_dict=True,
202
+ ).sample
203
+
204
+ if output_type == "latent":
205
+ result = output
206
+ else:
207
+ result = self.decode_latents(output, output_type=output_type)
208
+
209
+ if not return_dict:
210
+ return (result,)
211
+ return ImagePipelineOutput(images=result)
GAT-XL-2-256/vae/config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "AutoencoderKL",
3
+ "_diffusers_version": "0.38.0",
4
+ "_name_or_path": "stabilityai/sd-vae-ft-ema",
5
+ "act_fn": "silu",
6
+ "block_out_channels": [
7
+ 128,
8
+ 256,
9
+ 512,
10
+ 512
11
+ ],
12
+ "down_block_types": [
13
+ "DownEncoderBlock2D",
14
+ "DownEncoderBlock2D",
15
+ "DownEncoderBlock2D",
16
+ "DownEncoderBlock2D"
17
+ ],
18
+ "force_upcast": true,
19
+ "in_channels": 3,
20
+ "latent_channels": 4,
21
+ "latents_mean": null,
22
+ "latents_std": null,
23
+ "layers_per_block": 2,
24
+ "mid_block_add_attention": true,
25
+ "norm_num_groups": 32,
26
+ "out_channels": 3,
27
+ "sample_size": 256,
28
+ "scaling_factor": 0.18215,
29
+ "shift_factor": null,
30
+ "up_block_types": [
31
+ "UpDecoderBlock2D",
32
+ "UpDecoderBlock2D",
33
+ "UpDecoderBlock2D",
34
+ "UpDecoderBlock2D"
35
+ ],
36
+ "use_post_quant_conv": true,
37
+ "use_quant_conv": true
38
+ }
GAT-XL-2-256/vae/diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:703abdcd7c389316b5128faa9b750a530ea1680b453170b27afebac5e4db30c4
3
+ size 334643268
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: diffusers
4
+ pipeline_tag: image-to-image
5
+ tags:
6
+ - diffusers
7
+ - gat
8
+ - gan
9
+ - class-conditional
10
+ - imagenet
11
+ inference: true
12
+ widget:
13
+ - output:
14
+ url: GAT-XL-2-256/demo.png
15
+ language:
16
+ - en
17
+ ---
18
+
19
+ # BiliSakura/GAT-diffusers
20
+
21
+ Self-contained [Generative Adversarial Transformers (GAT)](https://arxiv.org/abs/2509.24935) checkpoints for Hugging Face diffusers.
22
+
23
+ Converted from the official GAT XL-2 checkpoint using `libs/GAT-diffusers/scripts/convert_gat_checkpoint.py`.
24
+
25
+ GAT performs one-step class-conditional image generation in Stable Diffusion VAE latent space (`sd-vae-ft-ema`).
26
+
27
+ ## Demo
28
+
29
+ `GAT-XL-2-256` — class **207** (*golden retriever*), seed **0**, `truncation_psi=0.3`:
30
+
31
+ <p align="center">
32
+ <img src="GAT-XL-2-256/demo.png" alt="GAT-XL-2-256 demo (class 207, seed 0)" width="256"/>
33
+ </p>
34
+
35
+ ## Variants
36
+
37
+ | Model | Resolution | Params | Checkpoint |
38
+ | --- | --- | --- | --- |
39
+ | GAT-XL/2 | 256×256 | 675M | `GAT-XL-2-256/` |
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from pathlib import Path
45
+ import torch
46
+ from diffusers import DiffusionPipeline
47
+
48
+ model_dir = Path("./GAT-XL-2-256").resolve()
49
+ pipe = DiffusionPipeline.from_pretrained(
50
+ str(model_dir),
51
+ custom_pipeline=str(model_dir / "pipeline.py"),
52
+ trust_remote_code=True,
53
+ torch_dtype=torch.float32,
54
+ local_files_only=True,
55
+ ).to("cuda")
56
+
57
+ image = pipe(
58
+ class_labels="golden retriever",
59
+ truncation_psi=0.3,
60
+ generator=torch.Generator("cuda").manual_seed(0),
61
+ ).images[0]
62
+ ```
63
+
64
+ ## Conversion
65
+
66
+ ```bash
67
+ conda activate rsgen
68
+ python libs/GAT-diffusers/scripts/convert_gat_checkpoint.py \
69
+ --ckpt models/BiliSakura/GAT-diffusers/gat-xl-2-256.pt \
70
+ --output-dir models/BiliSakura/GAT-diffusers/GAT-XL-2-256 \
71
+ --resolution 256
72
+ ```