adamelliotfields commited on
Commit
b70fffe
1 Parent(s): c70346f

Remove accordion menu

Browse files
Files changed (3) hide show
  1. app.css +3 -8
  2. app.js +0 -14
  3. app.py +281 -282
app.css CHANGED
@@ -15,9 +15,6 @@
15
  width: auto;
16
  margin-right: 4px;
17
  }
18
- .accordion .tabitem > div {
19
- --block-border-width: 1px;
20
- }
21
 
22
  #embeddings .token {
23
  border-radius: 4px;
@@ -33,7 +30,7 @@
33
  overflow-y: auto;
34
  }
35
  .gallery, .gallery .grid-wrap {
36
- height: calc(100vh - 400px);
37
  max-height: none;
38
  }
39
 
@@ -45,10 +42,6 @@
45
  max-width: 42px;
46
  }
47
 
48
- .image-container {
49
- max-height: calc(100vh - 480px);
50
- }
51
-
52
  #intro {
53
  margin-bottom: 8px !important;
54
  }
@@ -132,9 +125,11 @@
132
  }
133
  .tab-nav {
134
  margin-bottom: 16px;
 
135
  }
136
  .tab-nav > button {
137
  padding-bottom: 8px;
 
138
  }
139
 
140
  @keyframes spin {
 
15
  width: auto;
16
  margin-right: 4px;
17
  }
 
 
 
18
 
19
  #embeddings .token {
20
  border-radius: 4px;
 
30
  overflow-y: auto;
31
  }
32
  .gallery, .gallery .grid-wrap {
33
+ height: calc(100vh - 422px);
34
  max-height: none;
35
  }
36
 
 
42
  max-width: 42px;
43
  }
44
 
 
 
 
 
45
  #intro {
46
  margin-bottom: 8px !important;
47
  }
 
125
  }
126
  .tab-nav {
127
  margin-bottom: 16px;
128
+ flex-wrap: nowrap;
129
  }
130
  .tab-nav > button {
131
  padding-bottom: 8px;
132
+ text-wrap: wrap;
133
  }
134
 
