Instructions to use BiliSakura/iMF-diffusers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use BiliSakura/iMF-diffusers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("BiliSakura/iMF-diffusers", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps
- Draw Things
- DiffusionBee
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +72 -0
- iMF-B-2/README.md +40 -0
- iMF-B-2/__pycache__/pipeline.cpython-312.pyc +0 -0
- iMF-B-2/model_index.json +1021 -0
- iMF-B-2/pipeline.py +275 -0
- iMF-B-2/scheduler/scheduler_config.json +7 -0
- iMF-B-2/transformer/__pycache__/transformer_imf.cpython-312.pyc +0 -0
- iMF-B-2/transformer/config.json +23 -0
- iMF-B-2/transformer/diffusion_pytorch_model.safetensors +3 -0
- iMF-B-2/transformer/transformer_imf.py +586 -0
- iMF-B-2/vae/config.json +38 -0
- iMF-B-2/vae/diffusion_pytorch_model.safetensors +3 -0
- iMF-L-2/README.md +40 -0
- iMF-L-2/conversion_metadata.json +8 -0
- iMF-L-2/model_index.json +1021 -0
- iMF-L-2/pipeline.py +275 -0
- iMF-L-2/scheduler/scheduler_config.json +7 -0
- iMF-L-2/transformer/config.json +23 -0
- iMF-L-2/transformer/diffusion_pytorch_model.safetensors +3 -0
- iMF-L-2/transformer/transformer_imf.py +586 -0
- iMF-L-2/vae/config.json +38 -0
- iMF-L-2/vae/diffusion_pytorch_model.safetensors +3 -0
- iMF-XL-2/README.md +54 -0
- iMF-XL-2/demo.png +3 -0
- iMF-XL-2/model_index.json +1021 -0
- iMF-XL-2/pipeline.py +275 -0
- iMF-XL-2/scheduler/scheduler_config.json +7 -0
- iMF-XL-2/transformer/config.json +23 -0
- iMF-XL-2/transformer/diffusion_pytorch_model.safetensors +3 -0
- iMF-XL-2/transformer/transformer_imf.py +586 -0
- iMF-XL-2/vae/config.json +38 -0
- iMF-XL-2/vae/diffusion_pytorch_model.safetensors +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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 |
+
iMF-XL-2/demo.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: diffusers
|
| 4 |
+
pipeline_tag: text-to-image
|
| 5 |
+
tags:
|
| 6 |
+
- diffusers
|
| 7 |
+
- imf
|
| 8 |
+
- image-generation
|
| 9 |
+
- class-conditional
|
| 10 |
+
- imagenet
|
| 11 |
+
inference: true
|
| 12 |
+
widget:
|
| 13 |
+
- output:
|
| 14 |
+
url: iMF-XL-2/demo.png
|
| 15 |
+
language:
|
| 16 |
+
- en
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# iMF-diffusers
|
| 20 |
+
|
| 21 |
+
Native diffusers implementation of [Improved Mean Flows (iMF)](https://arxiv.org/abs/2512.02012). Each variant folder is self-contained:
|
| 22 |
+
|
| 23 |
+
- `pipeline.py` — `IMFPipeline`
|
| 24 |
+
- `scheduler/scheduler_config.json` — `FlowMatchEulerDiscreteScheduler` config
|
| 25 |
+
- `transformer/transformer_imf.py` — `IMFTransformer2DModel`
|
| 26 |
+
- `vae/` — bundled `stabilityai/sd-vae-ft-mse` (`AutoencoderKL`)
|
| 27 |
+
|
| 28 |
+
## Demo
|
| 29 |
+
|
| 30 |
+

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

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