Commit
·
5a67ae4
1
Parent(s):
b662a8e
Update README.md
Browse files
README.md
CHANGED
|
@@ -29,6 +29,112 @@ configs:
|
|
| 29 |
- split: train
|
| 30 |
path: data/train-*
|
| 31 |
---
|
| 32 |
-
# Dataset Card for "kand2"
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
- split: train
|
| 30 |
path: data/train-*
|
| 31 |
---
|
|
|
|
| 32 |
|
| 33 |
+
# Kandinksy 2.2
|
| 34 |
+
|
| 35 |
+
All images included in this dataset were voted as "Not solved" by the community in https://huggingface.co/spaces/OpenGenAI/open-parti-prompts. This means that according to the community the model did not generate an image that corresponds sufficiently enough to the prompt.
|
| 36 |
+
|
| 37 |
+
The following script was used to generate the images:
|
| 38 |
+
|
| 39 |
+
```py
|
| 40 |
+
import PIL
|
| 41 |
+
import torch
|
| 42 |
+
from datasets import Dataset, Features
|
| 43 |
+
from datasets import Image as ImageFeature
|
| 44 |
+
from datasets import Value, load_dataset
|
| 45 |
+
|
| 46 |
+
from diffusers import DiffusionPipeline
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def main():
|
| 50 |
+
print("Loading dataset...")
|
| 51 |
+
parti_prompts = load_dataset("nateraw/parti-prompts", split="train")
|
| 52 |
+
|
| 53 |
+
print("Loading pipeline...")
|
| 54 |
+
pipe_prior = DiffusionPipeline.from_pretrained(
|
| 55 |
+
"kandinsky-community/kandinsky-2-2-prior", torch_dtype=torch.float16
|
| 56 |
+
)
|
| 57 |
+
pipe_prior.to("cuda")
|
| 58 |
+
pipe_prior.set_progress_bar_config(disable=True)
|
| 59 |
+
|
| 60 |
+
t2i_pipe = DiffusionPipeline.from_pretrained(
|
| 61 |
+
"kandinsky-community/kandinsky-2-2-decoder", torch_dtype=torch.float16
|
| 62 |
+
)
|
| 63 |
+
t2i_pipe.to("cuda")
|
| 64 |
+
t2i_pipe.set_progress_bar_config(disable=True)
|
| 65 |
+
|
| 66 |
+
seed = 0
|
| 67 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
| 68 |
+
ckpt_id = (
|
| 69 |
+
"kandinsky-community/" + "kandinsky-2-2-prior" + "_" + "kandinsky-2-2-decoder"
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
print("Running inference...")
|
| 73 |
+
main_dict = {}
|
| 74 |
+
for i in range(len(parti_prompts)):
|
| 75 |
+
sample = parti_prompts[i]
|
| 76 |
+
prompt = sample["Prompt"]
|
| 77 |
+
|
| 78 |
+
image_embeds, negative_image_embeds = pipe_prior(
|
| 79 |
+
prompt,
|
| 80 |
+
generator=generator,
|
| 81 |
+
num_inference_steps=100,
|
| 82 |
+
guidance_scale=7.5,
|
| 83 |
+
).to_tuple()
|
| 84 |
+
image = t2i_pipe(
|
| 85 |
+
image_embeds=image_embeds,
|
| 86 |
+
negative_image_embeds=negative_image_embeds,
|
| 87 |
+
generator=generator,
|
| 88 |
+
num_inference_steps=100,
|
| 89 |
+
guidance_scale=7.5,
|
| 90 |
+
).images[0]
|
| 91 |
+
|
| 92 |
+
image = image.resize((256, 256), resample=PIL.Image.Resampling.LANCZOS)
|
| 93 |
+
img_path = f"kandinsky_22_{i}.png"
|
| 94 |
+
image.save(img_path)
|
| 95 |
+
main_dict.update(
|
| 96 |
+
{
|
| 97 |
+
prompt: {
|
| 98 |
+
"img_path": img_path,
|
| 99 |
+
"Category": sample["Category"],
|
| 100 |
+
"Challenge": sample["Challenge"],
|
| 101 |
+
"Note": sample["Note"],
|
| 102 |
+
"model_name": ckpt_id,
|
| 103 |
+
"seed": seed,
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
def generation_fn():
|
| 109 |
+
for prompt in main_dict:
|
| 110 |
+
prompt_entry = main_dict[prompt]
|
| 111 |
+
yield {
|
| 112 |
+
"Prompt": prompt,
|
| 113 |
+
"Category": prompt_entry["Category"],
|
| 114 |
+
"Challenge": prompt_entry["Challenge"],
|
| 115 |
+
"Note": prompt_entry["Note"],
|
| 116 |
+
"images": {"path": prompt_entry["img_path"]},
|
| 117 |
+
"model_name": prompt_entry["model_name"],
|
| 118 |
+
"seed": prompt_entry["seed"],
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
print("Preparing HF dataset...")
|
| 122 |
+
ds = Dataset.from_generator(
|
| 123 |
+
generation_fn,
|
| 124 |
+
features=Features(
|
| 125 |
+
Prompt=Value("string"),
|
| 126 |
+
Category=Value("string"),
|
| 127 |
+
Challenge=Value("string"),
|
| 128 |
+
Note=Value("string"),
|
| 129 |
+
images=ImageFeature(),
|
| 130 |
+
model_name=Value("string"),
|
| 131 |
+
seed=Value("int64"),
|
| 132 |
+
),
|
| 133 |
+
)
|
| 134 |
+
ds_id = "diffusers-parti-prompts/kandinsky-2-2"
|
| 135 |
+
ds.push_to_hub(ds_id)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
if __name__ == "__main__":
|
| 139 |
+
main()
|
| 140 |
+
```
|