ciCic commited on
Commit
313a5e9
1 Parent(s): a10df11
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -5,13 +5,13 @@ import torch
5
  from diffusers import AutoPipelineForText2Image, LCMScheduler
6
  from torchvision.transforms.functional import to_pil_image, center_crop, resize, to_tensor
7
 
8
- device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
9
 
10
  model_id = "Lykon/dreamshaper-7"
11
  adapter_id = "latent-consistency/lcm-lora-sdv1-5"
12
 
13
- # pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float16)
14
- pipe = AutoPipelineForText2Image.from_pretrained(model_id)
15
  pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
16
  pipe.to(device)
17
 
@@ -23,8 +23,8 @@ prompt = "Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"
23
 
24
 
25
  @torch.no_grad()
26
- def generate(prompt, guidance_scale):
27
- image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=guidance_scale).images[0]
28
  return image
29
 
30
 
@@ -37,7 +37,10 @@ def app():
37
  value=prompt,
38
  ),
39
  gr.Slider(2, 20, value=7.5, label="Guidance Scale",
40
- info="Higher scale depicts more creativity")],
 
 
 
41
  gr.Image(type="pil",
42
  height=512,
43
  width=512
 
5
  from diffusers import AutoPipelineForText2Image, LCMScheduler
6
  from torchvision.transforms.functional import to_pil_image, center_crop, resize, to_tensor
7
 
8
+ device = 'cpu'
9
 
10
  model_id = "Lykon/dreamshaper-7"
11
  adapter_id = "latent-consistency/lcm-lora-sdv1-5"
12
 
13
+ pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float16)
14
+ # pipe = AutoPipelineForText2Image.from_pretrained(model_id)
15
  pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
16
  pipe.to(device)
17
 
 
23
 
24
 
25
  @torch.no_grad()
26
+ def generate(prompt, guidance_scale, num_inference_steps):
27
+ image = pipe(prompt=prompt, num_inference_steps=num_inference_steps, guidance_scale=guidance_scale).images[0]
28
  return image
29
 
30
 
 
37
  value=prompt,
38
  ),
39
  gr.Slider(2, 20, value=7.5, label="Guidance Scale",
40
+ info="Higher scale depicts more creativity"),
41
+ gr.Slider(1, 50, value=4, label="Inference steps")
42
+ ],
43
+
44
  gr.Image(type="pil",
45
  height=512,
46
  width=512