John6666 commited on
Commit
821a6d5
·
verified ·
1 Parent(s): 523f99e

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +224 -442
  2. modutils.py +1 -0
  3. requirements.txt +0 -2
app.py CHANGED
@@ -1,9 +1,5 @@
1
  import spaces
2
-
3
- @spaces.GPU
4
- def dummy():
5
- pass
6
-
7
  import os
8
  from stablepy import Model_Diffusers
9
  from stablepy.diffusers_vanilla.model import scheduler_names
@@ -166,55 +162,18 @@ def process_string(input_string):
166
 
167
 
168
  ## BEGIN MOD
169
- from modutils import (
170
- list_uniq,
171
- download_private_repo,
172
- get_model_id_list,
173
- get_tupled_embed_list,
174
- get_lora_model_list,
175
- get_all_lora_tupled_list,
176
- update_loras,
177
- apply_lora_prompt,
178
- set_prompt_loras,
179
- get_my_lora,
180
- upload_file_lora,
181
- move_file_lora,
182
- search_civitai_lora,
183
- select_civitai_lora,
184
- set_textual_inversion_prompt,
185
- get_model_pipeline,
186
- change_interface_mode,
187
- get_t2i_model_info,
188
- get_tupled_model_list,
189
- save_gallery_images,
190
- set_optimization,
191
- set_sampler_settings,
192
- set_quick_presets,
193
- process_style_prompt,
194
- optimization_list,
195
- preset_styles,
196
- preset_quality,
197
- preset_sampler_setting,
198
- )
199
- from env import (
200
- hf_token,
201
- CIVITAI_API_KEY,
202
- HF_LORA_ESSENTIAL_PRIVATE_REPO,
203
- HF_VAE_PRIVATE_REPO,
204
- HF_SDXL_EMBEDS_NEGATIVE_PRIVATE_REPO,
205
- HF_SDXL_EMBEDS_POSITIVE_PRIVATE_REPO,
206
- directory_models,
207
- directory_loras,
208
- directory_vaes,
209
- directory_embeds,
210
- directory_embeds_sdxl,
211
- directory_embeds_positive_sdxl,
212
- load_diffusers_format_model,
213
- download_model_list,
214
- download_lora_list,
215
- download_vae_list,
216
- download_embeds,
217
- )
218
 
219
  # - **Download Models**
220
  download_model = ", ".join(download_model_list)
@@ -328,7 +287,6 @@ def extract_parameters(input_string):
328
  #######################
329
  # GUI
330
  #######################
331
- import spaces
332
  import gradio as gr
333
  from PIL import Image
334
  import IPython.display
