#!/usr/bin/env python3 from diffusers import StableDiffusionPipeline import time import os from huggingface_hub import HfApi import torch import sys from pathlib import Path import requests from PIL import Image from io import BytesIO begin = ["a picture of ", "a photo of ", "", "an image of "] end = ["", " smiling", " with sunglasses", " at the beach", " in front of a mountain", " in beautiful sunshine", " in avatar style", " as a picasso painting", " as an oil painting", " as oil art", " while it snows", " in a forest", " with a nice landscape"] api = HfApi() start_time = time.time() path = "patrickvonplaten/papa_out_5" pipe = StableDiffusionPipeline.from_pretrained(path, safety_checker=None, torch_dtype=torch.float16) pipe = pipe.to("cuda") counter = 0 for b in begin: for e in end: prompt = b + e + ", highly realistic, super resolution, high quality photography, beautiful" images = pipe(prompt=prompt, num_images_per_prompt=4, negative_prompt="ugly, bad quality, deformed", num_inference_steps=50).images for i, image in enumerate(images): path = os.path.join(Path.home(), "papa", f"{counter}.png") image.save(path) api.upload_file( path_or_fileobj=path, path_in_repo=path.split("/")[-1], repo_id="patrickvonplaten/papa", repo_type="dataset", ) print(f"https://huggingface.co/datasets/patrickvonplaten/papa/blob/main/{counter}.png") counter += 1