patrickvonplaten commited on
Commit
78ed83d
1 Parent(s): 9445050
Files changed (1) hide show
  1. run_local.py +23 -11
run_local.py CHANGED
@@ -1,18 +1,30 @@
1
  #!/usr/bin/env python3
2
- from diffusers import DiffusionPipeline
 
 
3
  import torch
4
- import os
5
-
6
  import sys
7
 
8
- local_path = sys.argv[1]
9
- local_path = os.path.abspath(local_path)
10
-
11
- prompts = ["astronaut on mars", "Barack Obama smiling with a big grin"]
12
 
13
- pipe = DiffusionPipeline.from_pretrained(local_path, torch_dtype=torch.float16)
 
 
 
14
  pipe = pipe.to("cuda")
15
 
16
- for prompt in prompts:
17
- image = pipe(prompt).images[0]
18
- image.save(f"/home/patrick_huggingface_co/images/a_{'_'.join(prompt.split())}.png")
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #!/usr/bin/env python3
2
+ from diffusers import StableDiffusionPipeline, DPMSolverSinglestepScheduler, DPMSolverMultistepScheduler, DEISMultistepScheduler, HeunDiscreteScheduler
3
+ import time
4
+ from huggingface_hub import HfApi
5
  import torch
 
 
6
  import sys
7
 
8
+ path = sys.argv[1]
 
 
 
9
 
10
+ api = HfApi()
11
+ start_time = time.time()
12
+ pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
13
+ pipe.scheduler = HeunDiscreteScheduler.from_config(pipe.scheduler.config)
14
  pipe = pipe.to("cuda")
15
 
16
+ prompt = "a highly realistic photo of green turtle"
17
+ generator = torch.Generator(device="cuda").manual_seed(0)
18
+ image = pipe(prompt, generator=generator, num_inference_steps=25).images[0]
19
+ print("Time", time.time() - start_time)
20
+
21
+ path = "/home/patrick_huggingface_co/images/aa.png"
22
+ image.save(path)
23
+
24
+ api.upload_file(
25
+ path_or_fileobj=path,
26
+ path_in_repo=path.split("/")[-1],
27
+ repo_id="patrickvonplaten/images",
28
+ repo_type="dataset",
29
+ )
30
+ print("https://huggingface.co/datasets/patrickvonplaten/images/blob/main/aa.png")