File size: 1,572 Bytes
69f6fc2
a032108
78ed83d
2f0087d
78ed83d
69f6fc2
 
b6badad
b88c59f
 
 
69f6fc2
a032108
 
69f6fc2
78ed83d
 
a032108
 
69f6fc2
a032108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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 <rickmann>", "a photo of <rickmann>", "<rickmann>", "an image of <rickmann>"]
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