Krebzonide commited on
Commit
7e9a760
·
1 Parent(s): f1ebf81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from diffusers import StableDiffusionXLPipeline, AutoencoderKL
2
  import torch
 
3
  #from controlnet_aux import OpenposeDetector
4
  #from diffusers.utils import load_image
5
  import gradio as gr
@@ -38,7 +39,9 @@ css = """
38
  }
39
  """
40
 
41
- def generate(prompt, neg_prompt, samp_steps, guide_scale, lora_scale, progress=gr.Progress(track_tqdm=True)):
 
 
42
  images = pipe(
43
  prompt,
44
  negative_prompt=neg_prompt,
@@ -47,7 +50,7 @@ def generate(prompt, neg_prompt, samp_steps, guide_scale, lora_scale, progress=g
47
  #cross_attention_kwargs={"scale": lora_scale},
48
  num_images_per_prompt=lora_scale,
49
  width=600,
50
- #generator=torch.manual_seed(97),
51
  ).images
52
  return [(img, f"Image {i+1}") for i, img in enumerate(images)]
53
 
@@ -57,13 +60,14 @@ with gr.Blocks(css=css) as demo:
57
  prompt = gr.Textbox(label="Prompt")
58
  negative_prompt = gr.Textbox(label="Negative Prompt")
59
  submit_btn = gr.Button("Generate", elem_classes="btn-green")
60
- gallery = gr.Gallery(label="Generated images", height=800)
61
  with gr.Row():
62
  samp_steps = gr.Slider(1, 50, value=20, step=1, label="Sampling steps")
63
  guide_scale = gr.Slider(1, 6, value=3, step=0.5, label="Guidance scale")
64
- lora_scale = gr.Slider(1, 6, value=1, step=1, label="LoRA power")
 
 
65
 
66
- submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, lora_scale], [gallery], queue=True)
67
 
68
  demo.queue(1)
69
  demo.launch(debug=True)
 
1
  from diffusers import StableDiffusionXLPipeline, AutoencoderKL
2
  import torch
3
+ import random
4
  #from controlnet_aux import OpenposeDetector
5
  #from diffusers.utils import load_image
6
  import gradio as gr
 
39
  }
40
  """
41
 
42
+ def generate(prompt, neg_prompt, samp_steps, guide_scale, batch_size, seed, progress=gr.Progress(track_tqdm=True)):
43
+ if seed < 0:
44
+ seed = random.randint(1,999999)
45
  images = pipe(
46
  prompt,
47
  negative_prompt=neg_prompt,
 
50
  #cross_attention_kwargs={"scale": lora_scale},
51
  num_images_per_prompt=lora_scale,
52
  width=600,
53
+ generator=torch.manual_seed(seed),
54
  ).images
55
  return [(img, f"Image {i+1}") for i, img in enumerate(images)]
56
 
 
60
  prompt = gr.Textbox(label="Prompt")
61
  negative_prompt = gr.Textbox(label="Negative Prompt")
62
  submit_btn = gr.Button("Generate", elem_classes="btn-green")
 
63
  with gr.Row():
64
  samp_steps = gr.Slider(1, 50, value=20, step=1, label="Sampling steps")
65
  guide_scale = gr.Slider(1, 6, value=3, step=0.5, label="Guidance scale")
66
+ batch_size = gr.Slider(1, 6, value=1, step=1, label="Batch size")
67
+ seed = gr.Number(label="seed", value="-1", precision=0)
68
+ gallery = gr.Gallery(label="Generated images", height=800)
69
 
70
+ submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed], [gallery], queue=True)
71
 
72
  demo.queue(1)
73
  demo.launch(debug=True)