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

api = HfApi()

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
pipe.load_lora_weights("stabilityai/stable-diffusion-xl-base-1.0", weight_name="sd_xl_offset_example-lora_1.0.safetensors")
# pipe.unet.fuse_lora()
# 7.8 it/s to beat
#
pipe.to(torch_dtype=torch.float16)
pipe.to("cuda")

torch.manual_seed(0)

prompt = "beautiful scenery nature glass bottle landscape, , purple galaxy bottle"
negative_prompt = "text, watermark"

image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=25).images[0]

file_name = f"aaa"
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")