gunship999 commited on
Commit
cfb8a93
·
verified ·
1 Parent(s): a6e6518

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +103 -108
app.py CHANGED
@@ -125,12 +125,7 @@ def add_gallery(image, model_str, gallery):
125
  return gallery
126
 
127
 
128
- CSS="""
129
- .gradio-container { max-width: 1200px; margin: 0 auto; !important; }
130
- .output { width=112px; height=112px; max_width=112px; max_height=112px; !important; }
131
- .gallery { min_width=512px; min_height=512px; max_height=512px; !important; }
132
- .guide { text-align: center; !important; }
133
- """
134
 
135
  js_func = """
136
  function refresh() {
@@ -158,108 +153,108 @@ js_AutoSave="""
158
 
159
  """
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=CSS) as demo:
162
- # with gr.Blocks(theme='JohnSmith9982/small_and_pretty', fill_width=True, css=CSS, js=js_func) as demo:
163
- gr.HTML("")
164
- with gr.Tab('6 Models'):
165
- with gr.Column(scale=2):
166
- with gr.Group():
167
- txt_input = gr.Textbox(label='Your prompt:', value=preSetPrompt, lines=3, autofocus=1)
168
- neg_input = gr.Textbox(label='Negative prompt:', value=negPreSetPrompt, lines=1)
169
- with gr.Accordion("Advanced", open=False, visible=True):
170
- with gr.Row():
171
- width = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
172
- height = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
173
- with gr.Row():
174
- steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
175
- cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
176
- seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
177
- seed_rand = gr.Button("Randomize Seed 🎲", size="sm", variant="secondary")
178
- seed_rand.click(randomize_seed, None, [seed], queue=False)
179
- with gr.Row():
180
- gen_button = gr.Button(f'Generate up to {int(num_models)} images', variant='primary', scale=3)
181
- random_button = gr.Button(f'Randomize Models', variant='secondary', scale=1)
182
- #stop_button = gr.Button('Stop', variant='stop', interactive=False, scale=1)
183
- #gen_button.click(lambda: gr.update(interactive=True), None, stop_button)
184
- gr.Markdown("", elem_classes="guide")
185
-
186
- with gr.Column(scale=1):
187
- with gr.Group():
188
  with gr.Row():
189
- output = [gr.Image(label=m, show_download_button=True, elem_classes="output",
190
- interactive=False, width=112, height=112, show_share_button=False, format="png",
191
- visible=True) for m in default_models]
192
- current_models = [gr.Textbox(m, visible=False) for m in default_models]
193
-
194
- with gr.Column(scale=2):
195
- gallery = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
196
- interactive=False, show_share_button=False, container=True, format="png",
197
- preview=True, object_fit="cover", columns=2, rows=2)
198
-
199
- for m, o in zip(current_models, output):
200
- gen_event = gr.on(triggers=[gen_button.click, txt_input.submit], fn=gen_fn,
201
- inputs=[m, txt_input, neg_input, height, width, steps, cfg, seed], outputs=[o],
202
- concurrency_limit=None, queue=False) # Be sure to delete ", queue=False" when activating the stop button
203
- o.change(add_gallery, [o, m, gallery], [gallery])
204
- #stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
205
-
206
- with gr.Column(scale=4):
207
- with gr.Accordion('Model selection'):
208
- model_choice = gr.CheckboxGroup(models, label = f'Choose up to {int(num_models)} different models from the {len(models)} available!', value=default_models, interactive=True)
209
- model_choice.change(update_imgbox, model_choice, output)
210
- model_choice.change(extend_choices, model_choice, current_models)
211
- random_button.click(random_choices, None, model_choice)
212
-
213
- with gr.Tab('Single model'):
214
- with gr.Column(scale=2):
215
- model_choice2 = gr.Dropdown(models, label='Choose model', value=models[0])
216
- with gr.Group():
217
- # global preSetPrompt
218
- # global negPreSetPrompt
219
- txt_input2 = gr.Textbox(label='Your prompt:', value = preSetPrompt, lines=3, autofocus=1)
220
- neg_input2 = gr.Textbox(label='Negative prompt:', value=negPreSetPrompt, lines=1)
221
- with gr.Accordion("Advanced", open=False, visible=True):
222
- with gr.Row():
223
- width2 = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
224
- height2 = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
225
- with gr.Row():
226
- steps2 = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
227
- cfg2 = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
228
- seed2 = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
229
- seed_rand2 = gr.Button("Randomize Seed", size="sm", variant="secondary")
230
- seed_rand2.click(randomize_seed, None, [seed2], queue=False)
231
- num_images = gr.Slider(1, max_images, value=max_images, step=1, label='Number of images')
232
- with gr.Row():
233
- gen_button2 = gr.Button('Let the machine halucinate', variant='primary', scale=2)
234
- #stop_button2 = gr.Button('Stop', variant='stop', interactive=False, scale=1)
235
- #gen_button2.click(lambda: gr.update(interactive=True), None, stop_button2)
236
-
237
- with gr.Column(scale=1):
238
- with gr.Group():
239
  with gr.Row():
240
- output2 = [gr.Image(label='', show_download_button=True, elem_classes="output",
241
- interactive=False, width=112, height=112, visible=True, format="png",
242
- show_share_button=False, show_label=False) for _ in range(max_images)]
243
-
244
- with gr.Column(scale=2):
245
- gallery2 = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
246
- interactive=False, show_share_button=True, container=True, format="png",
247
- preview=True, object_fit="cover", columns=2, rows=2)
248
-
249
- for i, o in enumerate(output2):
250
- img_i = gr.Number(i, visible=False)
251
- num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o, queue=False)
252
- gen_event2 = gr.on(triggers=[gen_button2.click, txt_input2.submit],
253
- fn=lambda i, n, m, t1, t2, n1, n2, n3, n4, n5: gen_fn(m, t1, t2, n1, n2, n3, n4, n5) if (i < n) else None,
254
- inputs=[img_i, num_images, model_choice2, txt_input2, neg_input2,
255
- height2, width2, steps2, cfg2, seed2], outputs=[o],
256
- concurrency_limit=None, queue=False) # Be sure to delete ", queue=False" when activating the stop button
257
- o.change(add_gallery, [o, model_choice2, gallery2], [gallery2])
258
- #stop_button2.click(lambda: gr.update(interactive=False), None, stop_button2, cancels=[gen_event2])
259
-
260
- # gr.Markdown(js_AutoSave)
261
- gr.Markdown("")
262
-
263
- # demo.queue(default_concurrency_limit=200, max_size=200)
264
- demo.launch(show_api=False, max_threads=400)
265
- # demo.launch(show_api=False, max_threads=400, js=js_AutoSave)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  return gallery
126
 
127
 
128
+
 
 
 
 
 
129
 
130
  js_func = """
