File size: 1,167 Bytes
811d1c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
import torch
from diffusers import AutoPipelineForText2Image
from huggingface_hub import HfApi
from pathlib import Path
import os

from PIL import Image
import numpy as np

api = HfApi()

pipe = AutoPipelineForText2Image.from_pretrained("warp-diffusion/WuerstchenGeneratorPipeline", torch_dtype=torch.float16).to("cuda")

prompt = [
    "An old destroyed car standing on a cliff in norway, cinematic photography",
    "Western movie, closeup cinematic photography",
    "Pink nike shoe commercial, closeup cinematic photography",
    "Croatia, closeup cinematic photography",
    "South Tyrol mountains at sunset, closeup cinematic photography",
]


images = pipe(prompt, guidance_scale=8.0, width=1024, height=1024).images

for i, image in enumerate(images):
    file_name = f"bb_1_{i}"
    path = os.path.join(Path.home(), "images", f"{file_name}.png")
    image.save(path)

    api.upload_file(
        path_or_fileobj=path,
        path_in_repo=path.split("/")[-1],
        repo_id="patrickvonplaten/images",
        repo_type="dataset",
    )
    print(f"https://huggingface.co/datasets/patrickvonplaten/images/blob/main/{file_name}.png")