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