patrickvonplaten commited on
Commit
056c912
2 Parent(s): d4bb530 2f0087d

Merge branch 'main' of https://huggingface.co/diffusers/tools into main

Browse files
Files changed (1) hide show
  1. run_local.py +5 -1
run_local.py CHANGED
@@ -2,14 +2,18 @@
2
  from diffusers import StableDiffusionPipeline, DPMSolverSinglestepScheduler, DPMSolverMultistepScheduler, DEISMultistepScheduler, HeunDiscreteScheduler
3
  from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
4
  import time
 
5
  from huggingface_hub import HfApi
6
  import torch
7
  import sys
 
8
 
9
  path = sys.argv[1]
10
 
11
  api = HfApi()
12
  start_time = time.time()
 
 
13
  pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
14
  pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
15
  pipe = pipe.to("cuda")
@@ -20,7 +24,7 @@ generator = torch.Generator(device="cuda").manual_seed(0)
20
  image = pipe(prompt, generator=generator, num_inference_steps=15).images[0]
21
  print("Time", time.time() - start_time)
22
 
23
- path = "/home/patrick_huggingface_co/images/aa.png"
24
  image.save(path)
25
 
26
  api.upload_file(
 
2
  from diffusers import StableDiffusionPipeline, DPMSolverSinglestepScheduler, DPMSolverMultistepScheduler, DEISMultistepScheduler, HeunDiscreteScheduler
3
  from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
4
  import time
5
+ import os
6
  from huggingface_hub import HfApi
7
  import torch
8
  import sys
9
+ from pathlib import Path
10
 
11
  path = sys.argv[1]
12
 
13
  api = HfApi()
14
  start_time = time.time()
15
+ #pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16, device_map="auto")
16
+ #pipe.scheduler = HeunDiscreteScheduler.from_config(pipe.scheduler.config)
17
  pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
18
  pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
19
  pipe = pipe.to("cuda")
 
24
  image = pipe(prompt, generator=generator, num_inference_steps=15).images[0]
25
  print("Time", time.time() - start_time)
26
 
27
+ path = os.path.join(Path.home(), "images", "aa.png")
28
  image.save(path)
29
 
30
  api.upload_file(