Krebzonide
commited on
Commit
·
89bcb6a
1
Parent(s):
ba9d526
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,7 @@ from diffusers import StableDiffusionXLPipeline, AutoencoderKL
|
|
2 |
import torch
|
3 |
import random
|
4 |
import os
|
5 |
-
#from controlnet_aux import OpenposeDetector
|
6 |
-
#from diffusers.utils import load_image
|
7 |
import gradio as gr
|
8 |
-
import gc
|
9 |
|
10 |
model_id = int(os.getenv("Model"))
|
11 |
|
@@ -44,15 +41,14 @@ css = """
|
|
44 |
}
|
45 |
"""
|
46 |
|
47 |
-
def generate(prompt, neg_prompt, samp_steps,
|
48 |
if seed < 0:
|
49 |
seed = random.randint(1,999999)
|
50 |
images = pipe(
|
51 |
prompt,
|
52 |
negative_prompt=neg_prompt,
|
53 |
num_inference_steps=samp_steps,
|
54 |
-
guidance_scale=
|
55 |
-
#cross_attention_kwargs={"scale": lora_scale},
|
56 |
num_images_per_prompt=batch_size,
|
57 |
height=height,
|
58 |
width=width,
|
@@ -105,17 +101,17 @@ with gr.Blocks(css=css) as demo:
|
|
105 |
submit_btn = gr.Button("Generate", elem_classes="btn-green")
|
106 |
with gr.Row():
|
107 |
samp_steps = gr.Slider(1, 50, value=20, step=1, label="Sampling steps")
|
108 |
-
|
109 |
batch_size = gr.Slider(1, 6, value=1, step=1, label="Batch size")
|
110 |
with gr.Row():
|
111 |
-
height = gr.Slider(label="Height", value=1024, minimum=
|
112 |
-
width = gr.Slider(label="Width", value=1024, minimum=
|
113 |
with gr.Row():
|
114 |
pixels = gr.Number(label="Pixel Ratio", value=1, interactive=False)
|
115 |
seed = gr.Number(label="Seed", value=-1, minimum=-1, precision=0)
|
116 |
-
gallery = gr.Gallery(label="Generated images"
|
117 |
ex = gr.Examples(examples=examples, inputs=[prompt, negative_prompt])
|
118 |
-
submit_btn.click(generate, [prompt, negative_prompt, samp_steps,
|
119 |
height.release(update_pixel_ratio, [height, width], [pixels, height], queue=False)
|
120 |
width.release(update_pixel_ratio, [width, height], [pixels, width], queue=False)
|
121 |
|
|
|
2 |
import torch
|
3 |
import random
|
4 |
import os
|
|
|
|
|
5 |
import gradio as gr
|
|
|
6 |
|
7 |
model_id = int(os.getenv("Model"))
|
8 |
|
|
|
41 |
}
|
42 |
"""
|
43 |
|
44 |
+
def generate(prompt, neg_prompt, samp_steps, cfg_scale, batch_size, seed, height, width, progress=gr.Progress(track_tqdm=True)):
|
45 |
if seed < 0:
|
46 |
seed = random.randint(1,999999)
|
47 |
images = pipe(
|
48 |
prompt,
|
49 |
negative_prompt=neg_prompt,
|
50 |
num_inference_steps=samp_steps,
|
51 |
+
guidance_scale=cfg_scale,
|
|
|
52 |
num_images_per_prompt=batch_size,
|
53 |
height=height,
|
54 |
width=width,
|
|
|
101 |
submit_btn = gr.Button("Generate", elem_classes="btn-green")
|
102 |
with gr.Row():
|
103 |
samp_steps = gr.Slider(1, 50, value=20, step=1, label="Sampling steps")
|
104 |
+
cfg_scale = gr.Slider(1, 10, value=3, step=0.5, label="Guidance scale")
|
105 |
batch_size = gr.Slider(1, 6, value=1, step=1, label="Batch size")
|
106 |
with gr.Row():
|
107 |
+
height = gr.Slider(label="Height", value=1024, minimum=8, maximum=2560, step=8)
|
108 |
+
width = gr.Slider(label="Width", value=1024, minimum=8, maximum=2560, step=8)
|
109 |
with gr.Row():
|
110 |
pixels = gr.Number(label="Pixel Ratio", value=1, interactive=False)
|
111 |
seed = gr.Number(label="Seed", value=-1, minimum=-1, precision=0)
|
112 |
+
gallery = gr.Gallery(label="Generated images")
|
113 |
ex = gr.Examples(examples=examples, inputs=[prompt, negative_prompt])
|
114 |
+
submit_btn.click(generate, [prompt, negative_prompt, samp_steps, cfg_scale, batch_size, seed, height, width], [gallery], queue=True)
|
115 |
height.release(update_pixel_ratio, [height, width], [pixels, height], queue=False)
|
116 |
width.release(update_pixel_ratio, [width, height], [pixels, width], queue=False)
|
117 |
|