|
|
|
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") |
|
|