135
  @keyframes spin {
app.js CHANGED
@@ -1,18 +1,4 @@
1
  () =>{
2
- const menu = document.querySelector("#menu");
3
- const menuButton = menu.querySelector("button");
4
- const content = document.querySelector("#content");
5
-
6
- const updateMenu = () => {
7
- const isOpen = menuButton.classList.contains("open");
8
- content.style.display = isOpen ? "none" : "flex";
9
- content.style.marginTop = isOpen ? "0" : "40px";
10
- };
11
-
12
- const observer = new MutationObserver(updateMenu);
13
- observer.observe(menuButton, { attributes: true, attributeFilter: ["class"] });
14
- updateMenu();
15
-
16
  if (window.location.hostname.endsWith(".hf.space")) {
17
  const hfHeader = document.getElementById("huggingface-space-header");
18
  if (hfHeader) {
 
1
  () =>{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  if (window.location.hostname.endsWith(".hf.space")) {
3
  const hfHeader = document.getElementById("huggingface-space-header");
4
  if (hfHeader) {
app.py CHANGED
@@ -134,305 +134,305 @@ with gr.Blocks(
134
 
135
  gr.HTML(read_file("./partials/intro.html"))
136
 
137
- with gr.Accordion(
138
- elem_classes=["accordion"],
139
- elem_id="menu",
140
- label="Menu",
141
- open=False,
142
- ):
143
- with gr.Tabs():
144
- with gr.TabItem("⚙️ Settings"):
145
  with gr.Group():
146
- negative_prompt = gr.Textbox(
147
- value="nsfw+",
148
- label="Negative Prompt",
149
- lines=2,
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  )
151
 
152
- with gr.Row():
153
- model = gr.Dropdown(
154
- choices=Config.MODELS,
155
- filterable=False,
156
- value=Config.MODEL,
157
- label="Model",
158
- min_width=240,
159
- )
160
- scheduler = gr.Dropdown(
161
- choices=Config.SCHEDULERS.keys(),
162
- value=Config.SCHEDULER,
163
- elem_id="scheduler",
164
- label="Scheduler",
165
- filterable=False,
166
- )
 
 
 
 
 
 
 
 
 
 
167
 
168
- with gr.Row():
169
- styles = json.loads(read_file("data/styles.json"))
170
- style_ids = list(styles.keys())
171
- style_ids = [sid for sid in style_ids if not sid.startswith("_")]
172
- style = gr.Dropdown(
173
- value=Config.STYLE,
174
- label="Style",
175
- min_width=240,
176
- choices=[("None", "none")]
177
- + [(styles[sid]["name"], sid) for sid in style_ids],
178
- )
179
- embeddings = gr.Dropdown(
180
- elem_id="embeddings",
181
- label="Embeddings",
182
- choices=[(f"<{e}>", e) for e in Config.EMBEDDINGS],
183
- multiselect=True,
184
- value=[Config.EMBEDDING],
185
- min_width=240,
186
- )
187
 
188
- with gr.Row():
189
- with gr.Group(elem_classes=["gap-0"]):
190
- lora_1 = gr.Dropdown(
191
- min_width=240,
192
- label="LoRA #1",
193
- value="none",
194
- choices=[("None", "none")]
195
- + [
196
- (lora["name"], lora_id)
197
- for lora_id, lora in Config.CIVIT_LORAS.items()
198
- ],
199
- )
200
- lora_1_weight = gr.Slider(
201
- value=0.0,
202
- minimum=0.0,
203
- maximum=1.0,
204
- step=0.1,
205
- show_label=False,
206
- )
207
- with gr.Group(elem_classes=["gap-0"]):
208
- lora_2 = gr.Dropdown(
209
- min_width=240,
210
- label="LoRA #2",
211
- value="none",
212
- choices=[("None", "none")]
213
- + [
214
- (lora["name"], lora_id)
215
- for lora_id, lora in Config.CIVIT_LORAS.items()
216
- ],
217
- )
218
- lora_2_weight = gr.Slider(
219
- value=0.0,
220
- minimum=0.0,
221
- maximum=1.0,
222
- step=0.1,
223
- show_label=False,
224
- )
225
-
226
- with gr.Row():
227
- guidance_scale = gr.Slider(
228
- value=Config.GUIDANCE_SCALE,
229
- label="Guidance Scale",
230
- minimum=1.0,
231
- maximum=15.0,
232
- step=0.1,
233
- )
234
- inference_steps = gr.Slider(
235
- value=Config.INFERENCE_STEPS,
236
- label="Inference Steps",
237
- minimum=1,
238
- maximum=50,
239
- step=1,
240
- )
241
- deepcache_interval = gr.Slider(
242
- value=Config.DEEPCACHE_INTERVAL,
243
- label="DeepCache",
244
- minimum=1,
245
- maximum=4,
246
- step=1,
247
- )
248
 
249
- with gr.Row():
250
- width = gr.Slider(
251
- value=Config.WIDTH,
252
- label="Width",
253
- minimum=256,
254
- maximum=768,
255
- step=32,
256
- )
257
- height = gr.Slider(
258
- value=Config.HEIGHT,
259
- label="Height",
260
- minimum=256,
261
- maximum=768,
262
- step=32,
263
- )
264
- aspect_ratio = gr.Dropdown(
265
- value=f"{Config.WIDTH},{Config.HEIGHT}",
266
- label="Aspect Ratio",
267
- filterable=False,
268
- choices=[
269
- ("Custom", None),
270
- ("4:7 (384x672)", "384,672"),
271
- ("7:9 (448x576)", "448,576"),
272
- ("1:1 (512x512)", "512,512"),
273
- ("9:7 (576x448)", "576,448"),
274
- ("7:4 (672x384)", "672,384"),
275
- ],
276
- )
277
 
278
- with gr.Row():
279
- file_format = gr.Dropdown(
280
- choices=["png", "jpeg", "webp"],
281
- label="File Format",
282
- filterable=False,
283
- value="png",
284
- )
285
- num_images = gr.Dropdown(
286
- choices=list(range(1, 5)),
287
- value=Config.NUM_IMAGES,
288
- filterable=False,
289
- label="Images",
290
- )
291
- scale = gr.Dropdown(
292
- choices=[(f"{s}x", s) for s in Config.SCALES],
293
- filterable=False,
294
- value=Config.SCALE,
295
- label="Scale",
296
- )
297
- seed = gr.Number(
298
- value=Config.SEED,
299
- label="Seed",
300
- minimum=-1,
301
- maximum=(2**64) - 1,
302
- )
303
 
304
- with gr.Row():
305
- use_karras = gr.Checkbox(
306
- elem_classes=["checkbox"],
307
- label="Karras σ",
308
- value=True,
309
- )
310
- use_taesd = gr.Checkbox(
311
- elem_classes=["checkbox"],
312
- label="Tiny VAE",
313
- value=False,
314
- )
315
- use_freeu = gr.Checkbox(
316
- elem_classes=["checkbox"],
317
- label="FreeU",
318
- value=False,
319
- )
320
- use_clip_skip = gr.Checkbox(
321
- elem_classes=["checkbox"],
322
- label="Clip skip",
323
- value=False,
324
- )
325
 
326
- # img2img tab
327
- with gr.TabItem("🖼️ Image"):
328
- with gr.Group():
329
- with gr.Row():
330
- image_prompt = gr.Image(
331
- show_share_button=False,
332
- label="Initial Image",
333
- min_width=320,
334
- format="png",
335
- type="pil",
336
- )
337
- ip_image_prompt = gr.Image(
338
- show_share_button=False,
339
- label="IP-Adapter Image",
340
- min_width=320,
341
- format="png",
342
- type="pil",
343
- )
 
 
 
 
 
344
 
345
- with gr.Row():
346
- image_select = gr.Dropdown(
347
- info="Use an initial image from the gallery",
348
- choices=[("None", -1)],
349
- label="Gallery Image",
350
- interactive=True,
351
- filterable=False,
352
- value=-1,
353
- )
354
- ip_image_select = gr.Dropdown(
355
- info="Use an IP-Adapter image from the gallery",
356
- label="Gallery Image (IP-Adapter)",
357
- choices=[("None", -1)],
358
- interactive=True,
359
- filterable=False,
360
- value=-1,
361
- )
 
 
362
 
363
- with gr.Row():
364
- denoising_strength = gr.Slider(
365
- value=Config.DENOISING_STRENGTH,
366
- label="Denoising Strength",
 
 
 
 
 
 
 
 
 
 
367
  minimum=0.0,
368
  maximum=1.0,
369
  step=0.1,
 
370
  )
371
-
372
- with gr.Row():
373
- disable_image = gr.Checkbox(
374
- elem_classes=["checkbox"],
375
- label="Disable Initial Image",
376
- value=False,
377
- )
378
- disable_ip_image = gr.Checkbox(
379
- elem_classes=["checkbox"],
380
- label="Disable IP-Adapter Image",
381
- value=False,
382
  )
383
- ip_face = gr.Checkbox(
384
- elem_classes=["checkbox"],
385
- label="Use IP-Adapter Face",
386
- value=False,
 
 
387
  )
388
 
389
- # Main content
390
- with gr.Column(elem_id="content"):
391
- with gr.Group():
392
- output_images = gr.Gallery(
393
- elem_classes=["gallery"],
394
- show_share_button=False,
395
- object_fit="cover",
396
- interactive=False,
397
- show_label=False,
398
- label="Output",
399
- format="png",
400
- columns=2,
401
- )
402
- prompt = gr.Textbox(
403
- placeholder="What do you want to see?",
404
- autoscroll=False,
405
- show_label=False,
406
- label="Prompt",
407
- max_lines=3,
408
- lines=3,
409
- )
 
410
 
411
- # Buttons
412
- with gr.Row():
413
- generate_btn = gr.Button("Generate", variant="primary")
414
- random_btn = gr.Button(
415
- elem_classes=["icon-button", "popover"],
416
- variant="secondary",
417
- elem_id="random",
418
- min_width=0,
419
- value="🎲",
420
- )
421
- refresh_btn = gr.Button(
422
- elem_classes=["icon-button", "popover"],
423
- variant="secondary",
424
- elem_id="refresh",
425
- min_width=0,
426
- value="🔄",
427
- )
428
- clear_btn = gr.ClearButton(
429
- elem_classes=["icon-button", "popover"],
430
- components=[output_images],
431
- variant="secondary",
432
- elem_id="clear",
433
- min_width=0,
434
- value="🗑️",
435
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
436
 
437
  random_btn.click(random_fn, inputs=[], outputs=[prompt], show_api=False)
438
 
@@ -513,7 +513,6 @@ with gr.Blocks(
513
  triggers=[generate_btn.click, prompt.submit],
514
  fn=generate_fn,
515
  api_name="generate",
516
- concurrency_limit=5,
517
  outputs=[output_images],
518
  inputs=[
519
  prompt,
@@ -568,7 +567,7 @@ if __name__ == "__main__":
568
  )
569
 
570
  # https://www.gradio.app/docs/gradio/interface#interface-queue
571
- demo.queue().launch(
572
  server_name=args.server,
573
  server_port=args.port,
574
  )
 
134
 
135
  gr.HTML(read_file("./partials/intro.html"))
136
 
137
+ with gr.Tabs():
138
+ with gr.TabItem("🏠 Text"):
139
+ with gr.Column():
 
 
 
 
 
140
  with gr.Group():
141
+ output_images = gr.Gallery(
142
+ elem_classes=["gallery"],
143
+ show_share_button=False,
144
+ object_fit="cover",
145
+ interactive=False,
146
+ show_label=False,
147
+ label="Output",
148
+ format="png",
149
+ columns=2,
150
+ )
151
+ prompt = gr.Textbox(
152
+ placeholder="What do you want to see?",
153
+ autoscroll=False,
154
+ show_label=False,
155
+ label="Prompt",
156
+ max_lines=3,
157
+ lines=3,
158
  )
159
 
160
+ # Buttons
161
+ with gr.Row():
162
+ generate_btn = gr.Button("Generate", variant="primary")
163
+ random_btn = gr.Button(
164
+ elem_classes=["icon-button", "popover"],
165
+ variant="secondary",
166
+ elem_id="random",
167
+ min_width=0,
168
+ value="🎲",
169
+ )
170
+ refresh_btn = gr.Button(
171
+ elem_classes=["icon-button", "popover"],
172
+ variant="secondary",
173
+ elem_id="refresh",
174
+ min_width=0,
175
+ value="🔄",
176
+ )
177
+ clear_btn = gr.ClearButton(
178
+ elem_classes=["icon-button", "popover"],
179
+ components=[output_images],
180
+ variant="secondary",
181
+ elem_id="clear",
182
+ min_width=0,
183
+ value="🗑️",
184
+ )
185
 
186
+ # img2img tab
187
+ with gr.TabItem("🖼️ Image"):
188
+ with gr.Group():
189
+ with gr.Row():
190
+ image_prompt = gr.Image(
191
+ show_share_button=False,
192
+ label="Initial Image",
193
+ min_width=320,
194
+ format="png",
195
+ type="pil",
196
+ )
197
+ ip_image_prompt = gr.Image(
198
+ show_share_button=False,
199
+ label="IP-Adapter Image",
200
+ min_width=320,
201
+ format="png",
202
+ type="pil",
203
+ )
 
204
 
205
+ with gr.Row():
206
+ image_select = gr.Dropdown(
207
+ info="Use an initial image from the gallery",
208
+ choices=[("None", -1)],
209
+ label="Gallery Image",
210
+ interactive=True,
211
+ filterable=False,
212
+ value=-1,
213
+ )
214
+ ip_image_select = gr.Dropdown(
215
+ info="Use an IP-Adapter image from the gallery",
216
+ label="Gallery Image (IP-Adapter)",
217
+ choices=[("None", -1)],
218
+ interactive=True,
219
+ filterable=False,
220
+ value=-1,
221
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
+ with gr.Row():
224
+ denoising_strength = gr.Slider(
225
+ value=Config.DENOISING_STRENGTH,
226
+ label="Denoising Strength",
227
+ minimum=0.0,
228
+ maximum=1.0,
229
+ step=0.1,
230
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
+ with gr.Row():
233
+ disable_image = gr.Checkbox(
234
+ elem_classes=["checkbox"],
235
+ label="Disable Initial Image",
236
+ value=False,
237
+ )
238
+ disable_ip_image = gr.Checkbox(
239
+ elem_classes=["checkbox"],
240
+ label="Disable IP-Adapter Image",
241
+ value=False,
242
+ )
243
+ ip_face = gr.Checkbox(
244
+ elem_classes=["checkbox"],
245
+ label="Use IP-Adapter Face",
246
+ value=False,
247
+ )
 
 
 
 
 
 
 
 
 
248
 
249
+ # img2img tab
250
+ with gr.TabItem("🎮 Control"):
251
+ gr.Markdown(
252
+ "[ControlNet](https://github.com/lllyasviel/ControlNet) with [preprocessors](https://github.com/huggingface/controlnet_aux) coming soon!"
253
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
+ with gr.TabItem("⚙️ Menu"):
256
+ with gr.Group():
257
+ negative_prompt = gr.Textbox(
258
+ value="nsfw+",
259
+ label="Negative Prompt",
260
+ lines=2,
261
+ )
262
+
263
+ with gr.Row():
264
+ model = gr.Dropdown(
265
+ choices=Config.MODELS,
266
+ filterable=False,
267
+ value=Config.MODEL,
268
+ label="Model",
269
+ min_width=240,
270
+ )
271
+ scheduler = gr.Dropdown(
272
+ choices=Config.SCHEDULERS.keys(),
273
+ value=Config.SCHEDULER,
274
+ elem_id="scheduler",
275
+ label="Scheduler",
276
+ filterable=False,
277
+ )
278
 
279
+ with gr.Row():
280
+ styles = json.loads(read_file("data/styles.json"))
281
+ style_ids = list(styles.keys())
282
+ style_ids = [sid for sid in style_ids if not sid.startswith("_")]
283
+ style = gr.Dropdown(
284
+ value=Config.STYLE,
285
+ label="Style",
286
+ min_width=240,
287
+ choices=[("None", "none")]
288
+ + [(styles[sid]["name"], sid) for sid in style_ids],
289
+ )
290
+ embeddings = gr.Dropdown(
291
+ elem_id="embeddings",
292
+ label="Embeddings",
293
+ choices=[(f"<{e}>", e) for e in Config.EMBEDDINGS],
294
+ multiselect=True,
295
+ value=[Config.EMBEDDING],
296
+ min_width=240,
297
+ )
298
 
299
+ with gr.Row():
300
+ with gr.Group(elem_classes=["gap-0"]):
301
+ lora_1 = gr.Dropdown(
302
+ min_width=240,
303
+ label="LoRA #1",
304
+ value="none",
305
+ choices=[("None", "none")]
306
+ + [
307
+ (lora["name"], lora_id)
308
+ for lora_id, lora in Config.CIVIT_LORAS.items()
309
+ ],
310
+ )
311
+ lora_1_weight = gr.Slider(
312
+ value=0.0,
313
  minimum=0.0,
314
  maximum=1.0,
315
  step=0.1,
316
+ show_label=False,
317
  )
318
+ with gr.Group(elem_classes=["gap-0"]):
319
+ lora_2 = gr.Dropdown(
320
+ min_width=240,
321
+ label="LoRA #2",
322
+ value="none",
323
+ choices=[("None", "none")]
324
+ + [
325
+ (lora["name"], lora_id)
326
+ for lora_id, lora in Config.CIVIT_LORAS.items()
327
+ ],
 
328
  )
329
+ lora_2_weight = gr.Slider(
330
+ value=0.0,
331
+ minimum=0.0,
332
+ maximum=1.0,
333
+ step=0.1,
334
+ show_label=False,
335
  )
336
 
337
+ with gr.Row():
338
+ guidance_scale = gr.Slider(
339
+ value=Config.GUIDANCE_SCALE,
340
+ label="Guidance Scale",
341
+ minimum=1.0,
342
+ maximum=15.0,
343
+ step=0.1,
344
+ )
345
+ inference_steps = gr.Slider(
346
+ value=Config.INFERENCE_STEPS,
347
+ label="Inference Steps",
348
+ minimum=1,
349
+ maximum=50,
350
+ step=1,
351
+ )
352
+ deepcache_interval = gr.Slider(
353
+ value=Config.DEEPCACHE_INTERVAL,
354
+ label="DeepCache",
355
+ minimum=1,
356
+ maximum=4,
357
+ step=1,
358
+ )
359
 
360
+ with gr.Row():
361
+ width = gr.Slider(
362
+ value=Config.WIDTH,
363
+ label="Width",
364
+ minimum=256,
365
+ maximum=768,
366
+ step=32,
367
+ )
368
+ height = gr.Slider(
369
+ value=Config.HEIGHT,
370
+ label="Height",
371
+ minimum=256,
372
+ maximum=768,
373
+ step=32,
374
+ )
375
+ aspect_ratio = gr.Dropdown(
376
+ value=f"{Config.WIDTH},{Config.HEIGHT}",
377
+ label="Aspect Ratio",
378
+ filterable=False,
379
+ choices=[
380
+ ("Custom", None),
381
+ ("4:7 (384x672)", "384,672"),
382
+ ("7:9 (448x576)", "448,576"),
383
+ ("1:1 (512x512)", "512,512"),
384
+ ("9:7 (576x448)", "576,448"),
385
+ ("7:4 (672x384)", "672,384"),
386
+ ],
387
+ )
388
+
389
+ with gr.Row():
390
+ file_format = gr.Dropdown(
391
+ choices=["png", "jpeg", "webp"],
392
+ label="File Format",
393
+ filterable=False,
394
+ value="png",
395
+ )
396
+ num_images = gr.Dropdown(
397
+ choices=list(range(1, 5)),
398
+ value=Config.NUM_IMAGES,
399
+ filterable=False,
400
+ label="Images",
401
+ )
402
+ scale = gr.Dropdown(
403
+ choices=[(f"{s}x", s) for s in Config.SCALES],
404
+ filterable=False,
405
+ value=Config.SCALE,
406
+ label="Scale",
407
+ )
408
+ seed = gr.Number(
409
+ value=Config.SEED,
410
+ label="Seed",
411
+ minimum=-1,
412
+ maximum=(2**64) - 1,
413
+ )
414
+
415
+ with gr.Row():
416
+ use_karras = gr.Checkbox(
417
+ elem_classes=["checkbox"],
418
+ label="Karras σ",
419
+ value=True,
420
+ )
421
+ use_taesd = gr.Checkbox(
422
+ elem_classes=["checkbox"],
423
+ label="Tiny VAE",
424
+ value=False,
425
+ )
426
+ use_freeu = gr.Checkbox(
427
+ elem_classes=["checkbox"],
428
+ label="FreeU",
429
+ value=False,
430
+ )
431
+ use_clip_skip = gr.Checkbox(
432
+ elem_classes=["checkbox"],
433
+ label="Clip skip",
434
+ value=False,
435
+ )
436
 
437
  random_btn.click(random_fn, inputs=[], outputs=[prompt], show_api=False)
438
 
 
513
  triggers=[generate_btn.click, prompt.submit],
514
  fn=generate_fn,
515
  api_name="generate",
 
516
  outputs=[output_images],
517
  inputs=[
518
  prompt,
 
567
  )
568
 
569
  # https://www.gradio.app/docs/gradio/interface#interface-queue
570
+ demo.queue(default_concurrency_limit=1).launch(
571
  server_name=args.server,
572
  server_port=args.port,
573
  )