ParahumanSkitter commited on
Commit
cf1dd6b
·
verified ·
1 Parent(s): 0a814f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -41
app.py CHANGED
@@ -75,45 +75,61 @@ def gen_fn(model_str, prompt, negative_prompt, guidance_scale, seed, clip_skip,
75
 
76
  return None
77
 
 
 
 
 
78
  def make_me():
79
- with gr.Row():
80
- with gr.Column(scale=1):
81
- txt_input = gr.Textbox(label='Your prompt:', lines=3, container=False, elem_id="custom_textbox", placeholder="Prompt")
82
- negative_txt_input = gr.Textbox(label='Negative prompt:', lines=3, container=False, elem_id="custom_negative_textbox", placeholder="Negative Prompt")
83
- with gr.Row():
84
- gen_button = gr.Button('Generate images', elem_id="custom_gen_button")
85
- stop_button = gr.Button('Stop', variant='secondary', interactive=False, elem_id="custom_stop_button")
86
-
87
- def on_generate_click():
88
- return gr.Button('Generate images', elem_id="custom_gen_button"), gr.Button('Stop', variant='secondary', interactive=True, elem_id="custom_stop_button")
89
-
90
- def on_stop_click():
91
- return gr.Button('Generate images', elem_id="custom_gen_button"), gr.Button('Stop', variant='secondary', interactive=False, elem_id="custom_stop_button")
92
-
93
- gen_button.click(on_generate_click, inputs=None, outputs=[gen_button, stop_button])
94
- stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
95
-
96
- with gr.Row():
97
- guidance_scale = gr.Slider(minimum=0, maximum=20, step=0.1, label='Guidance Scale', value=7.5)
98
- seed = gr.Slider(minimum=0, maximum=99999999, step=1, label='Seed', value=randint(0, 99999999))
99
- clip_skip = gr.Slider(minimum=0, maximum=5, step=1, label='CLIP Skip', value=1)
100
- scheduler = gr.Dropdown(['DDIM', 'PNDM', 'LMSDiscrete', 'EulerAncestralDiscrete', 'DPMSolverMultistep', 'HeunDiscrete', 'EulerDiscrete', 'DPMSolverSinglestep', 'DEISMultistep', 'UniPCMultistep'], label='Scheduler', value='DDIM')
101
- randomize_seed = gr.Checkbox(label='Randomize Seed', value=False)
102
-
103
- with gr.Row():
104
- output = [gr.Image(label=m, min_width=250, height=250, elem_id="custom_image") for m in default_models]
105
- current_models = [gr.Textbox(m, visible=False) for m in default_models]
106
- for m, o in zip(current_models, output):
107
- gen_event = gen_button.click(gen_fn, [m, txt_input, negative_txt_input, guidance_scale, seed, clip_skip, scheduler, randomize_seed], o)
108
- stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button], cancels=[gen_event])
109
-
110
- with gr.Accordion('Model selection', elem_id="custom_accordion"):
111
- model_choice = gr.CheckboxGroup(models, label=f'{num_models} different models selected', value=default_models, interactive=True, elem_id="custom_checkbox_group")
112
- model_choice.change(update_imgbox, model_choice, output)
113
- model_choice.change(extend_choices, model_choice, current_models)
114
-
115
- with gr.Row():
116
- gr.HTML("")
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  custom_css = """
119
  :root {
@@ -266,8 +282,6 @@ body {
266
  }
267
  """
268
 
269
- with gr.Blocks(css=custom_css) as demo:
270
- make_me()
271
-
272
  demo.queue(concurrency_count=500)
273
  demo.launch()
 
75
 
76
  return None
77
 
78
+ def insert_example_prompt(txt_input):
79
+ example_prompt = "Masterpiece, Highest Quality, Best Quality, Eye Catching, Award Winning, General, 1Girl, Long Black Hair, Wavy And Curly Hair, Green Eyes, Square Rimmed Glasses, Slim Bodied, Tall, Lithe, Petite, Smiling At Viewer, Looking At Viewer, Business Casual Clothing"
80
+ txt_input.value = example_prompt
81
+
82
  def make_me():
