Update app.py
Browse files
app.py
CHANGED
|
@@ -20,17 +20,6 @@ from fastapi import FastAPI
|
|
| 20 |
|
| 21 |
app = FastAPI()
|
| 22 |
|
| 23 |
-
# CSS to style the app
|
| 24 |
-
css = """
|
| 25 |
-
#generate {
|
| 26 |
-
width: 75%;
|
| 27 |
-
}
|
| 28 |
-
#image_output {
|
| 29 |
-
height: 100% !important;
|
| 30 |
-
}
|
| 31 |
-
.gradio-container {background-color: MediumAquaMarine}
|
| 32 |
-
footer{display:none !important}
|
| 33 |
-
"""
|
| 34 |
|
| 35 |
def query(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed, width, height):
|
| 36 |
result = {"prompt": prompt,"negative_prompt": negative_prompt,"task": task,"steps": steps,"sampler": sampler,"cfg_scale": cfg_scale,"seed": seed, "width": width, "height": height}
|
|
@@ -190,55 +179,54 @@ def mirror(image_output, scale_by, method, gfpgan, codeformer):
|
|
| 190 |
img = Image.open(BytesIO(response2.content))
|
| 191 |
return img
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
with gr.Blocks(css=css, theme=theme) as app:
|
| 202 |
with gr.Tab("Basic Settings"):
|
| 203 |
-
with gr.
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
)
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
with gr.
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
-
with gr.Column():
|
| 234 |
-
text_button = gr.Button("Generate image", variant="primary", interactive=True, elem_id="generate")
|
| 235 |
-
with gr.Column():
|
| 236 |
-
image_output = gr.Image(show_download_button=True, interactive=False, label='Generated Image 🌄', show_share_button=False, format="png", type="filepath", elem_id="gallery")
|
| 237 |
-
|
| 238 |
-
text_button.click(query, inputs=[prompt, negative_prompt, task, steps, sampler, cfg_scale, seed, width, height], outputs=image_output, concurrency_limit=48)
|
| 239 |
-
clear_prompt =gr.Button("Clear 🗑️",variant="primary", elem_id="clear_button")
|
| 240 |
-
clear_prompt.click(lambda: (None, None), None, [prompt, image_output], queue=False, show_api=False)
|
| 241 |
-
|
| 242 |
|
| 243 |
app.queue(default_concurrency_limit=200, max_size=200) # <-- Sets up a queue with default parameters
|
| 244 |
if __name__ == "__main__":
|
|
|
|
| 20 |
|
| 21 |
app = FastAPI()
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
def query(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed, width, height):
|
| 25 |
result = {"prompt": prompt,"negative_prompt": negative_prompt,"task": task,"steps": steps,"sampler": sampler,"cfg_scale": cfg_scale,"seed": seed, "width": width, "height": height}
|
|
|
|
| 179 |
img = Image.open(BytesIO(response2.content))
|
| 180 |
return img
|
| 181 |
|
| 182 |
+
# CSS to style the app
|
| 183 |
+
css = """
|
| 184 |
+
.gradio-container {background-color: MediumAquaMarine}
|
| 185 |
+
#app-container {
|
| 186 |
+
max-width: 930px;
|
| 187 |
+
margin-left: auto;
|
| 188 |
+
margin-right: auto;
|
| 189 |
+
}
|
| 190 |
+
footer {
|
| 191 |
+
visibility: hidden;
|
| 192 |
+
}
|
| 193 |
+
"""
|
| 194 |
|
| 195 |
with gr.Blocks(css=css, theme=theme) as app:
|
| 196 |
with gr.Tab("Basic Settings"):
|
| 197 |
+
with gr.Row():
|
| 198 |
+
prompt = gr.Textbox(placeholder="Enter the image description...", show_label=True, label='Image Prompt ✍️', lines=3, show_copy_button = True)
|
| 199 |
+
with gr.Row():
|
| 200 |
+
task = gr.Radio(interactive=True, value="Stable Diffusion XL 1.0", show_label=True, label="Model of neural network 🧠 ", choices=['Stable Diffusion XL 1.0', 'Crystal Clear XL',
|
| 201 |
+
'Juggernaut XL', 'DreamShaper XL',
|
| 202 |
+
'SDXL Niji', 'Cinemax SDXL', 'NightVision XL'])
|
| 203 |
+
with gr.Tab("Extended settings"):
|
| 204 |
+
with gr.Row():
|
| 205 |
+
negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=True, label='Negative Prompt:', lines=3, value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry")
|
| 206 |
+
|
| 207 |
+
with gr.Row():
|
| 208 |
+
sampler = gr.Dropdown(value="DPM++ 2M Karras", show_label=True, label="Sampling Method:", choices=[
|
| 209 |
+
"DPM++ 2M Karras", "DPM++ 2S a Karras", "DPM2 a Karras", "DPM2 Karras", "DPM++ SDE Karras", "DEIS", "LMS", "DPM Adaptive", "DPM++ 2M", "DPM2 Ancestral", "DPM++ S", "DPM++ SDE", "DDPM", "DPM Fast", "dpmpp_2s_ancestral", "Euler", "Euler CFG PP", "Euler a", "Euler Ancestral", "Euler+beta", "Heun", "Heun PP2", "DDIM", "LMS Karras", "PLMS", "UniPC", "UniPC BH2"])
|
| 210 |
+
with gr.Row():
|
| 211 |
+
steps = gr.Slider(show_label=True, label="Sampling Steps:", minimum=1, maximum=50, value=35, step=1)
|
| 212 |
+
with gr.Row():
|
| 213 |
+
cfg_scale = gr.Slider(show_label=True, label="CFG Scale:", minimum=1, maximum=20, value=7, step=1)
|
| 214 |
+
with gr.Row():
|
| 215 |
+
seed = gr.Number(show_label=True, label="Seed:", minimum=-1, maximum=1000000, value=-1, step=1)
|
| 216 |
+
with gr.Row():
|
| 217 |
+
width = gr.Slider(label="Width", minimum=512, maximum=2048, step=8, value=896, interactive=True,)
|
| 218 |
+
with gr.Row():
|
| 219 |
+
height = gr.Slider(label="Height", minimum=512, maximum=2048, step=8, value=1152,interactive=True,)
|
| 220 |
+
|
| 221 |
+
with gr.Column():
|
| 222 |
+
text_button = gr.Button("Generate image", variant="primary", interactive=True, elem_id="generate")
|
| 223 |
+
with gr.Column():
|
| 224 |
+
image_output = gr.Image(show_download_button=True, interactive=False, label='Generated Image 🌄', show_share_button=False, format="png", type="filepath", elem_id="gallery")
|
| 225 |
+
|
| 226 |
+
text_button.click(query, inputs=[prompt, negative_prompt, task, steps, sampler, cfg_scale, seed, width, height], outputs=image_output, concurrency_limit=48)
|
| 227 |
+
clear_prompt =gr.Button("Clear 🗑️",variant="primary", elem_id="clear_button")
|
| 228 |
+
clear_prompt.click(lambda: (None, None), None, [prompt, image_output], queue=False, show_api=False)
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
app.queue(default_concurrency_limit=200, max_size=200) # <-- Sets up a queue with default parameters
|
| 232 |
if __name__ == "__main__":
|