region:us
---
dataset_info:
  features:
  - name: prompt
    dtype: string
  - name: image_one
    dtype: image
  - name: image_two
    dtype: image
  - name: image_three
    dtype: image
  - name: image_four
    dtype: image
  splits:
  - name: train
    num_bytes: 8935461379.064
    num_examples: 1632
  download_size: 8924903414
  dataset_size: 8935461379.064
---
# Dataset Card for "xl-base-0.9-refiner-parti-prompts"

The dataset was generated using the following code:

```python
import torch
from datasets import Dataset, Features
from datasets import Image as ImageFeature
from datasets import Value, load_dataset

from diffusers import DDIMScheduler, DiffusionPipeline


def main():
    print("Loading dataset...")
    parti_prompts = load_dataset("nateraw/parti-prompts", split="train")

    print("Loading pipeline...")
    ckpt_id = "diffusers/stable-diffusion-xl-base-0.9"
    pipe = DiffusionPipeline.from_pretrained(
        ckpt_id, torch_dtype=torch.float16, use_auth_token=True
    ).to("cuda")
    pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
    pipe.set_progress_bar_config(disable=True)
    refiner = DiffusionPipeline.from_pretrained(
        "diffusers/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, use_auth_token=True
    ).to("cuda")

    generator = torch.Generator("cuda").manual_seed(0)

    print("Running inference...")
    main_dict = {}
    for i in range(len(parti_prompts)):
        prompt = parti_prompts[i]["Prompt"]
        output = pipe(
            prompt,
            generator=generator,
            num_inference_steps=100,
            guidance_scale=7.5,
            output_type="latent",
        )
        images = refiner(
            prompt=prompt,
            generator=generator,
            image=output.images,
            num_images_per_prompt=4,
        ).images
        image_paths = []
        for j in range(len(images)):
            path = f"sd_xl_{i}_{j}.png"
            images[j].save(path)
            image_paths.append(path)

        main_dict.update({prompt: image_paths})

    def generation_fn():
        for prompt in main_dict:
            all_image_paths = main_dict[prompt]
            yield {
                "prompt": prompt,
                "image_one": {"path": all_image_paths[0]},
                "image_two": {"path": all_image_paths[1]},
                "image_three": {"path": all_image_paths[2]},
                "image_four": {"path": all_image_paths[3]},
            }

    print("Preparing HF dataset...")
    ds = Dataset.from_generator(
        generation_fn,
        features=Features(
            prompt=Value("string"),
            image_one=ImageFeature(),
            image_two=ImageFeature(),
            image_three=ImageFeature(),
            image_four=ImageFeature(),
        ),
    )
    ds_id = "diffusers/xl-base-0.9-refiner-parti-prompts"
    ds.push_to_hub(ds_id, private=True)


if __name__ == "__main__":
    main()

```

Explore the dataset here: https://colab.research.google.com/drive/1oSrYN3NWpDKGBmm7PaohLPNJtVemf_Db?usp=sharing. 