patrickvonplaten commited on
Commit
bea3e10
1 Parent(s): e073450

Update README.md

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