File size: 948 Bytes
e58dd86 |
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 |
#!/usr/bin/env python3
#!/usr/bin/env python3
from diffusers import DiffusionPipeline
import torch
import time
import os
from pathlib import Path
from huggingface_hub import HfApi
api = HfApi()
start_time = time.time()
pipe = DiffusionPipeline.from_pretrained("/home/patrick/if", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
pipe.enable_model_cpu_offload()
generator = torch.Generator("cuda").manual_seed(0)
prompt = 'a photo of a kangaroo wearing an orange hoodie and blue sunglasses standing in front of the eiffel tower holding a sign that says "very deep learning"'
image = pipe(prompt, generator=generator).images[0]
path = os.path.join(Path.home(), "images", "if.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/if.png")
|