DigiP-AI commited on
Commit
caab276
·
verified ·
1 Parent(s): 1b902de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -56
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
- examples = [
194
- "a beautiful woman with blonde hair and blue eyes",
195
- "a beautiful woman with brown hair and grey eyes",
196
- "a beautiful woman with black hair and brown eyes",
197
- ]
198
-
199
-
 
 
 
 
 
200
 
201
  with gr.Blocks(css=css, theme=theme) as app:
202
  with gr.Tab("Basic Settings"):
203
- with gr.Column(elem_id="col-container"):
204
- with gr.Row():
205
- prompt = gr.Textbox(placeholder="Enter the image description...", show_label=True, label='Image Prompt ✍️', lines=3, show_copy_button = True)
206
-
207
- with gr.Row():
208
- gr.Examples(
209
- examples = examples,
210
- inputs = [prompt],
211
- )
212
- with gr.Row():
213
- 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',
214
- 'Juggernaut XL', 'DreamShaper XL',
215
- 'SDXL Niji', 'Cinemax SDXL', 'NightVision XL'])
216
- with gr.Tab("Extended settings"):
217
- with gr.Row():
218
- 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")
219
- with gr.Row():
220
- sampler = gr.Dropdown(value="DPM++ 2M Karras", show_label=True, label="Sampling Method:", choices=[
221
- "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"])
222
- with gr.Row():
223
- steps = gr.Slider(show_label=True, label="Sampling Steps:", minimum=1, maximum=50, value=35, step=1)
224
- with gr.Row():
225
- cfg_scale = gr.Slider(show_label=True, label="CFG Scale:", minimum=1, maximum=20, value=7, step=1)
226
- with gr.Row():
227
- seed = gr.Number(show_label=True, label="Seed:", minimum=-1, maximum=1000000, value=-1, step=1)
228
- with gr.Row():
229
- width = gr.Slider(label="Width", minimum=512, maximum=2048, step=8, value=896, interactive=True,)
230
- with gr.Row():
231
- height = gr.Slider(label="Height", minimum=512, maximum=2048, step=8, value=1152,interactive=True,)
 
 
 
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__":