File size: 1,144 Bytes
69f6fc2
78ed83d
866074c
78ed83d
 
69f6fc2
 
 
78ed83d
69f6fc2
78ed83d
 
 
866074c
69f6fc2
 
78ed83d
866074c
78ed83d
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
from diffusers import StableDiffusionPipeline, DPMSolverSinglestepScheduler, DPMSolverMultistepScheduler, DEISMultistepScheduler, HeunDiscreteScheduler
from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
import time
from huggingface_hub import HfApi
import torch
import sys

path = sys.argv[1]

api = HfApi()
start_time = time.time()
pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")

prompt = "a highly realistic photo of green turtle"
prompt = "an image of Santa Claus in light blue"
generator = torch.Generator(device="cuda").manual_seed(0)
image = pipe(prompt, generator=generator, num_inference_steps=25).images[0]
print("Time", time.time() - start_time)

path = "/home/patrick_huggingface_co/images/aa.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("https://huggingface.co./datasets/patrickvonplaten/images/blob/main/aa.png")