magicfixeseverything commited on
Commit
9f61a5d
1 Parent(s): cbe0b7d

Upload spaghetti_ai_script.py

Browse files
Files changed (1) hide show
  1. spaghetti_ai_script.py +45 -2
spaghetti_ai_script.py CHANGED
@@ -997,7 +997,7 @@ if enable_longer_prompts == 1:
997
 
998
  ending_html += """
999
 
1000
- Longer prompts for Stable Diffusion 1.5 and PhotoReal are available using the method <a href=\"https://github.com/huggingface/diffusers/issues/2136#issuecomment-1514969011\" target=\"_blank\">here</a>. Another method will likely eventually be added for SDXL models."""
1001
 
1002
  ending_html += """
1003
 
@@ -1617,6 +1617,9 @@ stored_model_configuration_names_object = {}
1617
 
1618
  for this_base_model in base_model_array:
1619
 
 
 
 
1620
  default_base_model_choices_array.append(
1621
  base_model_names_object[this_base_model]
1622
  )
@@ -1871,6 +1874,8 @@ def model_configuration_valid(
1871
  base_model_name_value_str = str(base_model_name_value).lower()
1872
  model_configuration_name_value_str = str(model_configuration_name_value).lower()
1873
  for this_base_model in base_model_array:
 
 
1874
  for this_model_configuration in base_model_object_of_model_configuration_arrays[this_base_model]:
1875
  if (
1876
  (base_model_name_value_str == this_base_model) and
@@ -5919,6 +5924,9 @@ def get_query_params(
5919
 
5920
  for this_base_model in base_model_array:
5921
 
 
 
 
5922
  if base_model_name_value == this_base_model:
5923
 
5924
  model_configuration_name_value = base_model_model_configuration_defaults_object[this_base_model]
@@ -6381,6 +6389,9 @@ def set_base_model_and_model_configuration_from_query_params(
6381
 
6382
  model_configuration_name_default_value_for_this_base_model = base_model_model_configuration_defaults_object[this_base_model]
6383
 
 
 
 
6384
  for this_model_configuration in base_model_object_of_model_configuration_arrays[this_base_model]:
6385
 
6386
  if (
@@ -6772,8 +6783,36 @@ with gr.Blocks(
6772
  visible = default_allow_longer_prompts_row_visibility
6773
  ):
6774
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6775
  allow_longer_prompts_for_sd_1_5_based_models_field = gr.Checkbox(
6776
- label = "Allow longer prompts for Stable Diffusion 1.5 and PhotoReal models when not using the refiner or upscaler",
6777
  value = default_allow_longer_prompts_for_sd_1_5_based_models_is_selected,
6778
  interactive = True,
6779
  container = True,
@@ -6919,6 +6958,10 @@ with gr.Blocks(
6919
 
6920
  this_model_configuration_choices_array = []
6921
 
 
 
 
 
6922
  for this_model_configuration in base_model_object_of_model_configuration_arrays[this_base_model]:
6923
 
6924
  this_model_configuration_choices_array.append(
 
997
 
998
  ending_html += """
999
 
1000
+ Longer prompts are not available for most models. When available, it is done using the method <a href=\"https://github.com/huggingface/diffusers/issues/2136#issuecomment-1514969011\" target=\"_blank\">here</a>. Another method will likely eventually be added for SDXL models in this app."""
1001
 
1002
  ending_html += """
1003
 
 
1617
 
1618
  for this_base_model in base_model_array:
1619
 
1620
+ if this_base_model not in base_model_object_of_model_configuration_arrays:
1621
+ continue
1622
+
1623
  default_base_model_choices_array.append(
1624
  base_model_names_object[this_base_model]
1625
  )
 
1874
  base_model_name_value_str = str(base_model_name_value).lower()
1875
  model_configuration_name_value_str = str(model_configuration_name_value).lower()
1876
  for this_base_model in base_model_array:
1877
+ if this_base_model not in base_model_object_of_model_configuration_arrays:
1878
+ continue
1879
  for this_model_configuration in base_model_object_of_model_configuration_arrays[this_base_model]:
1880
  if (
1881
  (base_model_name_value_str == this_base_model) and
 
5924
 
5925
  for this_base_model in base_model_array:
5926
 
5927
+ if this_base_model not in base_model_object_of_model_configuration_arrays:
5928
+ continue
5929
+
5930
  if base_model_name_value == this_base_model:
5931
 
5932
  model_configuration_name_value = base_model_model_configuration_defaults_object[this_base_model]
 
6389
 
6390
  model_configuration_name_default_value_for_this_base_model = base_model_model_configuration_defaults_object[this_base_model]
6391
 
6392
+ if this_base_model not in base_model_object_of_model_configuration_arrays:
6393
+ continue
6394
+
6395
  for this_model_configuration in base_model_object_of_model_configuration_arrays[this_base_model]:
6396
 
6397
  if (
 
6783
  visible = default_allow_longer_prompts_row_visibility
6784
  ):
6785
 
6786
+ model_types_for_longer_prompts_html = ""
6787
+
6788
+ sd15_available = 0
6789
+ photoreal_available = 0
6790
+
6791
+ if "sd_1_5_runwayml" in base_model_object_of_model_configuration_arrays:
6792
+
6793
+ sd15_available = 1
6794
+
6795
+ model_types_for_longer_prompts_html += base_model_names_object["sd_1_5_runwayml"]
6796
+
6797
+ if "photoreal" in base_model_object_of_model_configuration_arrays:
6798
+
6799
+ photoreal_available = 1
6800
+
6801
+ if sd15_available == 1:
6802
+
6803
+ model_types_for_longer_prompts_html += " and "
6804
+
6805
+ model_types_for_longer_prompts_html += base_model_names_object["photoreal"]
6806
+
6807
+ if (
6808
+ (sd15_available == 1) and
6809
+ (photoreal_available == 1)
6810
+ ):
6811
+
6812
+ model_types_for_longer_prompts_html += " models"
6813
+
6814
  allow_longer_prompts_for_sd_1_5_based_models_field = gr.Checkbox(
6815
+ label = "Allow longer prompts for " + model_types_for_longer_prompts_html + " models when not using the refiner or upscaler",
6816
  value = default_allow_longer_prompts_for_sd_1_5_based_models_is_selected,
6817
  interactive = True,
6818
  container = True,
 
6958
 
6959
  this_model_configuration_choices_array = []
6960
 
6961
+ if this_base_model not in base_model_object_of_model_configuration_arrays:
6962
+
6963
+ continue
6964
+
6965
  for this_model_configuration in base_model_object_of_model_configuration_arrays[this_base_model]:
6966
 
6967
  this_model_configuration_choices_array.append(