patrickvonplaten commited on
Commit
739f10e
·
1 Parent(s): 76a5c1c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +109 -2
README.md CHANGED
@@ -29,6 +29,113 @@ configs:
29
  - split: train
30
  path: data/train-*
31
  ---
32
- # Dataset Card for "sdxl"
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
+ # SDXL
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.
35
+ 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 torch
41
+ from datasets import Dataset, Features
42
+ from datasets import Image as ImageFeature
43
+ from datasets import Value, load_dataset
44
+
45
+ from diffusers import DDIMScheduler, DiffusionPipeline
46
+ import PIL
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
+ ckpt_id = "stabilityai/stable-diffusion-xl-base-1.0"
55
+ refiner_ckpt_id = "stabilityai/stable-diffusion-xl-refiner-1.0"
56
+
57
+ pipe = DiffusionPipeline.from_pretrained(
58
+ ckpt_id, torch_dtype=torch.float16, use_auth_token=True
59
+ ).to("cuda")
60
+ pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
61
+ pipe.set_progress_bar_config(disable=True)
62
+ refiner = DiffusionPipeline.from_pretrained(
63
+ refiner_ckpt_id,
64
+ torch_dtype=torch.float16,
65
+ use_auth_token=True
66
+ ).to("cuda")
67
+ refiner.scheduler = DDIMScheduler.from_config(refiner.scheduler.config)
68
+ refiner.set_progress_bar_config(disable=True)
69
+
70
+ seed = 0
71
+ generator = torch.Generator("cuda").manual_seed(seed)
72
+
73
+ print("Running inference...")
74
+ main_dict = {}
75
+ for i in range(len(parti_prompts)):
76
+ sample = parti_prompts[i]
77
+ prompt = sample["Prompt"]
78
+ latent = pipe(
79
+ prompt,
80
+ generator=generator,
81
+ num_inference_steps=100,
82
+ guidance_scale=7.5,
83
+ output_type="latent",
84
+ ).images[0]
85
+ image_refined = refiner(
86
+ prompt=prompt,
87
+ image=latent[None, :],
88
+ generator=generator,
89
+ num_inference_steps=100,
90
+ guidance_scale=7.5,
91
+ ).images[0]
92
+
93
+ image = image_refined.resize((256, 256), resample=PIL.Image.Resampling.LANCZOS)
94
+ img_path = f"sd_xl_{i}.png"
95
+ image.save(img_path)
96
+ main_dict.update(
97
+ {
98
+ prompt: {
99
+ "img_path": img_path,
100
+ "Category": sample["Category"],
101
+ "Challenge": sample["Challenge"],
102
+ "Note": sample["Note"],
103
+ "model_name": ckpt_id,
104
+ "seed": seed,
105
+ }
106
+ }
107
+ )
108
+
109
+ def generation_fn():
110
+ for prompt in main_dict:
111
+ prompt_entry = main_dict[prompt]
112
+ yield {
113
+ "Prompt": prompt,
114
+ "Category": prompt_entry["Category"],
115
+ "Challenge": prompt_entry["Challenge"],
116
+ "Note": prompt_entry["Note"],
117
+ "images": {"path": prompt_entry["img_path"]},
118
+ "model_name": prompt_entry["model_name"],
119
+ "seed": prompt_entry["seed"],
120
+ }
121
+
122
+ print("Preparing HF dataset...")
123
+ ds = Dataset.from_generator(
124
+ generation_fn,
125
+ features=Features(
126
+ Prompt=Value("string"),
127
+ Category=Value("string"),
128
+ Challenge=Value("string"),
129
+ Note=Value("string"),
130
+ images=ImageFeature(),
131
+ model_name=Value("string"),
132
+ seed=Value("int64"),
133
+ ),
134
+ )
135
+ ds_id = "diffusers-parti-prompts/sdxl-1.0-refiner"
136
+ ds.push_to_hub(ds_id)
137
+
138
+
139
+ if __name__ == "__main__":
140
+ main()
141
+ ```