-
-
Notifications
You must be signed in to change notification settings - Fork 890
/
Settings.py
1699 lines (1481 loc) · 85.1 KB
/
Settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This file is part of sygil-webui (https://github.com/Sygil-Dev/sygil-webui/).
# Copyright 2022 Sygil-Dev team.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# base webui import and utils.
from sd_utils import st, custom_models_available, logger, human_readable_size
# streamlit imports
# streamlit components section
from streamlit_server_state import server_state
# other imports
from omegaconf import OmegaConf
import torch
import os, toml
# end of imports
# ---------------------------------------------------------------------------------------------------------------
@logger.catch(reraise=True)
def layout():
# st.header("Settings")
with st.form("Settings"):
(
general_tab,
txt2img_tab,
img2img_tab,
img2txt_tab,
txt2vid_tab,
image_processing,
textual_inversion_tab,
concepts_library_tab,
) = st.tabs(
[
"General",
"Text-To-Image",
"Image-To-Image",
"Image-To-Text",
"Text-To-Video",
"Image processing",
"Textual Inversion",
"Concepts Library",
]
)
with general_tab:
col1, col2, col3, col4, col5 = st.columns(5, gap="large")
device_list = []
device_properties = [
(i, torch.cuda.get_device_properties(i))
for i in range(torch.cuda.device_count())
]
for device in device_properties:
id = device[0]
name = device[1].name
total_memory = device[1].total_memory
device_list.append(
f"{id}: {name} ({human_readable_size(total_memory, decimal_places=0)})"
)
with col1:
st.title("General")
st.session_state["defaults"].general.gpu = int(
st.selectbox(
"GPU",
device_list,
index=st.session_state["defaults"].general.gpu,
help=f"Select which GPU to use. Default: {device_list[0]}",
).split(":")[0]
)
st.session_state["defaults"].general.outdir = str(
st.text_input(
"Output directory",
value=st.session_state["defaults"].general.outdir,
help="Relative directory on which the output images after a generation will be placed. Default: 'outputs'",
)
)
# If we have custom models available on the "models/custom"
# folder then we show a menu to select which model we want to use, otherwise we use the main model for SD
custom_models_available()
if server_state["CustomModel_available"]:
st.session_state.defaults.general.default_model = st.selectbox(
"Default Model:",
server_state["custom_models"],
index=server_state["custom_models"].index(
st.session_state["defaults"].general.default_model
),
help="Select the model you want to use. If you have placed custom models \
on your 'models/custom' folder they will be shown here as well. The model name that will be shown here \
is the same as the name the file for the model has on said folder, \
it is recommended to give the .ckpt file a name that \
will make it easier for you to distinguish it from other models. Default: Stable Diffusion v1.4",
)
else:
st.session_state.defaults.general.default_model = st.selectbox(
"Default Model:",
[st.session_state["defaults"].general.default_model],
help="Select the model you want to use. If you have placed custom models \
on your 'models/custom' folder they will be shown here as well. \
The model name that will be shown here is the same as the name\
the file for the model has on said folder, it is recommended to give the .ckpt file a name that \
will make it easier for you to distinguish it from other models. Default: Stable Diffusion v1.4",
)
st.session_state[
"defaults"
].general.default_model_config = st.text_input(
"Default Model Config",
value=st.session_state["defaults"].general.default_model_config,
help="Default model config file for inference. Default: 'configs/stable-diffusion/v1-inference.yaml'",
)
st.session_state["defaults"].general.default_model_path = st.text_input(
"Default Model Config",
value=st.session_state["defaults"].general.default_model_path,
help="Default model path. Default: 'models/ldm/stable-diffusion-v1/model.ckpt'",
)
st.session_state["defaults"].general.GFPGAN_dir = st.text_input(
"Default GFPGAN directory",
value=st.session_state["defaults"].general.GFPGAN_dir,
help="Default GFPGAN directory. Default: './models/gfpgan'",
)
st.session_state["defaults"].general.RealESRGAN_dir = st.text_input(
"Default RealESRGAN directory",
value=st.session_state["defaults"].general.RealESRGAN_dir,
help="Default GFPGAN directory. Default: './models/realesrgan'",
)
RealESRGAN_model_list = [
"RealESRGAN_x4plus",
"RealESRGAN_x4plus_anime_6B",
]
st.session_state["defaults"].general.RealESRGAN_model = st.selectbox(
"RealESRGAN model",
RealESRGAN_model_list,
index=RealESRGAN_model_list.index(
st.session_state["defaults"].general.RealESRGAN_model
),
help="Default RealESRGAN model. Default: 'RealESRGAN_x4plus'",
)
Upscaler_list = ["RealESRGAN", "LDSR"]
st.session_state["defaults"].general.upscaling_method = st.selectbox(
"Upscaler",
Upscaler_list,
index=Upscaler_list.index(
st.session_state["defaults"].general.upscaling_method
),
help="Default upscaling method. Default: 'RealESRGAN'",
)
with col2:
st.title("Performance")
st.session_state["defaults"].general.gfpgan_cpu = st.checkbox(
"GFPGAN - CPU",
value=st.session_state["defaults"].general.gfpgan_cpu,
help="Run GFPGAN on the cpu. Default: False",
)
st.session_state["defaults"].general.esrgan_cpu = st.checkbox(
"ESRGAN - CPU",
value=st.session_state["defaults"].general.esrgan_cpu,
help="Run ESRGAN on the cpu. Default: False",
)
st.session_state["defaults"].general.extra_models_cpu = st.checkbox(
"Extra Models - CPU",
value=st.session_state["defaults"].general.extra_models_cpu,
help="Run extra models (GFGPAN/ESRGAN) on cpu. Default: False",
)
st.session_state["defaults"].general.extra_models_gpu = st.checkbox(
"Extra Models - GPU",
value=st.session_state["defaults"].general.extra_models_gpu,
help="Run extra models (GFGPAN/ESRGAN) on gpu. \
Check and save in order to be able to select the GPU that each model will use. Default: False",
)
if st.session_state["defaults"].general.extra_models_gpu:
st.session_state["defaults"].general.gfpgan_gpu = int(
st.selectbox(
"GFGPAN GPU",
device_list,
index=st.session_state["defaults"].general.gfpgan_gpu,
help=f"Select which GPU to use. Default: {device_list[st.session_state['defaults'].general.gfpgan_gpu]}",
key="gfpgan_gpu",
).split(":")[0]
)
st.session_state["defaults"].general.esrgan_gpu = int(
st.selectbox(
"ESRGAN - GPU",
device_list,
index=st.session_state["defaults"].general.esrgan_gpu,
help=f"Select which GPU to use. Default: {device_list[st.session_state['defaults'].general.esrgan_gpu]}",
key="esrgan_gpu",
).split(":")[0]
)
st.session_state["defaults"].general.no_half = st.checkbox(
"No Half",
value=st.session_state["defaults"].general.no_half,
help="DO NOT switch the model to 16-bit floats. Default: False",
)
st.session_state["defaults"].general.use_cudnn = st.checkbox(
"Use cudnn",
value=st.session_state["defaults"].general.use_cudnn,
help="Switch the pytorch backend to use cudnn, this should help with fixing Nvidia 16xx cards getting"
"a black or green image. Default: False",
)
st.session_state["defaults"].general.use_float16 = st.checkbox(
"Use float16",
value=st.session_state["defaults"].general.use_float16,
help="Switch the model to 16-bit floats. Default: False",
)
precision_list = ["full", "autocast"]
st.session_state["defaults"].general.precision = st.selectbox(
"Precision",
precision_list,
index=precision_list.index(
st.session_state["defaults"].general.precision
),
help="Evaluates at this precision. Default: autocast",
)
st.session_state["defaults"].general.optimized = st.checkbox(
"Optimized Mode",
value=st.session_state["defaults"].general.optimized,
help="Loads the model onto the device piecemeal instead of all at once to reduce VRAM usage\
at the cost of performance. Default: False",
)
st.session_state["defaults"].general.optimized_turbo = st.checkbox(
"Optimized Turbo Mode",
value=st.session_state["defaults"].general.optimized_turbo,
help="Alternative optimization mode that does not save as much VRAM but \
runs siginificantly faster. Default: False",
)
st.session_state["defaults"].general.optimized_config = st.text_input(
"Optimized Config",
value=st.session_state["defaults"].general.optimized_config,
help="Loads alternative optimized configuration for inference. \
Default: optimizedSD/v1-inference.yaml",
)
st.session_state[
"defaults"
].general.enable_attention_slicing = st.checkbox(
"Enable Attention Slicing",
value=st.session_state["defaults"].general.enable_attention_slicing,
help="Enable sliced attention computation. When this option is enabled, the attention module will \
split the input tensor in slices, to compute attention in several steps. This is useful to save some \
memory in exchange for a small speed decrease. Only works the txt2vid tab right now. Default: False",
)
st.session_state[
"defaults"
].general.enable_minimal_memory_usage = st.checkbox(
"Enable Minimal Memory Usage",
value=st.session_state[
"defaults"
].general.enable_minimal_memory_usage,
help="Moves only unet to fp16 and to CUDA, while keepping lighter models on CPUs \
(Not properly implemented and currently not working, check this \
link 'https://github.com/huggingface/diffusers/pull/537' for more information on it ). Default: False",
)
# st.session_state["defaults"].general.update_preview = st.checkbox("Update Preview Image", value=st.session_state['defaults'].general.update_preview,
# help="Enables the preview image to be updated and shown to the user on the UI during the generation.\
# If checked, once you save the settings an option to specify the frequency at which the image is updated\
# in steps will be shown, this is helpful to reduce the negative effect this option has on performance. \
# Default: True")
st.session_state["defaults"].general.update_preview = True
st.session_state[
"defaults"
].general.update_preview_frequency = st.number_input(
"Update Preview Frequency",
min_value=0,
value=st.session_state["defaults"].general.update_preview_frequency,
help="Specify the frequency at which the image is updated in steps, this is helpful to reduce the \
negative effect updating the preview image has on performance. Default: 10",
)
with col3:
st.title("Others")
st.session_state[
"defaults"
].general.use_sd_concepts_library = st.checkbox(
"Use the Concepts Library",
value=st.session_state["defaults"].general.use_sd_concepts_library,
help="Use the embeds Concepts Library, if checked, once the settings are saved an option will\
appear to specify the directory where the concepts are stored. Default: True)",
)
if st.session_state["defaults"].general.use_sd_concepts_library:
st.session_state[
"defaults"
].general.sd_concepts_library_folder = st.text_input(
"Concepts Library Folder",
value=st.session_state[
"defaults"
].general.sd_concepts_library_folder,
help="Relative folder on which the concepts library embeds are stored. \
Default: 'models/custom/sd-concepts-library'",
)
st.session_state["defaults"].general.LDSR_dir = st.text_input(
"LDSR Folder",
value=st.session_state["defaults"].general.LDSR_dir,
help="Folder where LDSR is located. Default: './models/ldsr'",
)
st.session_state["defaults"].general.save_metadata = st.checkbox(
"Save Metadata",
value=st.session_state["defaults"].general.save_metadata,
help="Save metadata on the output image. Default: True",
)
save_format_list = ["png", "jpg", "jpeg", "webp"]
st.session_state["defaults"].general.save_format = st.selectbox(
"Save Format",
save_format_list,
index=save_format_list.index(
st.session_state["defaults"].general.save_format
),
help="Format that will be used whens saving the output images. Default: 'png'",
)
st.session_state["defaults"].general.skip_grid = st.checkbox(
"Skip Grid",
value=st.session_state["defaults"].general.skip_grid,
help="Skip saving the grid output image. Default: False",
)
if not st.session_state["defaults"].general.skip_grid:
st.session_state["defaults"].general.grid_quality = st.number_input(
"Grid Quality",
value=st.session_state["defaults"].general.grid_quality,
help="Format for saving the grid output image. Default: 95",
)
st.session_state["defaults"].general.skip_save = st.checkbox(
"Skip Save",
value=st.session_state["defaults"].general.skip_save,
help="Skip saving the output image. Default: False",
)
st.session_state["defaults"].general.n_rows = st.number_input(
"Number of Grid Rows",
value=st.session_state["defaults"].general.n_rows,
help="Number of rows the grid wil have when saving the grid output image. Default: '-1'",
)
st.session_state["defaults"].general.no_verify_input = st.checkbox(
"Do not Verify Input",
value=st.session_state["defaults"].general.no_verify_input,
help="Do not verify input to check if it's too long. Default: False",
)
st.session_state[
"defaults"
].general.show_percent_in_tab_title = st.checkbox(
"Show Percent in tab title",
value=st.session_state[
"defaults"
].general.show_percent_in_tab_title,
help="Add the progress percent value to the page title on the tab on your browser. "
"This is useful in case you need to know how the generation is going while doign something else"
"in another tab on your browser. Default: True",
)
st.session_state["defaults"].general.enable_suggestions = st.checkbox(
"Enable Suggestions Box",
value=st.session_state["defaults"].general.enable_suggestions,
help="Adds a suggestion box under the prompt when clicked. Default: True",
)
st.session_state[
"defaults"
].daisi_app.running_on_daisi_io = st.checkbox(
"Running on Daisi.io?",
value=st.session_state["defaults"].daisi_app.running_on_daisi_io,
help="Specify if we are running on app.Daisi.io . Default: False",
)
with col4:
st.title("Streamlit Config")
default_theme_list = ["light", "dark"]
st.session_state["defaults"].general.default_theme = st.selectbox(
"Default Theme",
default_theme_list,
index=default_theme_list.index(
st.session_state["defaults"].general.default_theme
),
help="Defaut theme to use as base for streamlit. Default: dark",
)
st.session_state["streamlit_config"]["theme"][
"base"
] = st.session_state["defaults"].general.default_theme
if not st.session_state["defaults"].admin.hide_server_setting:
with st.expander("Server", True):
st.session_state["streamlit_config"]["server"][
"headless"
] = st.checkbox(
"Run Headless",
help="If false, will attempt to open a browser window on start. \
Default: false unless (1) we are on a Linux box where DISPLAY is unset, \
or (2) we are running in the Streamlit Atom plugin.",
)
st.session_state["streamlit_config"]["server"][
"port"
] = st.number_input(
"Port",
value=st.session_state["streamlit_config"]["server"][
"port"
],
help="The port where the server will listen for browser connections. Default: 8501",
)
st.session_state["streamlit_config"]["server"][
"baseUrlPath"
] = st.text_input(
"Base Url Path",
value=st.session_state["streamlit_config"]["server"][
"baseUrlPath"
],
help="The base path for the URL where Streamlit should be served from. Default: '' ",
)
st.session_state["streamlit_config"]["server"][
"enableCORS"
] = st.checkbox(
"Enable CORS",
value=st.session_state["streamlit_config"]["server"][
"enableCORS"
],
help="Enables support for Cross-Origin Request Sharing (CORS) protection, for added security. \
Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is on and `server.enableCORS` \
is off at the same time, we will prioritize `server.enableXsrfProtection`. Default: true",
)
st.session_state["streamlit_config"]["server"][
"enableXsrfProtection"
] = st.checkbox(
"Enable Xsrf Protection",
value=st.session_state["streamlit_config"]["server"][
"enableXsrfProtection"
],
help="Enables support for Cross-Site Request Forgery (XSRF) protection, \
for added security. Due to conflicts between CORS and XSRF, \
if `server.enableXsrfProtection` is on and `server.enableCORS` is off at \
the same time, we will prioritize `server.enableXsrfProtection`. Default: true",
)
st.session_state["streamlit_config"]["server"][
"maxUploadSize"
] = st.number_input(
"Max Upload Size",
value=st.session_state["streamlit_config"]["server"][
"maxUploadSize"
],
help="Max size, in megabytes, for files uploaded with the file_uploader. Default: 200",
)
st.session_state["streamlit_config"]["server"][
"maxMessageSize"
] = st.number_input(
"Max Message Size",
value=st.session_state["streamlit_config"]["server"][
"maxUploadSize"
],
help="Max size, in megabytes, of messages that can be sent via the WebSocket connection. Default: 200",
)
st.session_state["streamlit_config"]["server"][
"enableWebsocketCompression"
] = st.checkbox(
"Enable Websocket Compression",
value=st.session_state["streamlit_config"]["server"][
"enableWebsocketCompression"
],
help=" Enables support for websocket compression. Default: false",
)
if not st.session_state["defaults"].admin.hide_browser_setting:
with st.expander("Browser", expanded=True):
st.session_state["streamlit_config"]["browser"][
"serverAddress"
] = st.text_input(
"Server Address",
value=st.session_state["streamlit_config"]["browser"][
"serverAddress"
]
if "serverAddress" in st.session_state["streamlit_config"]
else "localhost",
help="Internet address where users should point their browsers in order \
to connect to the app. Can be IP address or DNS name and path.\
This is used to: - Set the correct URL for CORS and XSRF protection purposes. \
- Show the URL on the terminal - Open the browser. Default: 'localhost'",
)
st.session_state[
"defaults"
].general.streamlit_telemetry = st.checkbox(
"Enable Telemetry",
value=st.session_state[
"defaults"
].general.streamlit_telemetry,
help="Enables or Disables streamlit telemetry. Default: False",
)
st.session_state["streamlit_config"]["browser"][
"gatherUsageStats"
] = st.session_state["defaults"].general.streamlit_telemetry
st.session_state["streamlit_config"]["browser"][
"serverPort"
] = st.number_input(
"Server Port",
value=st.session_state["streamlit_config"]["browser"][
"serverPort"
],
help="Port where users should point their browsers in order to connect to the app. \
This is used to: - Set the correct URL for CORS and XSRF protection purposes. \
- Show the URL on the terminal - Open the browser \
Default: whatever value is set in server.port.",
)
with col5:
st.title("Huggingface")
st.session_state["defaults"].general.huggingface_token = st.text_input(
"Huggingface Token",
value=st.session_state["defaults"].general.huggingface_token,
type="password",
help="Your Huggingface Token, it's used to download the model for the diffusers library which \
is used on the Text To Video tab. This token will be saved to your user config file\
and WILL NOT be share with us or anyone. You can get your access token \
at https://huggingface.co/settings/tokens. Default: None",
)
st.title("Stable Horde")
st.session_state["defaults"].general.stable_horde_api = st.text_input(
"Stable Horde Api",
value=st.session_state["defaults"].general.stable_horde_api,
type="password",
help="First Register an account at https://stablehorde.net/register which will generate for you \
an API key. Store that key somewhere safe. \n \
If you do not want to register, you can use `0000000000` as api_key to connect anonymously.\
However anonymous accounts have the lowest priority when there's too many concurrent requests! \
To increase your priority you will need a unique API key and then to increase your Kudos \
read more about them at https://dbzer0.com/blog/the-kudos-based-economy-for-the-koboldai-horde/.",
)
with txt2img_tab:
col1, col2, col3, col4, col5 = st.columns(5, gap="medium")
with col1:
st.title("Slider Parameters")
# Width
st.session_state["defaults"].txt2img.width.value = st.number_input(
"Default Image Width",
value=st.session_state["defaults"].txt2img.width.value,
help="Set the default width for the generated image. Default is: 512",
)
st.session_state["defaults"].txt2img.width.min_value = st.number_input(
"Minimum Image Width",
value=st.session_state["defaults"].txt2img.width.min_value,
help="Set the default minimum value for the width slider. Default is: 64",
)
st.session_state["defaults"].txt2img.width.max_value = st.number_input(
"Maximum Image Width",
value=st.session_state["defaults"].txt2img.width.max_value,
help="Set the default maximum value for the width slider. Default is: 2048",
)
# Height
st.session_state["defaults"].txt2img.height.value = st.number_input(
"Default Image Height",
value=st.session_state["defaults"].txt2img.height.value,
help="Set the default height for the generated image. Default is: 512",
)
st.session_state["defaults"].txt2img.height.min_value = st.number_input(
"Minimum Image Height",
value=st.session_state["defaults"].txt2img.height.min_value,
help="Set the default minimum value for the height slider. Default is: 64",
)
st.session_state["defaults"].txt2img.height.max_value = st.number_input(
"Maximum Image Height",
value=st.session_state["defaults"].txt2img.height.max_value,
help="Set the default maximum value for the height slider. Default is: 2048",
)
with col2:
# CFG
st.session_state[
"defaults"
].txt2img.cfg_scale.value = st.number_input(
"Default CFG Scale",
value=st.session_state["defaults"].txt2img.cfg_scale.value,
help="Set the default value for the CFG Scale. Default is: 7.5",
)
st.session_state[
"defaults"
].txt2img.cfg_scale.min_value = st.number_input(
"Minimum CFG Scale Value",
value=st.session_state["defaults"].txt2img.cfg_scale.min_value,
help="Set the default minimum value for the CFG scale slider. Default is: 1",
)
st.session_state[
"defaults"
].txt2img.cfg_scale.step = st.number_input(
"CFG Slider Steps",
value=st.session_state["defaults"].txt2img.cfg_scale.step,
help="Set the default value for the number of steps on the CFG scale slider. Default is: 0.5",
)
# Sampling Steps
st.session_state[
"defaults"
].txt2img.sampling_steps.value = st.number_input(
"Default Sampling Steps",
value=st.session_state["defaults"].txt2img.sampling_steps.value,
help="Set the default number of sampling steps to use. Default is: 30 (with k_euler)",
)
st.session_state[
"defaults"
].txt2img.sampling_steps.min_value = st.number_input(
"Minimum Sampling Steps",
value=st.session_state[
"defaults"
].txt2img.sampling_steps.min_value,
help="Set the default minimum value for the sampling steps slider. Default is: 1",
)
st.session_state[
"defaults"
].txt2img.sampling_steps.step = st.number_input(
"Sampling Slider Steps",
value=st.session_state["defaults"].txt2img.sampling_steps.step,
help="Set the default value for the number of steps on the sampling steps slider. Default is: 10",
)
with col3:
st.title("General Parameters")
# Batch Count
st.session_state[
"defaults"
].txt2img.batch_count.value = st.number_input(
"Batch count",
value=st.session_state["defaults"].txt2img.batch_count.value,
help="How many iterations or batches of images to generate in total.",
)
st.session_state["defaults"].txt2img.batch_size.value = st.number_input(
"Batch size",
value=st.session_state.defaults.txt2img.batch_size.value,
help="How many images are at once in a batch.\
It increases the VRAM usage a lot but if you have enough VRAM it can reduce the time it \
takes to finish generation as more images are generated at once.\
Default: 1",
)
default_sampler_list = [
"k_lms",
"k_euler",
"k_euler_a",
"k_dpm_2",
"k_dpm_2_a",
"k_heun",
"PLMS",
"DDIM",
]
st.session_state["defaults"].txt2img.default_sampler = st.selectbox(
"Default Sampler",
default_sampler_list,
index=default_sampler_list.index(
st.session_state["defaults"].txt2img.default_sampler
),
help="Defaut sampler to use for txt2img. Default: k_euler",
)
st.session_state["defaults"].txt2img.seed = st.text_input(
"Default Seed",
value=st.session_state["defaults"].txt2img.seed,
help="Default seed.",
)
with col4:
st.session_state["defaults"].txt2img.separate_prompts = st.checkbox(
"Separate Prompts",
value=st.session_state["defaults"].txt2img.separate_prompts,
help="Separate Prompts. Default: False",
)
st.session_state[
"defaults"
].txt2img.normalize_prompt_weights = st.checkbox(
"Normalize Prompt Weights",
value=st.session_state["defaults"].txt2img.normalize_prompt_weights,
help="Choose to normalize prompt weights. Default: True",
)
st.session_state[
"defaults"
].txt2img.save_individual_images = st.checkbox(
"Save Individual Images",
value=st.session_state["defaults"].txt2img.save_individual_images,
help="Choose to save individual images. Default: True",
)
st.session_state["defaults"].txt2img.save_grid = st.checkbox(
"Save Grid Images",
value=st.session_state["defaults"].txt2img.save_grid,
help="Choose to save the grid images. Default: True",
)
st.session_state["defaults"].txt2img.group_by_prompt = st.checkbox(
"Group By Prompt",
value=st.session_state["defaults"].txt2img.group_by_prompt,
help="Choose to save images grouped by their prompt. Default: False",
)
st.session_state["defaults"].txt2img.save_as_jpg = st.checkbox(
"Save As JPG",
value=st.session_state["defaults"].txt2img.save_as_jpg,
help="Choose to save images as jpegs. Default: False",
)
st.session_state["defaults"].txt2img.write_info_files = st.checkbox(
"Write Info Files For Images",
value=st.session_state["defaults"].txt2img.write_info_files,
help="Choose to write the info files along with the generated images. Default: True",
)
st.session_state["defaults"].txt2img.use_GFPGAN = st.checkbox(
"Use GFPGAN",
value=st.session_state["defaults"].txt2img.use_GFPGAN,
help="Choose to use GFPGAN. Default: False",
)
st.session_state["defaults"].txt2img.use_upscaling = st.checkbox(
"Use Upscaling",
value=st.session_state["defaults"].txt2img.use_upscaling,
help="Choose to turn on upscaling by default. Default: False",
)
st.session_state["defaults"].txt2img.update_preview = True
st.session_state[
"defaults"
].txt2img.update_preview_frequency = st.number_input(
"Preview Image Update Frequency",
min_value=0,
value=st.session_state["defaults"].txt2img.update_preview_frequency,
help="Set the default value for the frrquency of the preview image updates. Default is: 10",
)
with col5:
st.title("Variation Parameters")
st.session_state[
"defaults"
].txt2img.variant_amount.value = st.number_input(
"Default Variation Amount",
value=st.session_state["defaults"].txt2img.variant_amount.value,
help="Set the default variation to use. Default is: 0.0",
)
st.session_state[
"defaults"
].txt2img.variant_amount.min_value = st.number_input(
"Minimum Variation Amount",
value=st.session_state["defaults"].txt2img.variant_amount.min_value,
help="Set the default minimum value for the variation slider. Default is: 0.0",
)
st.session_state[
"defaults"
].txt2img.variant_amount.max_value = st.number_input(
"Maximum Variation Amount",
value=st.session_state["defaults"].txt2img.variant_amount.max_value,
help="Set the default maximum value for the variation slider. Default is: 1.0",
)
st.session_state[
"defaults"
].txt2img.variant_amount.step = st.number_input(
"Variation Slider Steps",
value=st.session_state["defaults"].txt2img.variant_amount.step,
help="Set the default value for the number of steps on the variation slider. Default is: 1",
)
st.session_state["defaults"].txt2img.variant_seed = st.text_input(
"Default Variation Seed",
value=st.session_state["defaults"].txt2img.variant_seed,
help="Default variation seed.",
)
with img2img_tab:
col1, col2, col3, col4, col5 = st.columns(5, gap="medium")
with col1:
st.title("Image Editing")
# Denoising
st.session_state[
"defaults"
].img2img.denoising_strength.value = st.number_input(
"Default Denoising Amount",
value=st.session_state["defaults"].img2img.denoising_strength.value,
help="Set the default denoising to use. Default is: 0.75",
)
st.session_state[
"defaults"
].img2img.denoising_strength.min_value = st.number_input(
"Minimum Denoising Amount",
value=st.session_state[
"defaults"
].img2img.denoising_strength.min_value,
help="Set the default minimum value for the denoising slider. Default is: 0.0",
)
st.session_state[
"defaults"
].img2img.denoising_strength.max_value = st.number_input(
"Maximum Denoising Amount",
value=st.session_state[
"defaults"
].img2img.denoising_strength.max_value,
help="Set the default maximum value for the denoising slider. Default is: 1.0",
)
st.session_state[
"defaults"
].img2img.denoising_strength.step = st.number_input(
"Denoising Slider Steps",
value=st.session_state["defaults"].img2img.denoising_strength.step,
help="Set the default value for the number of steps on the denoising slider. Default is: 0.01",
)
# Masking
st.session_state["defaults"].img2img.mask_mode = st.number_input(
"Default Mask Mode",
value=st.session_state["defaults"].img2img.mask_mode,
help="Set the default mask mode to use. 0 = Keep Masked Area, 1 = Regenerate Masked Area. Default is: 0",
)
st.session_state["defaults"].img2img.mask_restore = st.checkbox(
"Default Mask Restore",
value=st.session_state["defaults"].img2img.mask_restore,
help="Mask Restore. Default: False",
)
st.session_state["defaults"].img2img.resize_mode = st.number_input(
"Default Resize Mode",
value=st.session_state["defaults"].img2img.resize_mode,
help="Set the default resizing mode. 0 = Just Resize, 1 = Crop and Resize, 3 = Resize and Fill. Default is: 0",
)
with col2:
st.title("Slider Parameters")
# Width
st.session_state["defaults"].img2img.width.value = st.number_input(
"Default Outputted Image Width",
value=st.session_state["defaults"].img2img.width.value,
help="Set the default width for the generated image. Default is: 512",
)
st.session_state["defaults"].img2img.width.min_value = st.number_input(
"Minimum Outputted Image Width",
value=st.session_state["defaults"].img2img.width.min_value,
help="Set the default minimum value for the width slider. Default is: 64",
)
st.session_state["defaults"].img2img.width.max_value = st.number_input(
"Maximum Outputted Image Width",
value=st.session_state["defaults"].img2img.width.max_value,
help="Set the default maximum value for the width slider. Default is: 2048",
)
# Height
st.session_state["defaults"].img2img.height.value = st.number_input(
"Default Outputted Image Height",
value=st.session_state["defaults"].img2img.height.value,
help="Set the default height for the generated image. Default is: 512",
)
st.session_state["defaults"].img2img.height.min_value = st.number_input(
"Minimum Outputted Image Height",
value=st.session_state["defaults"].img2img.height.min_value,
help="Set the default minimum value for the height slider. Default is: 64",
)
st.session_state["defaults"].img2img.height.max_value = st.number_input(
"Maximum Outputted Image Height",
value=st.session_state["defaults"].img2img.height.max_value,
help="Set the default maximum value for the height slider. Default is: 2048",
)
# CFG
st.session_state["defaults"].img2img.cfg_scale.value = st.number_input(
"Default Img2Img CFG Scale",
value=st.session_state["defaults"].img2img.cfg_scale.value,
help="Set the default value for the CFG Scale. Default is: 7.5",
)
st.session_state[
"defaults"
].img2img.cfg_scale.min_value = st.number_input(
"Minimum Img2Img CFG Scale Value",
value=st.session_state["defaults"].img2img.cfg_scale.min_value,
help="Set the default minimum value for the CFG scale slider. Default is: 1",
)
with col3:
st.session_state[
"defaults"
].img2img.cfg_scale.step = st.number_input(
"Img2Img CFG Slider Steps",
value=st.session_state["defaults"].img2img.cfg_scale.step,
help="Set the default value for the number of steps on the CFG scale slider. Default is: 0.5",
)
# Sampling Steps
st.session_state[
"defaults"
].img2img.sampling_steps.value = st.number_input(
"Default Img2Img Sampling Steps",
value=st.session_state["defaults"].img2img.sampling_steps.value,
help="Set the default number of sampling steps to use. Default is: 30 (with k_euler)",
)
st.session_state[
"defaults"
].img2img.sampling_steps.min_value = st.number_input(
"Minimum Img2Img Sampling Steps",
value=st.session_state[
"defaults"
].img2img.sampling_steps.min_value,
help="Set the default minimum value for the sampling steps slider. Default is: 1",
)
st.session_state[
"defaults"
].img2img.sampling_steps.step = st.number_input(
"Img2Img Sampling Slider Steps",
value=st.session_state["defaults"].img2img.sampling_steps.step,
help="Set the default value for the number of steps on the sampling steps slider. Default is: 10",
)
# Batch Count
st.session_state[
"defaults"
].img2img.batch_count.value = st.number_input(
"Img2img Batch count",
value=st.session_state["defaults"].img2img.batch_count.value,
help="How many iterations or batches of images to generate in total.",
)
st.session_state[
"defaults"
].img2img.batch_size.value = st.number_input(
"Img2img Batch size",
value=st.session_state["defaults"].img2img.batch_size.value,
help="How many images are at once in a batch.\
It increases the VRAM usage a lot but if you have enough VRAM it can reduce the time it \
takes to finish generation as more images are generated at once.\
Default: 1",