patrickvonplaten commited on
Commit
ac9ce53
1 Parent(s): 2c66ef3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -2
README.md CHANGED
@@ -29,6 +29,103 @@ configs:
29
  - split: train
30
  path: data/train-*
31
  ---
32
- # Dataset Card for "wuerst"
33
 
34
- [More Information needed](https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  - split: train
30
  path: data/train-*
31
  ---
32
+ # Wuerstchen
33
 
34
+ 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.
35
+
36
+ The following script was used to generate the images:
37
+
38
+ ```py
39
+ import torch
40
+ from datasets import Dataset, Features
41
+ from datasets import Image as ImageFeature
42
+ from datasets import Value, load_dataset
43
+ from diffusers import AutoPipelineForText2Image
44
+
45
+ import PIL
46
+
47
+
48
+ def main():
49
+ print("Loading dataset...")
50
+ parti_prompts = load_dataset("nateraw/parti-prompts", split="train")
51
+
52
+ print("Loading pipeline...")
53
+ seed = 0
54
+
55
+ device = "cuda"
56
+ generator = torch.Generator(device).manual_seed(seed)
57
+ dtype = torch.float16
58
+
59
+ ckpt_id = "warp-diffusion/wuerstchen"
60
+
61
+ pipeline = AutoPipelineForText2Image.from_pretrained(
62
+ ckpt_id, torch_dtype=dtype
63
+ ).to(device)
64
+
65
+ pipeline.prior_prior = torch.compile(pipeline.prior_prior, mode="reduce-overhead", fullgraph=True)
66
+ pipeline.decoder = torch.compile(pipeline.decoder, mode="reduce-overhead", fullgraph=True)
67
+
68
+ print("Running inference...")
69
+ main_dict = {}
70
+ for i in range(len(parti_prompts)):
71
+ sample = parti_prompts[i]
72
+ prompt = sample["Prompt"]
73
+
74
+ image = pipeline(
75
+ prompt=prompt,
76
+ height=1024,
77
+ width=1024,
78
+ prior_guidance_scale=4.0,
79
+ decoder_guidance_scale=0.0,
80
+ generator=generator,
81
+ ).images[0]
82
+
83
+ image = image.resize((256, 256), resample=PIL.Image.Resampling.LANCZOS)
84
+ img_path = f"wuerstchen_{i}.png"
85
+ image.save(img_path)
86
+ main_dict.update(
87
+ {
88
+ prompt: {
89
+ "img_path": img_path,
90
+ "Category": sample["Category"],
91
+ "Challenge": sample["Challenge"],
92
+ "Note": sample["Note"],
93
+ "model_name": ckpt_id,
94
+ "seed": seed,
95
+ }
96
+ }
97
+ )
98
+
99
+ def generation_fn():
100
+ for prompt in main_dict:
101
+ prompt_entry = main_dict[prompt]
102
+ yield {
103
+ "Prompt": prompt,
104
+ "Category": prompt_entry["Category"],
105
+ "Challenge": prompt_entry["Challenge"],
106
+ "Note": prompt_entry["Note"],
107
+ "images": {"path": prompt_entry["img_path"]},
108
+ "model_name": prompt_entry["model_name"],
109
+ "seed": prompt_entry["seed"],
110
+ }
111
+
112
+ print("Preparing HF dataset...")
113
+ ds = Dataset.from_generator(
114
+ generation_fn,
115
+ features=Features(
116
+ Prompt=Value("string"),
117
+ Category=Value("string"),
118
+ Challenge=Value("string"),
119
+ Note=Value("string"),
120
+ images=ImageFeature(),
121
+ model_name=Value("string"),
122
+ seed=Value("int64"),
123
+ ),
124
+ )
125
+ ds_id = "diffusers-parti-prompts/wuerstchen"
126
+ ds.push_to_hub(ds_id)
127
+
128
+
129
+ if __name__ == "__main__":
130
+ main()
131
+ ```