83
+ with gr.Blocks(css=custom_css) as demo:
84
+ # Add text and HTML link at the top
85
+ gr.Markdown("# Before you generate: Illustrious Diffusion uses a different prompting style than Pony Diffusion, relying less on booru tags and more on detail-oriented, natural language style prompts, please refer to the link provided for a guide on Illustrious prompting.")
86
+ gr.HTML('<p>Useful guide for how to prompt for Illustrious: <a href="https://civitai.com/articles/8380/tips-for-illustrious-xl-prompting-updates" target="_blank">Tips for Illustrious XL Prompting Updates</a>.</p>')
87
+
88
+ with gr.Row():
89
+ with gr.Column(scale=1):
90
+ txt_input = gr.Textbox(label='Your prompt:', lines=3, container=False, elem_id="custom_textbox", placeholder="Prompt")
91
+ negative_txt_input = gr.Textbox(label='Negative prompt:', lines=3, container=False, elem_id="custom_negative_textbox", placeholder="Negative Prompt")
92
+ with gr.Row():
93
+ gen_button = gr.Button('Generate images', elem_id="custom_gen_button")
94
+ stop_button = gr.Button('Stop', variant='secondary', interactive=False, elem_id="custom_stop_button")
95
+
96
+ def on_generate_click():
97
+ return gr.Button('Generate images', elem_id="custom_gen_button"), gr.Button('Stop', variant='secondary', interactive=True, elem_id="custom_stop_button")
98
+
99
+ def on_stop_click():
100
+ return gr.Button('Generate images', elem_id="custom_gen_button"), gr.Button('Stop', variant='secondary', interactive=False, elem_id="custom_stop_button")
101
+
102
+ gen_button.click(on_generate_click, inputs=None, outputs=[gen_button, stop_button])
103
+ stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
104
+
105
+ with gr.Row():
106
+ guidance_scale = gr.Slider(minimum=0, maximum=20, step=0.1, label='Guidance Scale', value=7.5)
107
+ seed = gr.Slider(minimum=0, maximum=99999999, step=1, label='Seed', value=randint(0, 99999999))
108
+ clip_skip = gr.Slider(minimum=0, maximum=5, step=1, label='CLIP Skip', value=1)
109
+ scheduler = gr.Dropdown(['DDIM', 'PNDM', 'LMSDiscrete', 'EulerAncestralDiscrete', 'DPMSolverMultistep', 'HeunDiscrete', 'EulerDiscrete', 'DPMSolverSinglestep', 'DEISMultistep', 'UniPCMultistep'], label='Scheduler', value='DDIM')
110
+ randomize_seed = gr.Checkbox(label='Randomize Seed', value=False)
111
+
112
+ with gr.Row():
113
+ output = [gr.Image(label=m, min_width=250, height=250, elem_id="custom_image") for m in default_models]
114
+ current_models = [gr.Textbox(m, visible=False) for m in default_models]
115
+ for m, o in zip(current_models, output):
116
+ gen_event = gen_button.click(gen_fn, [m, txt_input, negative_txt_input, guidance_scale, seed, clip_skip, scheduler, randomize_seed], o)
117
+ stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button], cancels=[gen_event])
118
+
119
+ with gr.Accordion('Model selection', elem_id="custom_accordion"):
120
+ model_choice = gr.CheckboxGroup(models, label=f'{num_models} different models selected', value=default_models, interactive=True, elem_id="custom_checkbox_group")
121
+ model_choice.change(update_imgbox, model_choice, output)
122
+ model_choice.change(extend_choices, model_choice, current_models)
123
+
124
+ with gr.Row():
125
+ gr.HTML("")
126
+
127
+ # Add the clickable element at the bottom
128
+ with gr.Row():
129
+ insert_example_button = gr.Button('Insert Example Prompt', variant='primary')
130
+ insert_example_button.click(insert_example_prompt, inputs=[], outputs=[txt_input])
131
+
132
+ return demo
133
 
134
  custom_css = """
135
  :root {
 
282
  }
283
  """
284
 
285
+ demo = make_me()
 
 
286
  demo.queue(concurrency_count=500)
287
  demo.launch()