@@ -346,30 +304,12 @@ warnings.filterwarnings(action="ignore", category=FutureWarning, module="transfo
346
  from stablepy import logger
347
  logger.setLevel(logging.CRITICAL)
348
 
349
- from v2 import (
350
- V2_ALL_MODELS,
351
- v2_random_prompt,
352
- v2_upsampling_prompt,
353
- )
354
- from utils import (
355
- gradio_copy_text,
356
- COPY_ACTION_JS,
357
- gradio_copy_prompt,
358
- V2_ASPECT_RATIO_OPTIONS,
359
- V2_RATING_OPTIONS,
360
- V2_LENGTH_OPTIONS,
361
- V2_IDENTITY_OPTIONS
362
- )
363
- from tagger import (
364
- predict_tags_wd,
365
- convert_danbooru_to_e621_prompt,
366
- remove_specific_prompt,
367
- insert_recom_prompt,
368
- insert_model_recom_prompt,
369
- compose_prompt_to_copy,
370
- translate_prompt,
371
- select_random_character,
372
- )
373
  def description_ui():
374
  gr.Markdown(
375
  """
@@ -431,7 +371,6 @@ class GuiSD:
431
  if incompatible_vae:
432
  vae_model = None
433
 
434
-
435
  self.model.load_pipe(
436
  model_name,
437
  task_name=task_stablepy[task],
@@ -779,16 +718,16 @@ class GuiSD:
779
  info_state = info_state + "<br>" + "<br>".join(msg_lora)
780
  yield self.infer_short(self.model, pipe_params), info_state
781
 
782
-
783
  sd_gen = GuiSD()
784
 
785
  ## BEGIN MOD
786
  CSS ="""
787
- .gradio-container, #main {width:100%; height:100%; max-width:100%; padding-left:0; padding-right:0; margin-left:0; margin-right:0; !important;}
788
- .contain {display: flex; flex-direction: column; !important;}
789
- #component-0 {height: 100%; !important;}
790
- #gallery {flex-grow: 1; !important;}
791
- #model-info { text-align: center; }
 
792
  """
793
  ## END MOD
794
 
@@ -809,7 +748,7 @@ def update_task_options(model_name, task_name):
809
  return gr.update(value=task_name, choices=task_model_list)
810
 
811
  ## BEGIN MOD
812
- with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, css=CSS) as app:
813
  gr.Markdown("# 🧩 DiffuseCraft Mod")
814
  gr.Markdown(
815
  f"""
@@ -830,7 +769,7 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
830
  quick_genre_gui = gr.Radio(label="Genre", choices=["Anime", "Photo"], value="Anime", interactive=True)
831
  quick_speed_gui = gr.Radio(label="Speed", choices=["Fast", "Standard", "Heavy"], value="Standard", interactive=True)
832
  quick_aspect_gui = gr.Radio(label="Aspect Ratio", choices=["1:1", "3:4"], value="1:1", interactive=True)
833
- with gr.Accordion(label="Advanced options", open=False):
834
  quality_selector_gui = gr.Dropdown(label="Quality Tags Presets", interactive=True, choices=list(preset_quality.keys()), value="None")
835
  style_selector_gui = gr.Dropdown(label="Style Preset", interactive=True, choices=list(preset_styles.keys()), value="None")
836
  sampler_selector_gui = gr.Dropdown(label="Sampler Quick Settings", interactive=True, choices=list(preset_sampler_setting.keys()), value="None")
@@ -839,19 +778,21 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
839
  with gr.Accordion("Prompt from Image", open=False) as menu_from_image:
840
  input_image_gui = gr.Image(label="Input image", type="pil", sources=["upload", "clipboard"], height=256)
841
  with gr.Accordion(label="Advanced options", open=False):
842
- general_threshold_gui = gr.Slider(label="Threshold", minimum=0.0, maximum=1.0, value=0.3, step=0.01, interactive=True)
843
- character_threshold_gui = gr.Slider(label="Character threshold", minimum=0.0, maximum=1.0, value=0.8, step=0.01, interactive=True)
844
- tag_type_gui = gr.Radio(label="Convert tags to", info="danbooru for Animagine, e621 for Pony.", choices=["danbooru", "e621"], value="danbooru")
845
- recom_prompt_gui = gr.Radio(label="Insert reccomended prompt", choices=["None", "Animagine", "Pony"], value="None", interactive=True)
846
- keep_tags_gui = gr.Radio(label="Remove tags leaving only the following", choices=["body", "dress", "all"], value="all")
847
- image_algorithms = gr.CheckboxGroup(["Use WD Tagger"], label="Algorithms", value=["Use WD Tagger"], visible=False)
 
 
848
  generate_from_image_btn_gui = gr.Button(value="GENERATE TAGS FROM IMAGE")
849
  prompt_gui = gr.Textbox(lines=6, placeholder="1girl, solo, ...", label="Prompt", show_copy_button=True)
850
  with gr.Accordion("Negative prompt, etc.", open=False) as menu_negative:
851
  neg_prompt_gui = gr.Textbox(lines=3, placeholder="lowres, (bad), ...", label="Negative prompt", show_copy_button=True)
852
  translate_prompt_button = gr.Button(value="Translate prompt to English", size="sm", variant="secondary")
853
- insert_prompt_gui = gr.Radio(label="Insert reccomended positive / negative prompt", choices=["None", "Auto", "Animagine", "Pony"], value="Auto", interactive=True)
854
- with gr.Accordion(label="Advanced options", open=False):
855
  prompt_type_gui = gr.Radio(label="Convert tags to", choices=["danbooru", "e621"], value="e621", visible=False)
856
  prompt_type_button = gr.Button(value="Convert prompt to Pony e621 style", size="sm", variant="secondary")
857
  with gr.Row():
@@ -902,18 +843,30 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
902
  actual_task_info = gr.HTML()
903
 
904
  with gr.Accordion("Generation settings", open=False, visible=True) as menu_gen:
905
- steps_gui = gr.Slider(minimum=1, maximum=100, step=1, value=28, label="Steps")
906
- cfg_gui = gr.Slider(minimum=0, maximum=30, step=0.5, value=7.0, label="CFG")
907
- sampler_gui = gr.Dropdown(label="Sampler", choices=scheduler_names, value="Euler a")
908
- img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
909
- img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
910
  with gr.Row():
 
 
 
 
 
 
 
911
  clip_skip_gui = gr.Checkbox(value=False, label="Layer 2 Clip Skip")
912
  free_u_gui = gr.Checkbox(value=False, label="FreeU")
913
- seed_gui = gr.Number(minimum=-1, maximum=9999999999, value=-1, label="Seed")
 
 
 
 
 
 
 
 
 
 
 
914
 
915
  with gr.Row(equal_height=False):
916
-
917
  def run_set_params_gui(base_prompt):
918
  valid_receptors = { # default values
919
  "prompt": gr.update(value=base_prompt),
@@ -981,134 +934,190 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
981
  run_set_random_seed, [], seed_gui
982
  )
983
 
984
- num_images_gui = gr.Slider(minimum=1, maximum=4, step=1, value=1, label="Images")
985
- prompt_s_options = [
986
- ("Compel format: (word)weight", "Compel"),
987
- ("Classic format: (word:weight)", "Classic"),
988
- ("Classic-original format: (word:weight)", "Classic-original"),
989
- ("Classic-no_norm format: (word:weight)", "Classic-no_norm"),
990
- ("Classic-ignore", "Classic-ignore"),
991
- ("None", "None"),
992
- ]
993
- prompt_syntax_gui = gr.Dropdown(label="Prompt Syntax", choices=prompt_s_options, value=prompt_s_options[1][1])
994
- vae_model_gui = gr.Dropdown(label="VAE Model", choices=vae_model_list, value=vae_model_list[0])
995
-
996
- with gr.Accordion("Hires fix", open=False, visible=True) as menu_hires:
997
- upscaler_keys = list(upscaler_dict_gui.keys())
998
- upscaler_model_path_gui = gr.Dropdown(label="Upscaler", choices=upscaler_keys, value=upscaler_dict_gui[upscaler_keys[0]])
999
- upscaler_increases_size_gui = gr.Slider(minimum=1.1, maximum=6., step=0.1, value=1.0, label="Upscale by")
1000
- esrgan_tile_gui = gr.Slider(minimum=0, value=100, maximum=500, step=1, label="ESRGAN Tile")
1001
- esrgan_tile_overlap_gui = gr.Slider(minimum=1, maximum=200, step=1, value=10, label="ESRGAN Tile Overlap")
1002
- hires_steps_gui = gr.Slider(minimum=0, value=30, maximum=100, step=1, label="Hires Steps")
1003
- hires_denoising_strength_gui = gr.Slider(minimum=0.1, maximum=1.0, step=0.01, value=0.55, label="Hires Denoising Strength")
1004
- hires_sampler_gui = gr.Dropdown(label="Hires Sampler", choices=["Use same sampler"] + scheduler_names[:-1], value="Use same sampler")
1005
- hires_prompt_gui = gr.Textbox(label="Hires Prompt", placeholder="Main prompt will be use", lines=3)
1006
- hires_negative_prompt_gui = gr.Textbox(label="Hires Negative Prompt", placeholder="Main negative prompt will be use", lines=3)
1007
-
1008
  with gr.Accordion("LoRA", open=False, visible=True) as menu_lora:
1009
- lora1_gui = gr.Dropdown(label="LoRA1", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True)
1010
- lora_scale_1_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 1")
1011
- with gr.Row():
1012
- with gr.Group():
1013
- lora1_info_gui = gr.Textbox(label="LoRA1 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
1014
- lora1_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
1015
- lora1_desc_gui = gr.Markdown(value="", visible=False)
1016
- lora2_gui = gr.Dropdown(label="LoRA2", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True)
1017
- lora_scale_2_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 2")
1018
- with gr.Row():
1019
- with gr.Group():
1020
- lora2_info_gui = gr.Textbox(label="LoRA2 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
1021
- lora2_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
1022
- lora2_desc_gui = gr.Markdown(value="", visible=False)
1023
- lora3_gui = gr.Dropdown(label="LoRA3", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True)
1024
- lora_scale_3_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 3")
1025
  with gr.Row():
1026
- with gr.Group():
1027
- lora3_info_gui = gr.Textbox(label="LoRA3 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
1028
- lora3_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
1029
- lora3_desc_gui = gr.Markdown(value="", visible=False)
1030
- lora4_gui = gr.Dropdown(label="LoRA4", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True)
1031
- lora_scale_4_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 4")
1032
- with gr.Row():
1033
- with gr.Group():
1034
- lora4_info_gui = gr.Textbox(label="LoRA4 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
1035
- lora4_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
1036
- lora4_desc_gui = gr.Markdown(value="", visible=False)
1037
- lora5_gui = gr.Dropdown(label="LoRA5", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True)
1038
- lora_scale_5_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 5")
1039
- with gr.Row():
1040
- with gr.Group():
1041
- lora5_info_gui = gr.Textbox(label="LoRA5 prompts", info="Example of prompt", value="None", show_copy_button=True, interactive=False, visible=False)
1042
- lora5_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
1043
- lora5_desc_gui = gr.Markdown(value="", visible=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1044
  with gr.Accordion("From URL", open=True, visible=True):
1045
  with gr.Row():
1046
  search_civitai_query_lora = gr.Textbox(label="Query", placeholder="oomuro sakurako...", lines=1)
1047
  search_civitai_basemodel_lora = gr.CheckboxGroup(label="Search LoRA for", choices=["Pony", "SD 1.5", "SDXL 1.0"], value=["Pony", "SDXL 1.0"])
1048
  search_civitai_button_lora = gr.Button("Search on Civitai")
1049
- search_civitai_result_lora = gr.Dropdown(label="Search Results", choices=[("", "")], value="", allow_custom_value=True, visible=False)
1050
  search_civitai_desc_lora = gr.Markdown(value="", visible=False)
 
1051
  text_lora = gr.Textbox(label="URL", placeholder="http://...my_lora_url.safetensors", lines=1)
1052
  button_lora = gr.Button("Get and update lists of LoRAs")
1053
  with gr.Accordion("From Local", open=True, visible=True):
1054
  file_output_lora = gr.File(label="Uploaded LoRA", file_types=['.ckpt', '.pt', '.pth', '.safetensors', '.bin'], file_count="multiple", interactive=False, visible=False)
1055
  upload_button_lora = gr.UploadButton(label="Upload LoRA from your disk (very slow)", file_types=['.ckpt' , '.pt', '.pth', '.safetensors', '.bin'], file_count="multiple")
1056
 
1057
- with gr.Accordion("ControlNet / Img2img / Inpaint", open=False, visible=True) as menu_i2i:
1058
- image_control = gr.Image(label="Image ControlNet/Inpaint/Img2img", type="filepath")
1059
- image_mask_gui = gr.Image(label="Image Mask", type="filepath")
1060
- strength_gui = gr.Slider(
1061
- minimum=0.01, maximum=1.0, step=0.01, value=0.55, label="Strength",
1062
- info="This option adjusts the level of changes for img2img and inpainting."
1063
- )
1064
- image_resolution_gui = gr.Slider(minimum=64, maximum=2048, step=64, value=1024, label="Image Resolution")
1065
- preprocessor_name_gui = gr.Dropdown(label="Preprocessor Name", choices=preprocessor_controlnet["canny"], value=preprocessor_controlnet["canny"][0])
1066
-
1067
- def change_preprocessor_choices(task):
1068
- task = task_stablepy[task]
1069
- if task in preprocessor_controlnet.keys():
1070
- choices_task = preprocessor_controlnet[task]
1071
- else:
1072
- choices_task = preprocessor_controlnet["canny"]
1073
- return gr.update(choices=choices_task, value=choices_task[0])
1074
-
1075
- task_gui.change(
1076
- change_preprocessor_choices,
1077
- [task_gui],
1078
- [preprocessor_name_gui],
1079
- )
1080
- preprocess_resolution_gui = gr.Slider(minimum=64, maximum=2048, step=64, value=512, label="Preprocess Resolution")
1081
- low_threshold_gui = gr.Slider(minimum=1, maximum=255, step=1, value=100, label="Canny low threshold")
1082
- high_threshold_gui = gr.Slider(minimum=1, maximum=255, step=1, value=200, label="Canny high threshold")
1083
- value_threshold_gui = gr.Slider(minimum=1, maximum=2.0, step=0.01, value=0.1, label="Hough value threshold (MLSD)")
1084
- distance_threshold_gui = gr.Slider(minimum=1, maximum=20.0, step=0.01, value=0.1, label="Hough distance threshold (MLSD)")
1085
- control_net_output_scaling_gui = gr.Slider(minimum=0, maximum=5.0, step=0.1, value=1, label="ControlNet Output Scaling in UNet")
1086
- control_net_start_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=0, label="ControlNet Start Threshold (%)")
1087
- control_net_stop_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="ControlNet Stop Threshold (%)")
1088
-
1089
- with gr.Accordion("Advanced functions", open=False, visible=True) as menu_advanced:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1090
  with gr.Accordion("IP-Adapter", open=False, visible=True) as menu_ipa:##############
1091
 
1092
  IP_MODELS = sorted(list(set(IP_ADAPTERS_SD + IP_ADAPTERS_SDXL)))
1093
  MODE_IP_OPTIONS = ["original", "style", "layout", "style+layout"]
1094
 
1095
- with gr.Accordion("IP-Adapter 1", open=False, visible=True):
1096
- image_ip1 = gr.Image(label="IP Image", type="filepath")
1097
- mask_ip1 = gr.Image(label="IP Mask", type="filepath")
1098
- model_ip1 = gr.Dropdown(value="plus_face", label="Model", choices=IP_MODELS)
1099
- mode_ip1 = gr.Dropdown(value="original", label="Mode", choices=MODE_IP_OPTIONS)
 
 
1100
  scale_ip1 = gr.Slider(minimum=0., maximum=2., step=0.01, value=0.7, label="Scale")
1101
- with gr.Accordion("IP-Adapter 2", open=False, visible=True):
1102
- image_ip2 = gr.Image(label="IP Image", type="filepath")
1103
- mask_ip2 = gr.Image(label="IP Mask (optional)", type="filepath")
1104
- model_ip2 = gr.Dropdown(value="base", label="Model", choices=IP_MODELS)
1105
- mode_ip2 = gr.Dropdown(value="style", label="Mode", choices=MODE_IP_OPTIONS)
 
 
1106
  scale_ip2 = gr.Slider(minimum=0., maximum=2., step=0.01, value=0.7, label="Scale")
1107
 
1108
  with gr.Accordion("T2I adapter", open=False, visible=True) as menu_t2i:
1109
  t2i_adapter_preprocessor_gui = gr.Checkbox(value=True, label="T2i Adapter Preprocessor")
1110
- adapter_conditioning_scale_gui = gr.Slider(minimum=0, maximum=5., step=0.1, value=1, label="Adapter Conditioning Scale")
1111
- adapter_conditioning_factor_gui = gr.Slider(minimum=0, maximum=1., step=0.01, value=0.55, label="Adapter Conditioning Factor (%)")
 
1112
 
1113
  with gr.Accordion("Styles", open=False, visible=True) as menu_styles:
1114
 
@@ -1138,57 +1147,12 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1138
 
1139
  style_button.click(load_json_style_file, [style_json_gui], [style_prompt_gui])
1140
 
1141
- with gr.Accordion("Textual inversion", open=False, visible=True) as menu_ti:
1142
- active_textual_inversion_gui = gr.Checkbox(value=False, label="Active Textual Inversion in prompt")
1143
- use_textual_inversion_gui = gr.CheckboxGroup(choices=get_embed_list(get_model_pipeline(model_name_gui.value)) if active_textual_inversion_gui.value else [], value=None, label="Use Textual Invertion in prompt")
1144
- def update_textual_inversion_gui(active_textual_inversion_gui, model_name_gui):
1145
- return gr.update(choices=get_embed_list(get_model_pipeline(model_name_gui)) if active_textual_inversion_gui else [])
1146
- active_textual_inversion_gui.change(update_textual_inversion_gui, [active_textual_inversion_gui, model_name_gui], [use_textual_inversion_gui])
1147
- model_name_gui.change(update_textual_inversion_gui, [active_textual_inversion_gui, model_name_gui], [use_textual_inversion_gui])
1148
-
1149
- with gr.Accordion("Detailfix", open=False, visible=True) as menu_detail:
1150
-
1151
- # Adetailer Inpaint Only
1152
- adetailer_inpaint_only_gui = gr.Checkbox(label="Inpaint only", value=True)
1153
-
1154
- # Adetailer Verbose
1155
- adetailer_verbose_gui = gr.Checkbox(label="Verbose", value=False)
1156
-
1157
- # Adetailer Sampler
1158
- adetailer_sampler_options = ["Use same sampler"] + scheduler_names[:-1]
1159
- adetailer_sampler_gui = gr.Dropdown(label="Adetailer sampler:", choices=adetailer_sampler_options, value="Use same sampler")
1160
-
1161
- with gr.Accordion("Detailfix A", open=False, visible=True):
1162
- # Adetailer A
1163
- adetailer_active_a_gui = gr.Checkbox(label="Enable Adetailer A", value=False)
1164
- prompt_ad_a_gui = gr.Textbox(label="Main prompt", placeholder="Main prompt will be use", lines=3)
1165
- negative_prompt_ad_a_gui = gr.Textbox(label="Negative prompt", placeholder="Main negative prompt will be use", lines=3)
1166
- strength_ad_a_gui = gr.Number(label="Strength:", value=0.35, step=0.01, minimum=0.01, maximum=1.0)
1167
- face_detector_ad_a_gui = gr.Checkbox(label="Face detector", value=True)
1168
- person_detector_ad_a_gui = gr.Checkbox(label="Person detector", value=True)
1169
- hand_detector_ad_a_gui = gr.Checkbox(label="Hand detector", value=False)
1170
- mask_dilation_a_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
1171
- mask_blur_a_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
1172
- mask_padding_a_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
1173
-
1174
- with gr.Accordion("Detailfix B", open=False, visible=True):
1175
- # Adetailer B
1176
- adetailer_active_b_gui = gr.Checkbox(label="Enable Adetailer B", value=False)
1177
- prompt_ad_b_gui = gr.Textbox(label="Main prompt", placeholder="Main prompt will be use", lines=3)
1178
- negative_prompt_ad_b_gui = gr.Textbox(label="Negative prompt", placeholder="Main negative prompt will be use", lines=3)
1179
- strength_ad_b_gui = gr.Number(label="Strength:", value=0.35, step=0.01, minimum=0.01, maximum=1.0)
1180
- face_detector_ad_b_gui = gr.Checkbox(label="Face detector", value=True)
1181
- person_detector_ad_b_gui = gr.Checkbox(label="Person detector", value=True)
1182
- hand_detector_ad_b_gui = gr.Checkbox(label="Hand detector", value=False)
1183
- mask_dilation_b_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
1184
- mask_blur_b_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
1185
- mask_padding_b_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
1186
-
1187
  with gr.Accordion("Other settings", open=False, visible=True) as menu_other:
1188
- image_previews_gui = gr.Checkbox(value=False, label="Image Previews")
1189
- hires_before_adetailer_gui = gr.Checkbox(value=False, label="Hires Before Adetailer")
1190
- hires_after_adetailer_gui = gr.Checkbox(value=True, label="Hires After Adetailer")
1191
- generator_in_cpu_gui = gr.Checkbox(value=False, label="Generator in CPU")
 
1192
 
1193
  with gr.Accordion("More settings", open=False, visible=False):
1194
  loop_generation_gui = gr.Slider(minimum=1, value=1, label="Loop Generation")
@@ -1203,9 +1167,7 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1203
  retain_hires_model_previous_load_gui = gr.Checkbox(value=False, label="Retain Hires Model Previous Load")
1204
  xformers_memory_efficient_attention_gui = gr.Checkbox(value=False, label="Xformers Memory Efficient Attention")
1205
 
1206
- with gr.Accordion("Examples and help", open=False, visible=False) as menu_example:
1207
- dummy_gui = gr.Checkbox(visible=False, label="dummy")
1208
- """with gr.Accordion("Examples and help", open=False, visible=True) as menu_example:
1209
  gr.Examples(
1210
  examples=[
1211
  [
@@ -1216,40 +1178,10 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1216
  7.5,
1217
  True,
1218
  -1,
1219
- None,
1220
- 1.0,
1221
- None,
1222
- 1.0,
1223
- None,
1224
- 1.0,
1225
- None,
1226
- 1.0,
1227
- None,
1228
- 1.0,
1229
  "Euler a",
1230
  1152,
1231
  896,
1232
  "votepurchase/animagine-xl-3.1",
1233
- None, # vae
1234
- "txt2img",
1235
- None, # img conttol
1236
- "Canny", # preprocessor
1237
- 512, # preproc resolution
1238
- 1024, # img resolution
1239
- None, # Style prompt
1240
- None, # Style json
1241
- None, # img Mask
1242
- 0.35, # strength
1243
- 100, # low th canny
1244
- 200, # high th canny
1245
- 0.1, # value mstd
1246
- 0.1, # distance mstd
1247
- 1.0, # cn scale
1248
- 0., # cn start
1249
- 1., # cn end
1250
- False, # ti
1251
- "Classic",
1252
- None,
1253
  ],
1254
  [
1255
  "solo, princess Zelda OOT, score_9, score_8_up, score_8, medium breasts, cute, eyelashes, cute small face, long hair, crown braid, hairclip, pointy ears, soft curvy body, looking at viewer, smile, blush, white dress, medium body, (((holding the Master Sword))), standing, deep forest in the background",
@@ -1259,40 +1191,10 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1259
  5.,
1260
  True,
1261
  -1,
1262
- None,
1263
- 1.0,
1264
- None,
1265
- 1.0,
1266
- None,
1267
- 1.0,
1268
- None,
1269
- 1.0,
1270
- None,
1271
- 1.0,
1272
  "Euler a",
1273
  1024,
1274
  1024,
1275
  "votepurchase/ponyDiffusionV6XL",
1276
- None, # vae
1277
- "txt2img",
1278
- None, # img conttol
1279
- "Canny", # preprocessor
1280
- 512, # preproc resolution
1281
- 1024, # img resolution
1282
- None, # Style prompt
1283
- None, # Style json
1284
- None, # img Mask
1285
- 0.35, # strength
1286
- 100, # low th canny
1287
- 200, # high th canny
1288
- 0.1, # value mstd
1289
- 0.1, # distance mstd
1290
- 1.0, # cn scale
1291
- 0., # cn start
1292
- 1., # cn end
1293
- False, # ti
1294
- "Classic",
1295
- None,
1296
  ],
1297
  [
1298
  "1girl, oomuro sakurako, yuru yuri, official art, school uniform, anime artwork, anime style, vibrant, studio anime, highly detailed, masterpiece, best quality, very aesthetic, absurdres",
@@ -1302,40 +1204,10 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1302
  7.0,
1303
  True,
1304
  -1,
1305
- None,
1306
- 1.0,
1307
- None,
1308
- 1.0,
1309
- None,
1310
- 1.0,
1311
- None,
1312
- 1.0,
1313
- None,
1314
- 1.0,
1315
  "Euler a",
1316
  1024,
1317
  1024,
1318
  "Raelina/Rae-Diffusion-XL-V2",
1319
- None, # vae
1320
- "txt2img",
1321
- None, # img conttol
1322
- "Canny", # preprocessor
1323
- 512, # preproc resolution
1324
- 1024, # img resolution
1325
- None, # Style prompt
1326
- None, # Style json
1327
- None, # img Mask
1328
- 0.35, # strength
1329
- 100, # low th canny
1330
- 200, # high th canny
1331
- 0.1, # value mstd
1332
- 0.1, # distance mstd
1333
- 1.0, # cn scale
1334
- 0., # cn start
1335
- 1., # cn end
1336
- False, # ti
1337
- "Classic",
1338
- None,
1339
  ],
1340
  [
1341
  "1girl, akaza akari, yuru yuri, official art, anime artwork, anime style, vibrant, studio anime, highly detailed, masterpiece, best quality, very aesthetic, absurdres",
@@ -1345,40 +1217,10 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1345
  7.0,
1346
  True,
1347
  -1,
1348
- None,
1349
- 1.0,
1350
- None,
1351
- 1.0,
1352
- None,
1353
- 1.0,
1354
- None,
1355
- 1.0,
1356
- None,
1357
- 1.0,
1358
  "Euler a",
1359
  1024,
1360
  1024,
1361
  "Raelina/Raemu-XL-V4",
1362
- None, # vae
1363
- "txt2img",
1364
- None, # img conttol
1365
- "Canny", # preprocessor
1366
- 512, # preproc resolution
1367
- 1024, # img resolution
1368
- None, # Style prompt
1369
- None, # Style json
1370
- None, # img Mask
1371
- 0.35, # strength
1372
- 100, # low th canny
1373
- 200, # high th canny
1374
- 0.1, # value mstd
1375
- 0.1, # distance mstd
1376
- 1.0, # cn scale
1377
- 0., # cn start
1378
- 1., # cn end
1379
- False, # ti
1380
- "Classic",
1381
- None,
1382
  ],
1383
  [
1384
  "yoshida yuuko, machikado mazoku, 1girl, solo, demon horns,horns, school uniform, long hair, open mouth, skirt, demon girl, ahoge, shiny, shiny hair, anime artwork",
@@ -1388,40 +1230,10 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1388
  7.,
1389
  True,
1390
  -1,
1391
- None,
1392
- 1.0,
1393
- None,
1394
- 1.0,
1395
- None,
1396
- 1.0,
1397
- None,
1398
- 1.0,
1399
- None,
1400
- 1.0,
1401
  "Euler a",
1402
  1024,
1403
  1024,
1404
  "votepurchase/animagine-xl-3.1",
1405
- None, # vae
1406
- "img2img",
1407
- "color_image.png", # img conttol
1408
- "Canny", # preprocessor
1409
- 512, # preproc resolution
1410
- 1024, # img resolution
1411
- None, # Style prompt
1412
- None, # Style json
1413
- None, # img Mask
1414
- 0.6, # strength
1415
- 100, # low th canny
1416
- 200, # high th canny
1417
- 0.1, # value mstd
1418
- 0.1, # distance mstd
1419
- 1.0, # cn scale
1420
- 0., # cn start
1421
- 1., # cn end
1422
- False, # ti
1423
- "Classic",
1424
- None,
1425
  ],
1426
  ],
1427
  #fn=sd_gen.generate_pipeline,
@@ -1433,45 +1245,15 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1433
  cfg_gui,
1434
  clip_skip_gui,
1435
  seed_gui,
1436
- lora1_gui,
1437
- lora_scale_1_gui,
1438
- lora2_gui,
1439
- lora_scale_2_gui,
1440
- lora3_gui,
1441
- lora_scale_3_gui,
1442
- lora4_gui,
1443
- lora_scale_4_gui,
1444
- lora5_gui,
1445
- lora_scale_5_gui,
1446
  sampler_gui,
1447
  img_height_gui,
1448
  img_width_gui,
1449
  model_name_gui,
1450
- vae_model_gui,
1451
- task_gui,
1452
- image_control,
1453
- preprocessor_name_gui,
1454
- preprocess_resolution_gui,
1455
- image_resolution_gui,
1456
- style_prompt_gui,
1457
- style_json_gui,
1458
- image_mask_gui,
1459
- strength_gui,
1460
- low_threshold_gui,
1461
- high_threshold_gui,
1462
- value_threshold_gui,
1463
- distance_threshold_gui,
1464
- control_net_output_scaling_gui,
1465
- control_net_start_threshold_gui,
1466
- control_net_stop_threshold_gui,
1467
- active_textual_inversion_gui,
1468
- prompt_syntax_gui,
1469
- upscaler_model_path_gui,
1470
  ],
1471
  #outputs=[result_images],
1472
  cache_examples=False,
1473
  elem_id="examples",
1474
- )"""
1475
  ## END MOD
1476
 
1477
  with gr.Tab("Inpaint mask maker", render=True):
@@ -1750,7 +1532,7 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", elem_id="main", fill_width=True, cs
1750
  outputs=[result_images, actual_task_info],
1751
  queue=True,
1752
  show_progress="full",
1753
- ).success(save_gallery_images, [result_images], [result_images, result_images_files, result_images_files], queue=False)
1754
 
1755
  with gr.Tab("Danbooru Tags Transformer with WD Tagger", render=True):
1756
  with gr.Column(scale=2):
 
1
  import spaces
2
+ import gradio as gr
 
 
 
 
3
  import os
4
  from stablepy import Model_Diffusers
5
  from stablepy.diffusers_vanilla.model import scheduler_names
 
162
 
163
 
164
  ## BEGIN MOD
165
+ from modutils import (list_uniq, download_private_repo, get_model_id_list, get_tupled_embed_list,
166
+ get_lora_model_list, get_all_lora_tupled_list, update_loras, apply_lora_prompt, set_prompt_loras,
167
+ get_my_lora, upload_file_lora, move_file_lora, search_civitai_lora, select_civitai_lora,
168
+ set_textual_inversion_prompt, get_model_pipeline, change_interface_mode, get_t2i_model_info,
169
+ get_tupled_model_list, save_gallery_images, set_optimization, set_sampler_settings,
170
+ set_quick_presets, process_style_prompt, optimization_list,
171
+ preset_styles, preset_quality, preset_sampler_setting)
172
+ from env import (hf_token, CIVITAI_API_KEY, HF_LORA_ESSENTIAL_PRIVATE_REPO, HF_VAE_PRIVATE_REPO,
173
+ HF_SDXL_EMBEDS_NEGATIVE_PRIVATE_REPO, HF_SDXL_EMBEDS_POSITIVE_PRIVATE_REPO,
174
+ directory_models, directory_loras, directory_vaes, directory_embeds, directory_embeds_sdxl,
175
+ directory_embeds_positive_sdxl, load_diffusers_format_model,
176
+ download_model_list, download_lora_list, download_vae_list, download_embeds)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
  # - **Download Models**
179
  download_model = ", ".join(download_model_list)
 
287
  #######################
288
  # GUI
289
  #######################
 
290
  import gradio as gr
291
  from PIL import Image
292
  import IPython.display
 
304
  from stablepy import logger
305
  logger.setLevel(logging.CRITICAL)
306
 
307
+ from v2 import V2_ALL_MODELS, v2_random_prompt, v2_upsampling_prompt
308
+ from utils import (gradio_copy_text, COPY_ACTION_JS, gradio_copy_prompt,
309
+ V2_ASPECT_RATIO_OPTIONS, V2_RATING_OPTIONS, V2_LENGTH_OPTIONS, V2_IDENTITY_OPTIONS)
310
+ from tagger import (predict_tags_wd, convert_danbooru_to_e621_prompt,
311
+ remove_specific_prompt, insert_recom_prompt, insert_model_recom_prompt,
312
+ compose_prompt_to_copy, translate_prompt, select_random_character)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  def description_ui():
314
  gr.Markdown(
315
  """
 
371
  if incompatible_vae:
372
  vae_model = None
373
 
 
374
  self.model.load_pipe(
375
  model_name,
376
  task_name=task_stablepy[task],
 
718
  info_state = info_state + "<br>" + "<br>".join(msg_lora)
719
  yield self.infer_short(self.model, pipe_params), info_state
720
 
 
721
  sd_gen = GuiSD()
722
 
723
  ## BEGIN MOD
724
  CSS ="""
725
+ .gradio-container, #main { width:100%; height:100%; max-width:100%; padding-left:0; padding-right:0; margin-left:0; margin-right:0; !important; }
726
+ .contain { display:flex; flex-direction:column; !important; }
727
+ #component-0 { width:100%; height:100%; !important; }
728
+ #gallery { flex-grow:1; !important; }
729
+ .lora { min-width:480px; !important; }
730
+ #model-info { text-align:center; }
731
  """
732
  ## END MOD
733
 
 
748
  return gr.update(value=task_name, choices=task_model_list)
749
 
750
  ## BEGIN MOD
751
+ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, css=CSS) as app:
752
  gr.Markdown("# 🧩 DiffuseCraft Mod")
753
  gr.Markdown(
754
  f"""
 
769
  quick_genre_gui = gr.Radio(label="Genre", choices=["Anime", "Photo"], value="Anime", interactive=True)
770
  quick_speed_gui = gr.Radio(label="Speed", choices=["Fast", "Standard", "Heavy"], value="Standard", interactive=True)
771
  quick_aspect_gui = gr.Radio(label="Aspect Ratio", choices=["1:1", "3:4"], value="1:1", interactive=True)
772
+ with gr.Row():
773
  quality_selector_gui = gr.Dropdown(label="Quality Tags Presets", interactive=True, choices=list(preset_quality.keys()), value="None")
774
  style_selector_gui = gr.Dropdown(label="Style Preset", interactive=True, choices=list(preset_styles.keys()), value="None")
775
  sampler_selector_gui = gr.Dropdown(label="Sampler Quick Settings", interactive=True, choices=list(preset_sampler_setting.keys()), value="None")
 
778
  with gr.Accordion("Prompt from Image", open=False) as menu_from_image:
779
  input_image_gui = gr.Image(label="Input image", type="pil", sources=["upload", "clipboard"], height=256)
780
  with gr.Accordion(label="Advanced options", open=False):
781
+ with gr.Row():
782
+ general_threshold_gui = gr.Slider(label="Threshold", minimum=0.0, maximum=1.0, value=0.3, step=0.01, interactive=True)
783
+ character_threshold_gui = gr.Slider(label="Character threshold", minimum=0.0, maximum=1.0, value=0.8, step=0.01, interactive=True)
784
+ with gr.Row():
785
+ tag_type_gui = gr.Radio(label="Convert tags to", info="danbooru for Animagine, e621 for Pony.", choices=["danbooru", "e621"], value="danbooru")
786
+ recom_prompt_gui = gr.Radio(label="Insert reccomended prompt", choices=["None", "Animagine", "Pony"], value="None", interactive=True)
787
+ keep_tags_gui = gr.Radio(label="Remove tags leaving only the following", choices=["body", "dress", "all"], value="all")
788
+ image_algorithms = gr.CheckboxGroup(["Use WD Tagger"], label="Algorithms", value=["Use WD Tagger"], visible=False)
789
  generate_from_image_btn_gui = gr.Button(value="GENERATE TAGS FROM IMAGE")
790
  prompt_gui = gr.Textbox(lines=6, placeholder="1girl, solo, ...", label="Prompt", show_copy_button=True)
791
  with gr.Accordion("Negative prompt, etc.", open=False) as menu_negative:
792
  neg_prompt_gui = gr.Textbox(lines=3, placeholder="lowres, (bad), ...", label="Negative prompt", show_copy_button=True)
793
  translate_prompt_button = gr.Button(value="Translate prompt to English", size="sm", variant="secondary")
794
+ with gr.Row():
795
+ insert_prompt_gui = gr.Radio(label="Insert reccomended positive / negative prompt", choices=["None", "Auto", "Animagine", "Pony"], value="Auto", interactive=True)
796
  prompt_type_gui = gr.Radio(label="Convert tags to", choices=["danbooru", "e621"], value="e621", visible=False)
797
  prompt_type_button = gr.Button(value="Convert prompt to Pony e621 style", size="sm", variant="secondary")
798
  with gr.Row():
 
843
  actual_task_info = gr.HTML()
844
 
845
  with gr.Accordion("Generation settings", open=False, visible=True) as menu_gen:
 
 
 
 
 
846
  with gr.Row():
847
+ img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
848
+ img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
849
+ steps_gui = gr.Slider(minimum=1, maximum=100, step=1, value=28, label="Steps")
850
+ cfg_gui = gr.Slider(minimum=0, maximum=30, step=0.5, value=7.0, label="CFG")
851
+ with gr.Row():
852
+ seed_gui = gr.Number(minimum=-1, maximum=9999999999, value=-1, label="Seed")
853
+ num_images_gui = gr.Slider(minimum=1, maximum=4, step=1, value=1, label="Images")
854
  clip_skip_gui = gr.Checkbox(value=False, label="Layer 2 Clip Skip")
855
  free_u_gui = gr.Checkbox(value=False, label="FreeU")
856
+ with gr.Row():
857
+ sampler_gui = gr.Dropdown(label="Sampler", choices=scheduler_names, value="Euler a")
858
+ vae_model_gui = gr.Dropdown(label="VAE Model", choices=vae_model_list, value=vae_model_list[0])
859
+ prompt_s_options = [
860
+ ("Compel format: (word)weight", "Compel"),
861
+ ("Classic format: (word:weight)", "Classic"),
862
+ ("Classic-original format: (word:weight)", "Classic-original"),
863
+ ("Classic-no_norm format: (word:weight)", "Classic-no_norm"),
864
+ ("Classic-ignore", "Classic-ignore"),
865
+ ("None", "None"),
866
+ ]
867
+ prompt_syntax_gui = gr.Dropdown(label="Prompt Syntax", choices=prompt_s_options, value=prompt_s_options[1][1])
868
 
869
  with gr.Row(equal_height=False):
 
870
  def run_set_params_gui(base_prompt):
871
  valid_receptors = { # default values
872
  "prompt": gr.update(value=base_prompt),
 
934
  run_set_random_seed, [], seed_gui
935
  )
936
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
937
  with gr.Accordion("LoRA", open=False, visible=True) as menu_lora:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
938
  with gr.Row():
939
+ with gr.Column():
940
+ lora1_gui = gr.Dropdown(label="LoRA1", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True, elem_classes="lora", min_width=320)
941
+ lora_scale_1_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 1")
942
+ with gr.Row():
943
+ with gr.Group():
944
+ lora1_info_gui = gr.Textbox(label="LoRA1 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
945
+ lora1_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
946
+ lora1_desc_gui = gr.Markdown(value="", visible=False)
947
+ with gr.Column():
948
+ lora2_gui = gr.Dropdown(label="LoRA2", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True, elem_classes="lora", min_width=320)
949
+ lora_scale_2_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 2")
950
+ with gr.Row():
951
+ with gr.Group():
952
+ lora2_info_gui = gr.Textbox(label="LoRA2 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
953
+ lora2_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
954
+ lora2_desc_gui = gr.Markdown(value="", visible=False)
955
+ with gr.Column():
956
+ lora3_gui = gr.Dropdown(label="LoRA3", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True, elem_classes="lora", min_width=320)
957
+ lora_scale_3_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 3")
958
+ with gr.Row():
959
+ with gr.Group():
960
+ lora3_info_gui = gr.Textbox(label="LoRA3 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
961
+ lora3_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
962
+ lora3_desc_gui = gr.Markdown(value="", visible=False)
963
+ with gr.Column():
964
+ lora4_gui = gr.Dropdown(label="LoRA4", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True, elem_classes="lora", min_width=320)
965
+ lora_scale_4_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 4")
966
+ with gr.Row():
967
+ with gr.Group():
968
+ lora4_info_gui = gr.Textbox(label="LoRA4 prompts", info="Example of prompt:", value="None", show_copy_button=True, interactive=False, visible=False)
969
+ lora4_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
970
+ lora4_desc_gui = gr.Markdown(value="", visible=False)
971
+ with gr.Column():
972
+ lora5_gui = gr.Dropdown(label="LoRA5", choices=get_all_lora_tupled_list(), value="", allow_custom_value=True, elem_classes="lora", min_width=320)
973
+ lora_scale_5_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA Scale 5")
974
+ with gr.Row():
975
+ with gr.Group():
976
+ lora5_info_gui = gr.Textbox(label="LoRA5 prompts", info="Example of prompt", value="None", show_copy_button=True, interactive=False, visible=False)
977
+ lora5_copy_gui = gr.Button(value="Copy example to prompt", visible=False)
978
+ lora5_desc_gui = gr.Markdown(value="", visible=False)
979
  with gr.Accordion("From URL", open=True, visible=True):
980
  with gr.Row():
981
  search_civitai_query_lora = gr.Textbox(label="Query", placeholder="oomuro sakurako...", lines=1)
982
  search_civitai_basemodel_lora = gr.CheckboxGroup(label="Search LoRA for", choices=["Pony", "SD 1.5", "SDXL 1.0"], value=["Pony", "SDXL 1.0"])
983
  search_civitai_button_lora = gr.Button("Search on Civitai")
 
984
  search_civitai_desc_lora = gr.Markdown(value="", visible=False)
985
+ search_civitai_result_lora = gr.Dropdown(label="Search Results", choices=[("", "")], value="", allow_custom_value=True, visible=False)
986
  text_lora = gr.Textbox(label="URL", placeholder="http://...my_lora_url.safetensors", lines=1)
987
  button_lora = gr.Button("Get and update lists of LoRAs")
988
  with gr.Accordion("From Local", open=True, visible=True):
989
  file_output_lora = gr.File(label="Uploaded LoRA", file_types=['.ckpt', '.pt', '.pth', '.safetensors', '.bin'], file_count="multiple", interactive=False, visible=False)
990
  upload_button_lora = gr.UploadButton(label="Upload LoRA from your disk (very slow)", file_types=['.ckpt' , '.pt', '.pth', '.safetensors', '.bin'], file_count="multiple")
991
 
992
+ with gr.Column() as menu_advanced:
993
+ with gr.Accordion("Hires fix", open=False, visible=True) as menu_hires:
994
+ upscaler_keys = list(upscaler_dict_gui.keys())
995
+ upscaler_model_path_gui = gr.Dropdown(label="Upscaler", choices=upscaler_keys, value=upscaler_dict_gui[upscaler_keys[0]])
996
+ with gr.Row():
997
+ upscaler_increases_size_gui = gr.Slider(minimum=1.1, maximum=6., step=0.1, value=1.0, label="Upscale by")
998
+ esrgan_tile_gui = gr.Slider(minimum=0, value=100, maximum=500, step=1, label="ESRGAN Tile")
999
+ esrgan_tile_overlap_gui = gr.Slider(minimum=1, maximum=200, step=1, value=10, label="ESRGAN Tile Overlap")
1000
+ with gr.Row():
1001
+ hires_steps_gui = gr.Slider(minimum=0, value=30, maximum=100, step=1, label="Hires Steps")
1002
+ hires_denoising_strength_gui = gr.Slider(minimum=0.1, maximum=1.0, step=0.01, value=0.55, label="Hires Denoising Strength")
1003
+ hires_sampler_gui = gr.Dropdown(label="Hires Sampler", choices=["Use same sampler"] + scheduler_names[:-1], value="Use same sampler")
1004
+ hires_prompt_gui = gr.Textbox(label="Hires Prompt", placeholder="Main prompt will be use", lines=3)
1005
+ hires_negative_prompt_gui = gr.Textbox(label="Hires Negative Prompt", placeholder="Main negative prompt will be use", lines=3)
1006
+
1007
+ with gr.Accordion("Detailfix", open=False, visible=True) as menu_detail:
1008
+ with gr.Row():
1009
+
1010
+ # Adetailer Inpaint Only
1011
+ adetailer_inpaint_only_gui = gr.Checkbox(label="Inpaint only", value=True)
1012
+
1013
+ # Adetailer Verbose
1014
+ adetailer_verbose_gui = gr.Checkbox(label="Verbose", value=False)
1015
+
1016
+ # Adetailer Sampler
1017
+ adetailer_sampler_options = ["Use same sampler"] + scheduler_names[:-1]
1018
+ adetailer_sampler_gui = gr.Dropdown(label="Adetailer sampler:", choices=adetailer_sampler_options, value="Use same sampler")
1019
+
1020
+ with gr.Accordion("Detailfix A", open=True, visible=True):
1021
+ # Adetailer A
1022
+ adetailer_active_a_gui = gr.Checkbox(label="Enable Adetailer A", value=False)
1023
+ prompt_ad_a_gui = gr.Textbox(label="Main prompt", placeholder="Main prompt will be use", lines=3)
1024
+ negative_prompt_ad_a_gui = gr.Textbox(label="Negative prompt", placeholder="Main negative prompt will be use", lines=3)
1025
+ with gr.Row():
1026
+ strength_ad_a_gui = gr.Number(label="Strength:", value=0.35, step=0.01, minimum=0.01, maximum=1.0)
1027
+ face_detector_ad_a_gui = gr.Checkbox(label="Face detector", value=True)
1028
+ person_detector_ad_a_gui = gr.Checkbox(label="Person detector", value=True)
1029
+ hand_detector_ad_a_gui = gr.Checkbox(label="Hand detector", value=False)
1030
+ with gr.Row():
1031
+ mask_dilation_a_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
1032
+ mask_blur_a_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
1033
+ mask_padding_a_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
1034
+
1035
+ with gr.Accordion("Detailfix B", open=True, visible=True):
1036
+ # Adetailer B
1037
+ adetailer_active_b_gui = gr.Checkbox(label="Enable Adetailer B", value=False)
1038
+ prompt_ad_b_gui = gr.Textbox(label="Main prompt", placeholder="Main prompt will be use", lines=3)
1039
+ negative_prompt_ad_b_gui = gr.Textbox(label="Negative prompt", placeholder="Main negative prompt will be use", lines=3)
1040
+ with gr.Row():
1041
+ strength_ad_b_gui = gr.Number(label="Strength:", value=0.35, step=0.01, minimum=0.01, maximum=1.0)
1042
+ face_detector_ad_b_gui = gr.Checkbox(label="Face detector", value=True)
1043
+ person_detector_ad_b_gui = gr.Checkbox(label="Person detector", value=True)
1044
+ hand_detector_ad_b_gui = gr.Checkbox(label="Hand detector", value=False)
1045
+ with gr.Row():
1046
+ mask_dilation_b_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
1047
+ mask_blur_b_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
1048
+ mask_padding_b_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
1049
+
1050
+ with gr.Accordion("Textual inversion", open=False, visible=True) as menu_ti:
1051
+ active_textual_inversion_gui = gr.Checkbox(value=False, label="Active Textual Inversion in prompt")
1052
+ use_textual_inversion_gui = gr.CheckboxGroup(choices=get_embed_list(get_model_pipeline(model_name_gui.value)) if active_textual_inversion_gui.value else [], value=None, label="Use Textual Invertion in prompt")
1053
+ def update_textual_inversion_gui(active_textual_inversion_gui, model_name_gui):
1054
+ return gr.update(choices=get_embed_list(get_model_pipeline(model_name_gui)) if active_textual_inversion_gui else [])
1055
+ active_textual_inversion_gui.change(update_textual_inversion_gui, [active_textual_inversion_gui, model_name_gui], [use_textual_inversion_gui])
1056
+ model_name_gui.change(update_textual_inversion_gui, [active_textual_inversion_gui, model_name_gui], [use_textual_inversion_gui])
1057
+
1058
+ with gr.Accordion("ControlNet / Img2img / Inpaint", open=False, visible=True) as menu_i2i:
1059
+ with gr.Row():
1060
+ image_control = gr.Image(label="Image ControlNet/Inpaint/Img2img", type="filepath")
1061
+ image_mask_gui = gr.Image(label="Image Mask", type="filepath")
1062
+ with gr.Row():
1063
+ strength_gui = gr.Slider(
1064
+ minimum=0.01, maximum=1.0, step=0.01, value=0.55, label="Strength",
1065
+ info="This option adjusts the level of changes for img2img and inpainting."
1066
+ )
1067
+ image_resolution_gui = gr.Slider(minimum=64, maximum=2048, step=64, value=1024, label="Image Resolution")
1068
+ preprocessor_name_gui = gr.Dropdown(label="Preprocessor Name", choices=preprocessor_controlnet["canny"], value=preprocessor_controlnet["canny"][0])
1069
+
1070
+ def change_preprocessor_choices(task):
1071
+ task = task_stablepy[task]
1072
+ if task in preprocessor_controlnet.keys():
1073
+ choices_task = preprocessor_controlnet[task]
1074
+ else:
1075
+ choices_task = preprocessor_controlnet["canny"]
1076
+ return gr.update(choices=choices_task, value=choices_task[0])
1077
+
1078
+ task_gui.change(
1079
+ change_preprocessor_choices,
1080
+ [task_gui],
1081
+ [preprocessor_name_gui],
1082
+ )
1083
+ with gr.Row():
1084
+ preprocess_resolution_gui = gr.Slider(minimum=64, maximum=2048, step=64, value=512, label="Preprocess Resolution")
1085
+ low_threshold_gui = gr.Slider(minimum=1, maximum=255, step=1, value=100, label="Canny low threshold")
1086
+ high_threshold_gui = gr.Slider(minimum=1, maximum=255, step=1, value=200, label="Canny high threshold")
1087
+ value_threshold_gui = gr.Slider(minimum=1, maximum=2.0, step=0.01, value=0.1, label="Hough value threshold (MLSD)")
1088
+ with gr.Row():
1089
+ distance_threshold_gui = gr.Slider(minimum=1, maximum=20.0, step=0.01, value=0.1, label="Hough distance threshold (MLSD)")
1090
+ control_net_output_scaling_gui = gr.Slider(minimum=0, maximum=5.0, step=0.1, value=1, label="ControlNet Output Scaling in UNet")
1091
+ control_net_start_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=0, label="ControlNet Start Threshold (%)")
1092
+ control_net_stop_threshold_gui = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label="ControlNet Stop Threshold (%)")
1093
+
1094
  with gr.Accordion("IP-Adapter", open=False, visible=True) as menu_ipa:##############
1095
 
1096
  IP_MODELS = sorted(list(set(IP_ADAPTERS_SD + IP_ADAPTERS_SDXL)))
1097
  MODE_IP_OPTIONS = ["original", "style", "layout", "style+layout"]
1098
 
1099
+ with gr.Accordion("IP-Adapter 1", open=True, visible=True):
1100
+ with gr.Row():
1101
+ image_ip1 = gr.Image(label="IP Image", type="filepath")
1102
+ mask_ip1 = gr.Image(label="IP Mask", type="filepath")
1103
+ with gr.Row():
1104
+ model_ip1 = gr.Dropdown(value="plus_face", label="Model", choices=IP_MODELS)
1105
+ mode_ip1 = gr.Dropdown(value="original", label="Mode", choices=MODE_IP_OPTIONS)
1106
  scale_ip1 = gr.Slider(minimum=0., maximum=2., step=0.01, value=0.7, label="Scale")
1107
+ with gr.Accordion("IP-Adapter 2", open=True, visible=True):
1108
+ with gr.Row():
1109
+ image_ip2 = gr.Image(label="IP Image", type="filepath")
1110
+ mask_ip2 = gr.Image(label="IP Mask (optional)", type="filepath")
1111
+ with gr.Row():
1112
+ model_ip2 = gr.Dropdown(value="base", label="Model", choices=IP_MODELS)
1113
+ mode_ip2 = gr.Dropdown(value="style", label="Mode", choices=MODE_IP_OPTIONS)
1114
  scale_ip2 = gr.Slider(minimum=0., maximum=2., step=0.01, value=0.7, label="Scale")
1115
 
1116
  with gr.Accordion("T2I adapter", open=False, visible=True) as menu_t2i:
1117
  t2i_adapter_preprocessor_gui = gr.Checkbox(value=True, label="T2i Adapter Preprocessor")
1118
+ with gr.Row():
1119
+ adapter_conditioning_scale_gui = gr.Slider(minimum=0, maximum=5., step=0.1, value=1, label="Adapter Conditioning Scale")
1120
+ adapter_conditioning_factor_gui = gr.Slider(minimum=0, maximum=1., step=0.01, value=0.55, label="Adapter Conditioning Factor (%)")
1121
 
1122
  with gr.Accordion("Styles", open=False, visible=True) as menu_styles:
1123
 
 
1147
 
1148
  style_button.click(load_json_style_file, [style_json_gui], [style_prompt_gui])
1149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1150
  with gr.Accordion("Other settings", open=False, visible=True) as menu_other:
1151
+ with gr.Row():
1152
+ image_previews_gui = gr.Checkbox(value=False, label="Image Previews")
1153
+ hires_before_adetailer_gui = gr.Checkbox(value=False, label="Hires Before Adetailer")
1154
+ hires_after_adetailer_gui = gr.Checkbox(value=True, label="Hires After Adetailer")
1155
+ generator_in_cpu_gui = gr.Checkbox(value=False, label="Generator in CPU")
1156
 
1157
  with gr.Accordion("More settings", open=False, visible=False):
1158
  loop_generation_gui = gr.Slider(minimum=1, value=1, label="Loop Generation")
 
1167
  retain_hires_model_previous_load_gui = gr.Checkbox(value=False, label="Retain Hires Model Previous Load")
1168
  xformers_memory_efficient_attention_gui = gr.Checkbox(value=False, label="Xformers Memory Efficient Attention")
1169
 
1170
+ with gr.Accordion("Examples and help", open=False, visible=True) as menu_example:
 
 
1171
  gr.Examples(
1172
  examples=[
1173
  [
 
1178
  7.5,
1179
  True,
1180
  -1,
 
 
 
 
 
 
 
 
 
 
1181
  "Euler a",
1182
  1152,
1183
  896,
1184
  "votepurchase/animagine-xl-3.1",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1185
  ],
1186
  [
1187
  "solo, princess Zelda OOT, score_9, score_8_up, score_8, medium breasts, cute, eyelashes, cute small face, long hair, crown braid, hairclip, pointy ears, soft curvy body, looking at viewer, smile, blush, white dress, medium body, (((holding the Master Sword))), standing, deep forest in the background",
 
1191
  5.,
1192
  True,
1193
  -1,
 
 
 
 
 
 
 
 
 
 
1194
  "Euler a",
1195
  1024,
1196
  1024,
1197
  "votepurchase/ponyDiffusionV6XL",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1198
  ],
1199
  [
1200
  "1girl, oomuro sakurako, yuru yuri, official art, school uniform, anime artwork, anime style, vibrant, studio anime, highly detailed, masterpiece, best quality, very aesthetic, absurdres",
 
1204
  7.0,
1205
  True,
1206
  -1,
 
 
 
 
 
 
 
 
 
 
1207
  "Euler a",
1208
  1024,
1209
  1024,
1210
  "Raelina/Rae-Diffusion-XL-V2",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1211
  ],
1212
  [
1213
  "1girl, akaza akari, yuru yuri, official art, anime artwork, anime style, vibrant, studio anime, highly detailed, masterpiece, best quality, very aesthetic, absurdres",
 
1217
  7.0,
1218
  True,
1219
  -1,
 
 
 
 
 
 
 
 
 
 
1220
  "Euler a",
1221
  1024,
1222
  1024,
1223
  "Raelina/Raemu-XL-V4",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1224
  ],
1225
  [
1226
  "yoshida yuuko, machikado mazoku, 1girl, solo, demon horns,horns, school uniform, long hair, open mouth, skirt, demon girl, ahoge, shiny, shiny hair, anime artwork",
 
1230
  7.,
1231
  True,
1232
  -1,
 
 
 
 
 
 
 
 
 
 
1233
  "Euler a",
1234
  1024,
1235
  1024,
1236
  "votepurchase/animagine-xl-3.1",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1237
  ],
1238
  ],
1239
  #fn=sd_gen.generate_pipeline,
 
1245
  cfg_gui,
1246
  clip_skip_gui,
1247
  seed_gui,
 
 
 
 
 
 
 
 
 
 
1248
  sampler_gui,
1249
  img_height_gui,
1250
  img_width_gui,
1251
  model_name_gui,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1252
  ],
1253
  #outputs=[result_images],
1254
  cache_examples=False,
1255
  elem_id="examples",
1256
+ )
1257
  ## END MOD
1258
 
1259
  with gr.Tab("Inpaint mask maker", render=True):
 
1532
  outputs=[result_images, actual_task_info],
1533
  queue=True,
1534
  show_progress="full",
1535
+ ).success(save_gallery_images, [result_images], [result_images, result_images_files, result_images_files], queue=False, show_api=False)
1536
 
1537
  with gr.Tab("Danbooru Tags Transformer with WD Tagger", render=True):
1538
  with gr.Column(scale=2):
modutils.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import json
2
  import gradio as gr
3
  from huggingface_hub import HfApi
 
1
+ import spaces
2
  import json
3
  import gradio as gr
4
  from huggingface_hub import HfApi
requirements.txt CHANGED
@@ -2,12 +2,10 @@ git+https://github.com/R3gm/stablepy.git@dev2
2
  torch==2.2.0
3
  gdown
4
  opencv-python
5
- pytorch-lightning
6
  torchvision
7
  accelerate
8
  transformers
9
  optimum[onnxruntime]
10
- spaces
11
  dartrs
12
  huggingface_hub
13
  httpx==0.13.3
 
2
  torch==2.2.0
3
  gdown
4
  opencv-python
 
5
  torchvision
6
  accelerate
7
  transformers
8
  optimum[onnxruntime]
 
9
  dartrs
10
  huggingface_hub
11
  httpx==0.13.3