131
  function refresh() {
 
153
 
154
  """
155
 
156
+
157
+ CSS="""
158
+ .gradio-container { max-width: 1200px; margin: 0 auto; background: linear-gradient(to bottom, #1a1a1a, #2d2d2d); !important; }
159
+ .output {
160
+ width: 112px;
161
+ height: 112px;
162
+ border-radius: 10px;
163
+ box-shadow: 0 4px 8px rgba(0,0,0,0.2);
164
+ transition: transform 0.2s;
165
+ !important;
166
+ }
167
+ .output:hover {
168
+ transform: scale(1.05);
169
+ }
170
+ .gallery {
171
+ min-width: 512px;
172
+ min-height: 512px;
173
+ max-height: 512px;
174
+ border-radius: 15px;
175
+ box-shadow: 0 6px 12px rgba(0,0,0,0.3);
176
+ !important;
177
+ }
178
+ .guide { text-align: center; color: #e0e0e0; !important; }
179
+ .primary-btn {
180
+ background: linear-gradient(45deg, #4a90e2, #357abd);
181
+ border-radius: 8px;
182
+ transition: all 0.3s ease;
183
+ }
184
+ .primary-btn:hover {
185
+ transform: translateY(-2px);
186
+ box-shadow: 0 5px 15px rgba(74,144,226,0.3);
187
+ }
188
+ """
189
+
190
  with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=CSS) as demo:
191
+ gr.HTML("""<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fgunship999-SexyImages.hf.space">
192
+ <img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgunship999-SexyImages.hf.space&countColor=%23263759" />
193
+ </a>""")
194
+
195
+ with gr.Column(scale=2):
196
+ with gr.Group():
197
+ txt_input = gr.Textbox(
198
+ label='Your prompt:',
199
+ value=preSetPrompt,
200
+ lines=3,
201
+ autofocus=1,
202
+ container=False,
203
+ elem_classes="modern-input"
204
+ )
205
+ neg_input = gr.Textbox(
206
+ label='Negative prompt:',
207
+ value=negPreSetPrompt,
208
+ lines=1
209
+ )
210
+ with gr.Accordion("Advanced Settings", open=False):
 
 
 
 
 
 
211
  with gr.Row():
212
+ width = gr.Slider(label="Width", maximum=1216, step=32, value=0)
213
+ height = gr.Slider(label="Height", maximum=1216, step=32, value=0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  with gr.Row():
215
+ steps = gr.Slider(label="Steps", maximum=100, step=1, value=0)
216
+ cfg = gr.Slider(label="Guidance Scale", maximum=30.0, step=0.1, value=0)
217
+ seed = gr.Slider(label="Seed", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
218
+ seed_rand = gr.Button("🎲", size="sm", elem_classes="primary-btn")
219
+ seed_rand.click(randomize_seed, None, [seed], queue=False)
220
+
221
+ with gr.Row():
222
+ gen_button = gr.Button(
223
+ f'Generate {int(num_models)} Images',
224
+ variant='primary',
225
+ scale=3,
226
+ elem_classes="primary-btn"
227
+ )
228
+ random_button = gr.Button(
229
+ 'Randomize Models',
230
+ variant='secondary',
231
+ scale=1
232
+ )
233
+
234
+ with gr.Column(scale=1):
235
+ with gr.Group():
236
+ with gr.Row():
237
+ output = [gr.Image(label=m, show_download_button=True,
238
+ elem_classes="output",
239
+ interactive=False, width=112, height=112,
240
+ show_share_button=False, format="png",
241
+ visible=True) for m in default_models]
242
+ current_models = [gr.Textbox(m, visible=False)
243
+ for m in default_models]
244
+
245
+ with gr.Column(scale=2):
246
+ gallery = gr.Gallery(
247
+ label="Generated Images",
248
+ show_download_button=True,
249
+ elem_classes="gallery",
250
+ interactive=False,
251
+ show_share_button=False,
252
+ container=True,
253
+ format="png",
254
+ preview=True,
255
+ object_fit="cover",
256
+ columns=2,
257
+ rows=2
258
+ )
259
+
260
+ demo.launch(show_api=False, max_threads=400)