magicfixeseverything
commited on
Commit
·
2baf14d
1
Parent(s):
bd13715
Upload spaghetti_ai_script.py
Browse files- spaghetti_ai_script.py +856 -265
spaghetti_ai_script.py
CHANGED
@@ -8,6 +8,7 @@ import random
|
|
8 |
import torchsde
|
9 |
from math import floor, copysign
|
10 |
import time
|
|
|
11 |
|
12 |
##########
|
13 |
|
@@ -335,6 +336,14 @@ suppress_hugging_face_hub_offline_status = 0
|
|
335 |
|
336 |
####################
|
337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
#
|
339 |
# Add Seed Into Pipe
|
340 |
#
|
@@ -402,7 +411,6 @@ allow_other_model_versions = 1
|
|
402 |
# Image Preview
|
403 |
#
|
404 |
|
405 |
-
enable_image_preview = 1
|
406 |
use_image_preview = 1
|
407 |
image_preview_step_interval = 10
|
408 |
image_preview_seconds_interval = 60
|
@@ -921,7 +929,7 @@ if device == "cpu":
|
|
921 |
|
922 |
if script_being_run_on_hugging_face == 1:
|
923 |
|
924 |
-
opening_html = "<span style=\"font-weight: bold; color: #c00;\">This app is extremely slow
|
925 |
|
926 |
else:
|
927 |
|
@@ -931,7 +939,7 @@ if device == "cpu":
|
|
931 |
|
932 |
|
933 |
|
934 |
-
ending_html += """<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAABkCAMAAADADYxgAAABelBMVEVzQShrNiBOLB2FSSlaNSPm4uCVZ0RhQjVCJhtcKBc3HhN2TkN8WE2DYVtwRjl8TjOHWjtHGRA4DQivgltQHxLz6OD68+onGRYvWZGlWibswHv78dxOOzKSVDLwzY+idlNrU0ytZDCaUiPZrkrYnFe6jmLhpVvVro7Cl2zWomq4bjIOX7T158vAg1HAdzfR1dzntm6sdk4fc8jWk0rHgUC80OMda7vFoHXkrWWBrtvxyITSqHbOikW2dULcsHydXzSIUDvLj1OjbEP01Zvdq3BGCAqWdnKVamWRWUXJlF/w3ruVc1pGRk2sw9rcvZzeuYydhoAyKSjLo4KKbWjMoUCubjxaT1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dHAK2GpYsRj1e/zWlUic0Tor9lYnf1HRej9k494YEW9bSLcW0FxZCdqsbJeiYL3y3T5iKCiSl+nKhUDFSJMUldLpdVVg0tNUKTfN4pIZesrLxQys/br5KQznJkVtYnIHWsTKxWdVlcbjXsGt5RJF/EFNSq7rRa2FMyf+3EO1/5ZLTs+/A1R8ZxzG596+8Y6UDYFdQg1EBPoIaFjFiXD02r8XE3REzVfryutkqcRyypcbipMzgfcpmu4fKp0/BP/e3STtfOqxDY4eah5TasaMl49Th8x4pSxUY+pp8DGM7RSTRQ9vljNkKqMKqlVVJlOC3s6Rfp5la8fauf4eDjH6/8/NYPOylrR4ORvQ0ClnDGR58ut8a85qPEe6Bz8AHqBqmtv3n1rBIa0FaxKQ03moBIxydXl8Y8ZqNhMncN9yQVqJv0J+dZYFRQt4FLPqFO4TKVyneimeIcH5zugY3hq75BPgyKriKFIvcQq31xEJvCH5ZvoKuU37dMhLdfsj3Mq3sb302+Qd0qJil+AkiqNFTVxvVctbACwsgXiQXB4Xq0Fg/RbYjWNVWxTlIokKo+xifsc9+raRD0U9YT6gJInaikIzPRbSkqDh+2qYvWKqOpMrWjAmD6PXGrrz7Vm82TM3aUtlqi+aQ7SD4E+TE9U7bQKVNRpAwiF2oEhuUnu96mKaeR7+kOKLmVVtbOqEXegyD+z2AFDRvHjODY7RydUtqi/WUXOqAapmqjnS5W2NsWkvdU57pw0+fY6OjqaQ68RvIBqWbEK7SLVmPaV9xUuESx9UCBOMvmDv2JFnMdVezSBAAAAAElFTkSuQmCC" alt="Spaghetti AI Logo" title="Spaghetti AI Logo" style="float: left; padding:
|
935 |
|
936 |
Tokens are not individual characters. If the prompt length is too long, the display will notify you what part of the prompt wasn't used. Changing just the image dimensions alone will change the image generated. For some models, trying to make a large image, such as 1024x1024, may add extra people and come out worse than using smaller dimensions.
|
937 |
|
@@ -962,12 +970,38 @@ gradio_image_gallery_component_height = 350
|
|
962 |
|
963 |
|
964 |
|
965 |
-
canceled_image_in_queue_message = "Due to how the queue works in this app, you need to reload the page after canceling an image. Otherwise, you will not be able to generate another image until you reach the position in the queue you were in originally. At that time, the button to generate an image will appear again."
|
966 |
|
967 |
canceled_image_in_process_of_being_generated = "<div style=\"text-align: center;\">Image generation will be canceled once the current step completes.</div>"
|
968 |
|
969 |
|
970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
###############################################################################
|
972 |
###############################################################################
|
973 |
#
|
@@ -1203,6 +1237,10 @@ if auto_save_imagery == 1:
|
|
1203 |
|
1204 |
additional_prompt_info_html = " The image, and a text file with generation information, will be saved automatically."
|
1205 |
|
|
|
|
|
|
|
|
|
1206 |
|
1207 |
|
1208 |
if use_xformers == 1:
|
@@ -1389,6 +1427,14 @@ if default_base_model in base_models_not_supporting_denoising_end_for_base_model
|
|
1389 |
|
1390 |
|
1391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1392 |
default_add_seed_into_pipe_is_selected = False
|
1393 |
|
1394 |
if default_add_seed_into_pipe == 1:
|
@@ -1447,12 +1493,6 @@ for this_scheduler in schedulers_array:
|
|
1447 |
|
1448 |
|
1449 |
|
1450 |
-
if enable_image_preview != 1:
|
1451 |
-
|
1452 |
-
use_image_preview = 0
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
make_seed_selection_a_textbox = 1
|
1457 |
|
1458 |
if maximum_seed <= 9007199254740992:
|
@@ -2014,6 +2054,49 @@ def upscaling_steps_valid(
|
|
2014 |
|
2015 |
|
2016 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017 |
#####################
|
2018 |
#
|
2019 |
# Numerical Bool
|
@@ -2619,6 +2702,7 @@ def create_image_generation_information (
|
|
2619 |
image_height,
|
2620 |
actual_seed,
|
2621 |
add_seed_into_pipe,
|
|
|
2622 |
guidance_scale,
|
2623 |
base_model_steps,
|
2624 |
display_xformers_usage_in_prompt_info,
|
@@ -2630,6 +2714,7 @@ def create_image_generation_information (
|
|
2630 |
denoising_end_applicable,
|
2631 |
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
2632 |
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
|
|
2633 |
refining_steps_for_older_configuration_field_value,
|
2634 |
use_upscaler,
|
2635 |
upscaler_error,
|
@@ -2712,6 +2797,15 @@ def create_image_generation_information (
|
|
2712 |
"Seed added to generation? " + nice_seed_added_to_generation
|
2713 |
])
|
2714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2715 |
if int(guidance_scale) > 0:
|
2716 |
|
2717 |
info_about_prompt_lines_array.extend([
|
@@ -2789,6 +2883,12 @@ def create_image_generation_information (
|
|
2789 |
"Refiner denoise start %: " + nice_refiner_denoise_start
|
2790 |
])
|
2791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2792 |
if current_actual_total_refiner_steps > 0:
|
2793 |
|
2794 |
info_about_prompt_lines_array.extend([
|
@@ -2922,7 +3022,7 @@ def load_image_preview (
|
|
2922 |
|
2923 |
user_id_state_value = user_id_state.value
|
2924 |
|
2925 |
-
|
2926 |
|
2927 |
if (
|
2928 |
(user_id_state_value > 0) and
|
@@ -3357,13 +3457,10 @@ def create_preview_image (
|
|
3357 |
#####################
|
3358 |
|
3359 |
def create_image_function (
|
3360 |
-
|
3361 |
base_model_field_index,
|
3362 |
prompt_text,
|
3363 |
negative_prompt_text,
|
3364 |
-
|
3365 |
scheduler_index,
|
3366 |
-
|
3367 |
image_width,
|
3368 |
image_height,
|
3369 |
guidance_scale,
|
@@ -3371,39 +3468,29 @@ def create_image_function (
|
|
3371 |
base_model_steps_field_for_sdxl_turbo,
|
3372 |
actual_seed,
|
3373 |
add_seed_into_pipe,
|
3374 |
-
|
3375 |
-
|
3376 |
refining_selection_field_value,
|
3377 |
refining_denoise_start_field_value,
|
3378 |
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
3379 |
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
|
|
3380 |
refining_steps_for_older_configuration_field_value,
|
3381 |
-
|
3382 |
upscaling_selection_field_value,
|
3383 |
upscaling_steps,
|
3384 |
-
|
3385 |
image_gallery_array_state_value,
|
3386 |
prompt_information_array_state_value,
|
3387 |
-
|
3388 |
last_model_configuration_name_selected_state_value,
|
3389 |
last_refiner_name_selected_state_value,
|
3390 |
last_upscaler_name_selected_state_value,
|
3391 |
-
|
3392 |
stored_pipe_state,
|
3393 |
stored_refiner_state,
|
3394 |
stored_upscaler_state,
|
3395 |
-
|
3396 |
save_base_image_when_using_refiner_field_value,
|
3397 |
save_refined_image_when_using_upscaler_field_value,
|
3398 |
-
|
3399 |
user_id_state,
|
3400 |
image_generation_id_state,
|
3401 |
-
canceled_images_array_state,
|
3402 |
-
|
3403 |
*model_configuration_dropdown_fields_array,
|
3404 |
-
|
3405 |
progress = gr.Progress()
|
3406 |
-
|
3407 |
):
|
3408 |
|
3409 |
image_generation_id_state_value = image_generation_id_state.value
|
@@ -3533,7 +3620,7 @@ def create_image_function (
|
|
3533 |
|
3534 |
|
3535 |
add_seed_into_pipe = numerical_bool(add_seed_into_pipe)
|
3536 |
-
|
3537 |
|
3538 |
|
3539 |
|
@@ -3546,6 +3633,10 @@ def create_image_function (
|
|
3546 |
|
3547 |
|
3548 |
|
|
|
|
|
|
|
|
|
3549 |
use_upscaler = numerical_bool(upscaling_selection_field_value)
|
3550 |
|
3551 |
|
@@ -3561,11 +3652,14 @@ def create_image_function (
|
|
3561 |
if not refiner_denoise_start_valid(refining_denoise_start_field_value):
|
3562 |
error_function("Refiner denoise start is not valid.")
|
3563 |
|
3564 |
-
|
3565 |
|
3566 |
# For older configrations. Doesn't reflect actual number of steps.
|
3567 |
|
3568 |
-
|
|
|
|
|
|
|
3569 |
|
3570 |
|
3571 |
|
@@ -3736,7 +3830,7 @@ def create_image_function (
|
|
3736 |
|
3737 |
else:
|
3738 |
|
3739 |
-
if
|
3740 |
|
3741 |
torch.manual_seed(actual_seed)
|
3742 |
|
@@ -3775,7 +3869,7 @@ def create_image_function (
|
|
3775 |
|
3776 |
output_type_in_base_model_to_use = "latent"
|
3777 |
|
3778 |
-
current_estimated_total_refiner_steps = rounded_number(
|
3779 |
|
3780 |
if current_estimated_total_refiner_steps < 1:
|
3781 |
|
@@ -3794,6 +3888,8 @@ def create_image_function (
|
|
3794 |
|
3795 |
|
3796 |
current_base_model_generation_start_time = 0
|
|
|
|
|
3797 |
|
3798 |
global saved_final_base_model_pil_image_if_using_refiner
|
3799 |
saved_final_base_model_pil_image_if_using_refiner = None
|
@@ -3802,7 +3898,6 @@ def create_image_function (
|
|
3802 |
global upscaled_image_canceled_latents
|
3803 |
|
3804 |
upscaled_image_canceled = 0
|
3805 |
-
# upscaled_image_canceled_latents = None
|
3806 |
|
3807 |
|
3808 |
|
@@ -3827,9 +3922,10 @@ def create_image_function (
|
|
3827 |
|
3828 |
seconds_per_step = 0
|
3829 |
|
3830 |
-
if callback_step_number
|
|
|
3831 |
|
3832 |
-
seconds_per_step = ((time.time() - current_base_model_generation_start_time) /
|
3833 |
|
3834 |
nice_time_per_step = nice_elapsed_time(seconds_per_step)
|
3835 |
|
@@ -3928,6 +4024,8 @@ def create_image_function (
|
|
3928 |
):
|
3929 |
|
3930 |
current_refiner_generation_start_time = 0
|
|
|
|
|
3931 |
|
3932 |
def callback_function_for_refiner_progress(
|
3933 |
callback_pipe,
|
@@ -3950,9 +4048,10 @@ def create_image_function (
|
|
3950 |
|
3951 |
seconds_per_step = 0
|
3952 |
|
3953 |
-
if callback_step_number
|
|
|
3954 |
|
3955 |
-
seconds_per_step = ((time.time() - current_refiner_generation_start_time) /
|
3956 |
|
3957 |
nice_time_per_step = nice_elapsed_time(seconds_per_step)
|
3958 |
|
@@ -4011,6 +4110,8 @@ def create_image_function (
|
|
4011 |
|
4012 |
|
4013 |
current_upscaler_generation_start_time = 0
|
|
|
|
|
4014 |
|
4015 |
def callback_function_for_upscaler_progress(
|
4016 |
callback_step_index,
|
@@ -4032,9 +4133,10 @@ def create_image_function (
|
|
4032 |
|
4033 |
seconds_per_step = 0
|
4034 |
|
4035 |
-
if callback_step_number
|
|
|
4036 |
|
4037 |
-
seconds_per_step = ((time.time() - current_upscaler_generation_start_time) /
|
4038 |
|
4039 |
nice_time_per_step = nice_elapsed_time(seconds_per_step)
|
4040 |
|
@@ -4494,6 +4596,7 @@ def create_image_function (
|
|
4494 |
image_height,
|
4495 |
actual_seed,
|
4496 |
add_seed_into_pipe,
|
|
|
4497 |
guidance_scale,
|
4498 |
base_model_steps,
|
4499 |
display_xformers_usage_in_prompt_info,
|
@@ -4505,6 +4608,7 @@ def create_image_function (
|
|
4505 |
denoising_end_applicable,
|
4506 |
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
4507 |
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
|
|
4508 |
refining_steps_for_older_configuration_field_value,
|
4509 |
use_upscaler,
|
4510 |
upscaler_error,
|
@@ -4911,7 +5015,7 @@ def download_data_from_huggingface(
|
|
4911 |
model_configuration_name_value
|
4912 |
)
|
4913 |
|
4914 |
-
data_links_downloaded_object[
|
4915 |
|
4916 |
print ("Downloading/loading refiner data...")
|
4917 |
|
@@ -4935,207 +5039,516 @@ def download_data_from_huggingface(
|
|
4935 |
|
4936 |
#####################
|
4937 |
#
|
4938 |
-
#
|
4939 |
#
|
4940 |
-
#
|
4941 |
-
# reflect them.
|
4942 |
#
|
4943 |
#####################
|
4944 |
|
4945 |
-
def
|
4946 |
-
|
4947 |
-
|
4948 |
-
|
4949 |
-
raw_url_params = str(request.query_params)
|
4950 |
-
|
4951 |
-
import urllib.parse
|
4952 |
-
|
4953 |
-
unprocessed_url_object = urllib.parse.parse_qs(raw_url_params)
|
4954 |
-
|
4955 |
-
url_object = {}
|
4956 |
-
|
4957 |
-
for url_param_key in unprocessed_url_object:
|
4958 |
-
|
4959 |
-
url_param_value = unprocessed_url_object[url_param_key][0]
|
4960 |
-
|
4961 |
-
if len(url_param_value) > 0:
|
4962 |
-
|
4963 |
-
url_param_key = str(url_param_key)
|
4964 |
-
|
4965 |
-
url_param_key_lowercase = url_param_key.lower()
|
4966 |
-
|
4967 |
-
url_object[url_param_key_lowercase] = str(unprocessed_url_object[url_param_key][0]).lower()
|
4968 |
-
|
4969 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4970 |
|
4971 |
-
|
4972 |
|
4973 |
|
4974 |
|
4975 |
-
|
4976 |
|
4977 |
-
|
4978 |
|
4979 |
-
|
4980 |
|
|
|
4981 |
|
|
|
4982 |
|
4983 |
-
|
4984 |
|
4985 |
-
|
|
|
4986 |
|
4987 |
-
if base_model_field_key_in_url in url_object:
|
4988 |
|
4989 |
-
base_model_field_in_url = url_object[base_model_field_key_in_url].lower()
|
4990 |
|
4991 |
-
|
4992 |
|
4993 |
-
base_model_name_value = base_model_field_in_url
|
4994 |
|
4995 |
-
base_model_nicely_named_value = base_model_names_object[base_model_name_value]
|
4996 |
|
4997 |
-
|
|
|
4998 |
|
4999 |
|
5000 |
|
5001 |
-
|
5002 |
|
5003 |
-
if download_data_key_in_url in url_object:
|
5004 |
|
5005 |
-
download_data_option_in_url = str(url_object[download_data_key_in_url])
|
5006 |
|
5007 |
-
|
5008 |
-
|
5009 |
-
(download_data_option_in_url == "2")
|
5010 |
-
):
|
5011 |
|
5012 |
-
download_data_from_huggingface(download_data_option_in_url)
|
5013 |
|
5014 |
|
|
|
|
|
5015 |
|
5016 |
-
model_configuration_key_in_url = "model_config"
|
5017 |
|
5018 |
-
model_configuration_in_url = ""
|
5019 |
|
5020 |
-
if
|
|
|
5021 |
|
5022 |
-
model_configuration_in_url = url_object[model_configuration_key_in_url].lower()
|
5023 |
|
5024 |
-
for this_base_model in base_model_array:
|
5025 |
|
5026 |
-
|
|
|
5027 |
|
5028 |
-
model_configuration_name_value = base_model_model_configuration_defaults_object[this_base_model]
|
5029 |
|
5030 |
-
if len(model_configuration_in_url) > 0:
|
5031 |
|
5032 |
-
|
|
|
5033 |
|
5034 |
-
if model_configuration_valid(base_model_name_value, model_configuration_in_url):
|
5035 |
|
5036 |
-
model_configuration_name_value = this_model_configuration
|
5037 |
|
5038 |
-
|
|
|
5039 |
|
5040 |
|
5041 |
|
5042 |
-
|
|
|
5043 |
|
5044 |
-
if prompt_field_key_in_url in url_object:
|
5045 |
|
5046 |
-
prompt_field_in_url = url_object[prompt_field_key_in_url].lower()
|
5047 |
|
5048 |
-
|
|
|
5049 |
|
5050 |
-
field_object.update({prompt_field: prompt_field_in_url})
|
5051 |
|
5052 |
|
|
|
|
|
|
|
5053 |
|
5054 |
-
|
5055 |
|
5056 |
-
if negative_prompt_field_key_in_url in url_object:
|
5057 |
|
5058 |
-
negative_prompt_field_in_url = url_object[negative_prompt_field_key_in_url].lower()
|
5059 |
|
5060 |
-
|
|
|
|
|
|
|
5061 |
|
5062 |
-
|
5063 |
|
5064 |
|
5065 |
|
5066 |
-
|
|
|
|
|
5067 |
|
5068 |
-
|
5069 |
|
5070 |
-
scheduler_field_in_url = url_object[scheduler_field_key_in_url].lower()
|
5071 |
|
5072 |
-
if scheduler_valid(scheduler_field_in_url):
|
5073 |
|
5074 |
-
|
|
|
5075 |
|
5076 |
-
scheduler_nicely_named_value = scheduler_long_names_object[scheduler_name_value]
|
5077 |
|
5078 |
-
field_object.update({scheduler_field: scheduler_nicely_named_value})
|
5079 |
|
|
|
|
|
5080 |
|
|
|
|
|
5081 |
|
5082 |
-
image_width_field_key_in_url = "width"
|
5083 |
|
5084 |
-
if image_width_field_key_in_url in url_object:
|
5085 |
|
5086 |
-
|
|
|
|
|
5087 |
|
5088 |
-
|
5089 |
|
5090 |
-
field_object.update({image_width_field: image_width_field_in_url})
|
5091 |
|
5092 |
|
|
|
|
|
|
|
5093 |
|
5094 |
-
|
5095 |
|
5096 |
-
if image_height_field_key_in_url in url_object:
|
5097 |
|
5098 |
-
image_height_field_in_url = str(url_object[image_height_field_key_in_url])
|
5099 |
|
5100 |
-
|
|
|
|
|
5101 |
|
5102 |
-
|
5103 |
|
5104 |
|
5105 |
|
5106 |
-
|
|
|
5107 |
|
5108 |
-
if guidance_scale_field_key_in_url in url_object:
|
5109 |
|
5110 |
-
guidance_scale_field_in_url = str(url_object[guidance_scale_field_key_in_url])
|
5111 |
|
5112 |
-
|
|
|
|
|
5113 |
|
5114 |
-
field_object.update({guidance_scale_field: guidance_scale_field_in_url})
|
5115 |
|
5116 |
|
|
|
|
|
|
|
5117 |
|
5118 |
-
steps_key_in_url = "steps"
|
5119 |
|
5120 |
-
if steps_key_in_url in url_object:
|
5121 |
|
5122 |
-
|
5123 |
|
5124 |
-
|
5125 |
|
5126 |
-
|
5127 |
|
5128 |
-
|
5129 |
|
5130 |
-
else:
|
5131 |
|
5132 |
-
field_object.update({base_model_steps_field: steps_in_url})
|
5133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5134 |
|
|
|
|
|
|
|
5135 |
|
5136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5137 |
|
5138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
5149 |
-
|
5150 |
add_seed_to_generation = None
|
5151 |
|
5152 |
if add_seed_key_in_url in url_object:
|
@@ -5168,8 +5579,6 @@ def get_query_params(
|
|
5168 |
|
5169 |
|
5170 |
|
5171 |
-
use_torch_manual_seed_but_not_in_generator_key_in_url = "use_torch_manual_seed_but_not_in_generator"
|
5172 |
-
|
5173 |
if use_torch_manual_seed_but_not_in_generator_key_in_url in url_object:
|
5174 |
|
5175 |
use_torch_manual_seed_but_not_in_generator_in_url = url_object[use_torch_manual_seed_but_not_in_generator_key_in_url].lower()
|
@@ -5196,8 +5605,6 @@ def get_query_params(
|
|
5196 |
|
5197 |
|
5198 |
|
5199 |
-
refiner_key_in_url = "refiner"
|
5200 |
-
|
5201 |
if refiner_key_in_url in url_object:
|
5202 |
|
5203 |
refiner_in_url = url_object[refiner_key_in_url].lower()
|
@@ -5217,8 +5624,6 @@ def get_query_params(
|
|
5217 |
|
5218 |
|
5219 |
|
5220 |
-
refiner_denoise_start_key_in_url = "denoise_start"
|
5221 |
-
|
5222 |
if refiner_denoise_start_key_in_url in url_object:
|
5223 |
|
5224 |
refiner_denoise_start_in_url = str(url_object[refiner_denoise_start_key_in_url])
|
@@ -5229,7 +5634,24 @@ def get_query_params(
|
|
5229 |
|
5230 |
|
5231 |
|
5232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5233 |
|
5234 |
if refining_steps_key_in_url in url_object:
|
5235 |
|
@@ -5241,8 +5663,6 @@ def get_query_params(
|
|
5241 |
|
5242 |
|
5243 |
|
5244 |
-
use_denoising_start_in_base_model_when_using_refiner_key_in_url = "use_denoise_end"
|
5245 |
-
|
5246 |
if use_denoising_start_in_base_model_when_using_refiner_key_in_url in url_object:
|
5247 |
|
5248 |
use_denoising_start_in_base_model_when_using_refiner_in_url = url_object[use_denoising_start_in_base_model_when_using_refiner_key_in_url].lower()
|
@@ -5262,8 +5682,6 @@ def get_query_params(
|
|
5262 |
|
5263 |
|
5264 |
|
5265 |
-
base_model_output_to_refiner_is_in_latent_space_key_in_url = "latent_space_before_refiner"
|
5266 |
-
|
5267 |
if base_model_output_to_refiner_is_in_latent_space_key_in_url in url_object:
|
5268 |
|
5269 |
base_model_output_to_refiner_is_in_latent_space_in_url = url_object[base_model_output_to_refiner_is_in_latent_space_key_in_url].lower()
|
@@ -5283,8 +5701,6 @@ def get_query_params(
|
|
5283 |
|
5284 |
|
5285 |
|
5286 |
-
upscaler_key_in_url = "upscaler"
|
5287 |
-
|
5288 |
if upscaler_key_in_url in url_object:
|
5289 |
|
5290 |
upscaler_in_url = url_object[upscaler_key_in_url].lower()
|
@@ -5304,8 +5720,6 @@ def get_query_params(
|
|
5304 |
|
5305 |
|
5306 |
|
5307 |
-
upscaling_steps_key_in_url = "upscaler_steps"
|
5308 |
-
|
5309 |
if upscaling_steps_key_in_url in url_object:
|
5310 |
|
5311 |
upscaling_steps_in_url = str(url_object[upscaling_steps_key_in_url])
|
@@ -5316,6 +5730,32 @@ def get_query_params(
|
|
5316 |
|
5317 |
|
5318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5319 |
generate_image_button_update = gr.Button(
|
5320 |
interactive = True
|
5321 |
)
|
@@ -5418,12 +5858,12 @@ css_to_use = """
|
|
5418 |
.generating {border: none !important;}
|
5419 |
|
5420 |
/* Hide footer */
|
5421 |
-
|
5422 |
footer
|
5423 |
{
|
5424 |
display: none !important;
|
5425 |
}
|
5426 |
-
|
5427 |
/* Dropdowns */
|
5428 |
|
5429 |
.sp_dropdown ul
|
@@ -5473,12 +5913,13 @@ footer
|
|
5473 |
width: 100%;
|
5474 |
height: 60px;
|
5475 |
max-height: 80%;
|
5476 |
-
border: 1px solid rgb(
|
5477 |
}
|
5478 |
|
5479 |
.textbox_vertical_scroll textarea::-webkit-scrollbar-thumb:hover
|
5480 |
{
|
5481 |
background-color: rgb(184, 184, 184);
|
|
|
5482 |
}
|
5483 |
|
5484 |
.image_scaling button.image-button img
|
@@ -5486,6 +5927,27 @@ footer
|
|
5486 |
object-fit: scale-down;
|
5487 |
}
|
5488 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5489 |
/* Size of image for image preview */
|
5490 |
|
5491 |
#image_preview_id div.image-container
|
@@ -5503,6 +5965,28 @@ footer
|
|
5503 |
margin: 0 auto;
|
5504 |
}
|
5505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5506 |
"""
|
5507 |
|
5508 |
with gr.Blocks(
|
@@ -5533,7 +6017,11 @@ with gr.Blocks(
|
|
5533 |
|
5534 |
user_id_state = gr.State(0)
|
5535 |
image_generation_id_state = gr.State("")
|
5536 |
-
|
|
|
|
|
|
|
|
|
5537 |
|
5538 |
gr.Markdown(opening_html)
|
5539 |
|
@@ -5601,7 +6089,8 @@ with gr.Blocks(
|
|
5601 |
):
|
5602 |
|
5603 |
negative_prompt_for_sdxl_turbo_field = gr.HTML(
|
5604 |
-
value = "<div style=\"padding: 10px; text-align: center
|
|
|
5605 |
)
|
5606 |
|
5607 |
with gr.Group(
|
@@ -5660,43 +6149,6 @@ with gr.Blocks(
|
|
5660 |
|
5661 |
|
5662 |
|
5663 |
-
|
5664 |
-
|
5665 |
-
|
5666 |
-
|
5667 |
-
|
5668 |
-
|
5669 |
-
# Might add this again eventually (not needed, but to match older configuration)
|
5670 |
-
|
5671 |
-
model_configuration_include_refiner_number_of_steps_object = {}
|
5672 |
-
|
5673 |
-
refining_steps_for_older_configuration_field_visible = False
|
5674 |
-
|
5675 |
-
if default_model_configuration in model_configuration_include_refiner_number_of_steps_object:
|
5676 |
-
|
5677 |
-
refining_steps_for_older_configuration_field_visible = True
|
5678 |
-
|
5679 |
-
with gr.Row(
|
5680 |
-
elem_id = "refining_steps_for_older_configuration_field_row_id",
|
5681 |
-
visible = refining_steps_for_older_configuration_field_visible
|
5682 |
-
):
|
5683 |
-
|
5684 |
-
refining_steps_for_older_configuration_field = gr.Slider(
|
5685 |
-
label = "Refining steps:",
|
5686 |
-
minimum = 1,
|
5687 |
-
maximum = maximum_refining_steps_for_online_config_field,
|
5688 |
-
value = default_refining_steps_for_online_config_field,
|
5689 |
-
step = 1
|
5690 |
-
)
|
5691 |
-
|
5692 |
-
|
5693 |
-
|
5694 |
-
|
5695 |
-
|
5696 |
-
|
5697 |
-
|
5698 |
-
|
5699 |
-
|
5700 |
with gr.Group(
|
5701 |
visible = upscaler_group_visible
|
5702 |
):
|
@@ -5890,7 +6342,8 @@ with gr.Blocks(
|
|
5890 |
):
|
5891 |
|
5892 |
guidance_scale_for_sdxl_turbo_field = gr.HTML(
|
5893 |
-
value = "<div style=\"padding: 10px; text-align: center
|
|
|
5894 |
)
|
5895 |
|
5896 |
with gr.Row():
|
@@ -5987,7 +6440,7 @@ with gr.Blocks(
|
|
5987 |
|
5988 |
output_image_preview_field_every_value = None
|
5989 |
|
5990 |
-
if
|
5991 |
|
5992 |
output_image_preview_field_every_value = load_image_preview_frequency_in_seconds
|
5993 |
|
@@ -6087,6 +6540,16 @@ with gr.Blocks(
|
|
6087 |
open = True
|
6088 |
):
|
6089 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6090 |
with gr.Row():
|
6091 |
|
6092 |
add_seed_into_pipe_field = gr.Checkbox(
|
@@ -6100,7 +6563,7 @@ with gr.Blocks(
|
|
6100 |
with gr.Row():
|
6101 |
|
6102 |
use_torch_manual_seed_but_do_not_add_to_pipe_field = gr.Checkbox(
|
6103 |
-
label = "Use torch.manual_seed, but don't
|
6104 |
value = default_use_torch_manual_seed_but_do_not_add_to_pipe_is_selected,
|
6105 |
interactive = True,
|
6106 |
container = False,
|
@@ -6135,6 +6598,36 @@ with gr.Blocks(
|
|
6135 |
elem_classes = "sp_checkbox"
|
6136 |
)
|
6137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6138 |
|
6139 |
|
6140 |
if len(ending_html) > 0:
|
@@ -6227,9 +6720,8 @@ async (
|
|
6227 |
var baseModelNamesObject = {0};
|
6228 |
var modelConfigurationNamesObject = {1};
|
6229 |
var baseModelArray = {2};
|
6230 |
-
var
|
6231 |
-
var
|
6232 |
-
var allowOtherModelVersions = {5};
|
6233 |
|
6234 |
var baseModelFullNamesToBaseModelIdConversion = {{}};
|
6235 |
Object.keys(baseModelNamesObject).forEach(key => {{
|
@@ -6326,32 +6818,6 @@ async (
|
|
6326 |
document.getElementById("guidance_scale_field_row_id").style.display = guidanceScaleFieldDisplay;
|
6327 |
document.getElementById("guidance_scale_for_sdxl_turbo_field_row_id").style.display = guidanceScaleForSdxlTurboFieldDisplay;
|
6328 |
|
6329 |
-
|
6330 |
-
|
6331 |
-
|
6332 |
-
|
6333 |
-
|
6334 |
-
|
6335 |
-
|
6336 |
-
|
6337 |
-
|
6338 |
-
|
6339 |
-
|
6340 |
-
|
6341 |
-
|
6342 |
-
|
6343 |
-
|
6344 |
-
|
6345 |
-
|
6346 |
-
|
6347 |
-
var refiningStepsForOlderConfiguration = "none";
|
6348 |
-
|
6349 |
-
if (Object.keys(modelConfigurationIncludeRefinerNumberOfStepsObject).includes(modelConfigurationNameValue)) {{
|
6350 |
-
|
6351 |
-
refiningStepsForOlderConfiguration = "block";
|
6352 |
-
|
6353 |
-
}}
|
6354 |
-
|
6355 |
var refiningUseDenoisingStartInBaseModelWhenUsingRefinerFieldDisplay = "block";
|
6356 |
|
6357 |
if (Object.keys(baseModelsNotSupportingDenoisingEndForBaseModelObject).includes(baseModelFieldValue)) {{
|
@@ -6361,7 +6827,6 @@ async (
|
|
6361 |
}}
|
6362 |
|
6363 |
document.getElementById("refining_use_denoising_start_in_base_model_when_using_refiner_field_row_id").style.display = refiningUseDenoisingStartInBaseModelWhenUsingRefinerFieldDisplay;
|
6364 |
-
document.getElementById("refining_steps_for_older_configuration_field_row_id").style.display = refiningStepsForOlderConfiguration;
|
6365 |
|
6366 |
}}
|
6367 |
|
@@ -6371,7 +6836,6 @@ async (
|
|
6371 |
base_model_names_object,
|
6372 |
model_configuration_names_object,
|
6373 |
base_model_array,
|
6374 |
-
model_configuration_include_refiner_number_of_steps_object,
|
6375 |
base_models_not_supporting_denoising_end_for_base_model_object,
|
6376 |
allow_other_model_versions
|
6377 |
)
|
@@ -6459,14 +6923,10 @@ async (
|
|
6459 |
|
6460 |
|
6461 |
create_image_function_inputs = [
|
6462 |
-
|
6463 |
base_model_field,
|
6464 |
-
|
6465 |
prompt_field,
|
6466 |
negative_prompt_field,
|
6467 |
-
|
6468 |
scheduler_field,
|
6469 |
-
|
6470 |
image_width_field,
|
6471 |
image_height_field,
|
6472 |
guidance_scale_field,
|
@@ -6475,17 +6935,14 @@ async (
|
|
6475 |
seed_field,
|
6476 |
add_seed_into_pipe_field,
|
6477 |
use_torch_manual_seed_but_do_not_add_to_pipe_field,
|
6478 |
-
|
6479 |
refining_selection_field,
|
6480 |
refining_denoise_start_field,
|
6481 |
refining_use_denoising_start_in_base_model_when_using_refiner_field,
|
6482 |
refining_base_model_output_to_refiner_is_in_latent_space_field,
|
6483 |
-
|
6484 |
refining_steps_for_older_configuration_field,
|
6485 |
-
|
6486 |
upscaling_selection_field,
|
6487 |
upscaling_num_inference_steps_field,
|
6488 |
-
|
6489 |
image_gallery_array_state,
|
6490 |
prompt_information_array_state,
|
6491 |
last_model_configuration_name_selected_state,
|
@@ -6494,14 +6951,10 @@ async (
|
|
6494 |
stored_pipe_state,
|
6495 |
stored_refiner_state,
|
6496 |
stored_upscaler_state,
|
6497 |
-
|
6498 |
save_base_image_when_using_refiner_field,
|
6499 |
save_refined_image_when_using_upscaler_field,
|
6500 |
-
|
6501 |
user_id_state,
|
6502 |
-
image_generation_id_state
|
6503 |
-
canceled_images_array_state
|
6504 |
-
|
6505 |
]
|
6506 |
|
6507 |
for this_model_configuration_dropdown_field in model_configuration_dropdown_fields_array:
|
@@ -6683,6 +7136,39 @@ async () => {{
|
|
6683 |
|
6684 |
document.querySelectorAll(".textbox_vertical_scroll textarea").forEach(e => e.classList.remove("scroll-hide"));
|
6685 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6686 |
}}
|
6687 |
|
6688 |
""".format(
|
@@ -6712,14 +7198,16 @@ async () => {{
|
|
6712 |
|
6713 |
sd_interface_load_outputs = create_image_function_inputs + [
|
6714 |
initial_model_configuration_name_selected_state,
|
6715 |
-
generate_image_button
|
|
|
|
|
6716 |
]
|
6717 |
|
6718 |
|
6719 |
|
6720 |
every_value_in_seconds_for_image_preview = None
|
6721 |
|
6722 |
-
if
|
6723 |
|
6724 |
every_value_in_seconds_for_image_preview = load_image_preview_frequency_in_seconds
|
6725 |
|
@@ -6731,7 +7219,6 @@ async () => {{
|
|
6731 |
outputs = sd_interface_load_outputs,
|
6732 |
show_progress = "hidden",
|
6733 |
queue = False,
|
6734 |
-
scroll_to_output = False,
|
6735 |
js = script_on_load_js
|
6736 |
).then(
|
6737 |
fn = set_base_model_and_model_configuration_from_query_params,
|
@@ -6739,12 +7226,6 @@ async () => {{
|
|
6739 |
outputs = model_base_model_and_model_configuration_outputs,
|
6740 |
show_progress = "hidden",
|
6741 |
queue = False
|
6742 |
-
).then(
|
6743 |
-
fn = set_base_model_and_model_configuration_from_query_params,
|
6744 |
-
inputs = model_base_model_and_model_configuration_inputs,
|
6745 |
-
outputs = model_base_model_and_model_configuration_outputs,
|
6746 |
-
show_progress = "hidden",
|
6747 |
-
queue = False,
|
6748 |
).then(
|
6749 |
fn = load_image_preview,
|
6750 |
inputs = [
|
@@ -6760,6 +7241,110 @@ async () => {{
|
|
6760 |
|
6761 |
|
6762 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6763 |
sd_interface.queue(
|
6764 |
max_size = max_queue_size
|
6765 |
)
|
@@ -6772,13 +7357,19 @@ if auto_open_browser == 1:
|
|
6772 |
|
6773 |
inbrowser = True
|
6774 |
|
6775 |
-
|
6776 |
-
|
6777 |
-
|
6778 |
-
|
6779 |
-
|
6780 |
-
|
6781 |
-
|
6782 |
-
|
6783 |
-
|
6784 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
import torchsde
|
9 |
from math import floor, copysign
|
10 |
import time
|
11 |
+
import urllib.parse
|
12 |
|
13 |
##########
|
14 |
|
|
|
336 |
|
337 |
####################
|
338 |
|
339 |
+
#
|
340 |
+
# Dark Theme
|
341 |
+
#
|
342 |
+
|
343 |
+
default_dark_theme = 0
|
344 |
+
|
345 |
+
####################
|
346 |
+
|
347 |
#
|
348 |
# Add Seed Into Pipe
|
349 |
#
|
|
|
411 |
# Image Preview
|
412 |
#
|
413 |
|
|
|
414 |
use_image_preview = 1
|
415 |
image_preview_step_interval = 10
|
416 |
image_preview_seconds_interval = 60
|
|
|
929 |
|
930 |
if script_being_run_on_hugging_face == 1:
|
931 |
|
932 |
+
opening_html = "<span style=\"font-weight: bold; color: #c00;\">This app is extremely slow.</span> This app is not running on a GPU. The first time it loads after the space is rebuilt it might take 10 minutes to generate a SDXL Turbo image. It may take around 3 minutes after that point to do two steps. (with no refining or upscaling) For other models, it may take an hour to create a single image. Want apps that work fast? Use these which this app is based on: <a href=\"" + sdxl_link + "\" target=\"_blank\">Stable Diffusion XL</a>, <a href=\"" + photoreal_link + "\" target=\"_blank\">PhotoReal with SDXL 1.0 Refiner</a> and <a href=\"" + sdxl_turbo_link + "\" target=\"_blank\">SDXL Turbo Unofficial Demo</a>. This app is designed to give more options, but it's too slow to operate and test on a CPU. There are some features that are either not available, or more limited, in the online version of this app. (such as smaller allowed image dimensions and less steps allowed) This app is still in development."
|
933 |
|
934 |
else:
|
935 |
|
|
|
939 |
|
940 |
|
941 |
|
942 |
+
ending_html += """<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAABkCAMAAADADYxgAAABelBMVEVzQShrNiBOLB2FSSlaNSPm4uCVZ0RhQjVCJhtcKBc3HhN2TkN8WE2DYVtwRjl8TjOHWjtHGRA4DQivgltQHxLz6OD68+onGRYvWZGlWibswHv78dxOOzKSVDLwzY+idlNrU0ytZDCaUiPZrkrYnFe6jmLhpVvVro7Cl2zWomq4bjIOX7T158vAg1HAdzfR1dzntm6sdk4fc8jWk0rHgUC80OMda7vFoHXkrWWBrtvxyITSqHbOikW2dULcsHydXzSIUDvLj1OjbEP01Zvdq3BGCAqWdnKVamWRWUXJlF/w3ruVc1pGRk2sw9rcvZzeuYydhoAyKSjLo4KKbWjMoUCubjxaT1Lnv5y3knEaX6k8PEGkfGvDlzt2HBpaEBB+WSLy2q3kzam2jDSWbimQKyUUVJhHXH/DlX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iSl+nKhUDFSJMUldLpdVVg0tNUKTfN4pIZesrLxQys/br5KQznJkVtYnIHWsTKxWdVlcbjXsGt5RJF/EFNSq7rRa2FMyf+3EO1/5ZLTs+/A1R8ZxzG596+8Y6UDYFdQg1EBPoIaFjFiXD02r8XE3REzVfryutkqcRyypcbipMzgfcpmu4fKp0/BP/e3STtfOqxDY4eah5TasaMl49Th8x4pSxUY+pp8DGM7RSTRQ9vljNkKqMKqlVVJlOC3s6Rfp5la8fauf4eDjH6/8/NYPOylrR4ORvQ0ClnDGR58ut8a85qPEe6Bz8AHqBqmtv3n1rBIa0FaxKQ03moBIxydXl8Y8ZqNhMncN9yQVqJv0J+dZYFRQt4FLPqFO4TKVyneimeIcH5zugY3hq75BPgyKriKFIvcQq31xEJvCH5ZvoKuU37dMhLdfsj3Mq3sb302+Qd0qJil+AkiqNFTVxvVctbACwsgXiQXB4Xq0Fg/RbYjWNVWxTlIokKo+xifsc9+raRD0U9YT6gJInaikIzPRbSkqDh+2qYvWKqOpMrWjAmD6PXGrrz7Vm82TM3aUtlqi+aQ7SD4E+TE9U7bQKVNRpAwiF2oEhuUnu96mKaeR7+kOKLmVVtbOqEXegyD+z2AFDRvHjODY7RydUtqi/WUXOqAapmqjnS5W2NsWkvdU57pw0+fY6OjqaQ68RvIBqWbEK7SLVmPaV9xUuESx9UCBOMvmDv2JFnMdVezSBAAAAAElFTkSuQmCC" alt="Spaghetti AI Logo" title="Spaghetti AI Logo" style="float: left; padding: 5px 15px 15px 0px;">
|
943 |
|
944 |
Tokens are not individual characters. If the prompt length is too long, the display will notify you what part of the prompt wasn't used. Changing just the image dimensions alone will change the image generated. For some models, trying to make a large image, such as 1024x1024, may add extra people and come out worse than using smaller dimensions.
|
945 |
|
|
|
970 |
|
971 |
|
972 |
|
973 |
+
canceled_image_in_queue_message = "Due to how the queue works in this app, you need to reload the page after canceling an image. Otherwise, you will not be able to generate another image until you reach the position in the queue you were in originally. At that time, the button to generate an image will appear again. You can easily create a link on this page to save what you have entered and visit that link to generate the image."
|
974 |
|
975 |
canceled_image_in_process_of_being_generated = "<div style=\"text-align: center;\">Image generation will be canceled once the current step completes.</div>"
|
976 |
|
977 |
|
978 |
|
979 |
+
base_model_field_key_in_url = "model"
|
980 |
+
download_data_key_in_url = "download_data"
|
981 |
+
model_configuration_key_in_url = "model_config"
|
982 |
+
prompt_field_key_in_url = "prompt"
|
983 |
+
negative_prompt_field_key_in_url = "neg_prompt"
|
984 |
+
scheduler_field_key_in_url = "scheduler"
|
985 |
+
image_width_field_key_in_url = "width"
|
986 |
+
image_height_field_key_in_url = "height"
|
987 |
+
guidance_scale_field_key_in_url = "guidance"
|
988 |
+
steps_key_in_url = "steps"
|
989 |
+
seed_field_key_in_url = "seed"
|
990 |
+
add_seed_key_in_url = "add_seed"
|
991 |
+
use_torch_manual_seed_but_not_in_generator_key_in_url = "use_torch_manual_seed_but_not_in_generator"
|
992 |
+
refiner_key_in_url = "refiner"
|
993 |
+
refiner_denoise_start_key_in_url = "denoise_start"
|
994 |
+
refining_steps_option_key_in_url = "refiner_steps_option"
|
995 |
+
refining_steps_key_in_url = "refiner_steps"
|
996 |
+
use_denoising_start_in_base_model_when_using_refiner_key_in_url = "use_denoise_end"
|
997 |
+
base_model_output_to_refiner_is_in_latent_space_key_in_url = "latent_space_before_refiner"
|
998 |
+
upscaler_key_in_url = "upscaler"
|
999 |
+
upscaling_steps_key_in_url = "upscaler_steps"
|
1000 |
+
theme_key_in_url = "theme"
|
1001 |
+
special_theme_key_in_url = "__theme"
|
1002 |
+
|
1003 |
+
|
1004 |
+
|
1005 |
###############################################################################
|
1006 |
###############################################################################
|
1007 |
#
|
|
|
1237 |
|
1238 |
additional_prompt_info_html = " The image, and a text file with generation information, will be saved automatically."
|
1239 |
|
1240 |
+
else:
|
1241 |
+
|
1242 |
+
canceled_image_in_queue_message += " Make sure to save any imagery before reloading the page."
|
1243 |
+
|
1244 |
|
1245 |
|
1246 |
if use_xformers == 1:
|
|
|
1427 |
|
1428 |
|
1429 |
|
1430 |
+
default_dark_theme_is_selected = False
|
1431 |
+
|
1432 |
+
if default_dark_theme == 1:
|
1433 |
+
|
1434 |
+
default_dark_theme_is_selected = True
|
1435 |
+
|
1436 |
+
|
1437 |
+
|
1438 |
default_add_seed_into_pipe_is_selected = False
|
1439 |
|
1440 |
if default_add_seed_into_pipe == 1:
|
|
|
1493 |
|
1494 |
|
1495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1496 |
make_seed_selection_a_textbox = 1
|
1497 |
|
1498 |
if maximum_seed <= 9007199254740992:
|
|
|
2054 |
|
2055 |
|
2056 |
|
2057 |
+
#####################
|
2058 |
+
#
|
2059 |
+
# Theme
|
2060 |
+
#
|
2061 |
+
# Return True if valid.
|
2062 |
+
#
|
2063 |
+
#####################
|
2064 |
+
|
2065 |
+
def theme_valid(
|
2066 |
+
theme_field
|
2067 |
+
):
|
2068 |
+
try:
|
2069 |
+
theme_field_str = str(theme_field).lower()
|
2070 |
+
if (
|
2071 |
+
(theme_field_str == "light") or
|
2072 |
+
(theme_field_str == "dark")
|
2073 |
+
):
|
2074 |
+
return True
|
2075 |
+
else:
|
2076 |
+
return False
|
2077 |
+
except ValueError:
|
2078 |
+
return False
|
2079 |
+
|
2080 |
+
|
2081 |
+
|
2082 |
+
try:
|
2083 |
+
upscaling_steps_num = int(upscaling_steps_num_str)
|
2084 |
+
if (
|
2085 |
+
(upscaling_steps_num > 0) and
|
2086 |
+
(upscaling_steps_num <= int(maximum_upscaler_steps))
|
2087 |
+
):
|
2088 |
+
return True
|
2089 |
+
else:
|
2090 |
+
return False
|
2091 |
+
except ValueError:
|
2092 |
+
return False
|
2093 |
+
|
2094 |
+
|
2095 |
+
|
2096 |
+
|
2097 |
+
|
2098 |
+
|
2099 |
+
|
2100 |
#####################
|
2101 |
#
|
2102 |
# Numerical Bool
|
|
|
2702 |
image_height,
|
2703 |
actual_seed,
|
2704 |
add_seed_into_pipe,
|
2705 |
+
use_torch_manual_seed_but_do_not_add_to_pipe_field_value,
|
2706 |
guidance_scale,
|
2707 |
base_model_steps,
|
2708 |
display_xformers_usage_in_prompt_info,
|
|
|
2714 |
denoising_end_applicable,
|
2715 |
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
2716 |
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
2717 |
+
refining_steps_option_for_older_configuration_field_value,
|
2718 |
refining_steps_for_older_configuration_field_value,
|
2719 |
use_upscaler,
|
2720 |
upscaler_error,
|
|
|
2797 |
"Seed added to generation? " + nice_seed_added_to_generation
|
2798 |
])
|
2799 |
|
2800 |
+
if (
|
2801 |
+
(add_seed_into_pipe != 1) and
|
2802 |
+
(use_torch_manual_seed_but_do_not_add_to_pipe_field_value == 1)
|
2803 |
+
):
|
2804 |
+
|
2805 |
+
info_about_prompt_lines_array.extend([
|
2806 |
+
"Use torch.manual_seed, but don't explicitly add it as a generator during generation? Yes"
|
2807 |
+
])
|
2808 |
+
|
2809 |
if int(guidance_scale) > 0:
|
2810 |
|
2811 |
info_about_prompt_lines_array.extend([
|
|
|
2883 |
"Refiner denoise start %: " + nice_refiner_denoise_start
|
2884 |
])
|
2885 |
|
2886 |
+
if refining_steps_option_for_older_configuration_field_value == 1:
|
2887 |
+
|
2888 |
+
info_about_prompt_lines_array.extend([
|
2889 |
+
"Number of steps in refiner that \"denoise start %\" applies to: " + str(refining_steps_for_older_configuration_field_value)
|
2890 |
+
])
|
2891 |
+
|
2892 |
if current_actual_total_refiner_steps > 0:
|
2893 |
|
2894 |
info_about_prompt_lines_array.extend([
|
|
|
3022 |
|
3023 |
user_id_state_value = user_id_state.value
|
3024 |
|
3025 |
+
print ("Image preview check run", current_preview_image_user_id, user_id_state_value)
|
3026 |
|
3027 |
if (
|
3028 |
(user_id_state_value > 0) and
|
|
|
3457 |
#####################
|
3458 |
|
3459 |
def create_image_function (
|
|
|
3460 |
base_model_field_index,
|
3461 |
prompt_text,
|
3462 |
negative_prompt_text,
|
|
|
3463 |
scheduler_index,
|
|
|
3464 |
image_width,
|
3465 |
image_height,
|
3466 |
guidance_scale,
|
|
|
3468 |
base_model_steps_field_for_sdxl_turbo,
|
3469 |
actual_seed,
|
3470 |
add_seed_into_pipe,
|
3471 |
+
use_torch_manual_seed_but_do_not_add_to_pipe_field_value,
|
|
|
3472 |
refining_selection_field_value,
|
3473 |
refining_denoise_start_field_value,
|
3474 |
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
3475 |
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
3476 |
+
refining_steps_option_for_older_configuration_field_value,
|
3477 |
refining_steps_for_older_configuration_field_value,
|
|
|
3478 |
upscaling_selection_field_value,
|
3479 |
upscaling_steps,
|
|
|
3480 |
image_gallery_array_state_value,
|
3481 |
prompt_information_array_state_value,
|
|
|
3482 |
last_model_configuration_name_selected_state_value,
|
3483 |
last_refiner_name_selected_state_value,
|
3484 |
last_upscaler_name_selected_state_value,
|
|
|
3485 |
stored_pipe_state,
|
3486 |
stored_refiner_state,
|
3487 |
stored_upscaler_state,
|
|
|
3488 |
save_base_image_when_using_refiner_field_value,
|
3489 |
save_refined_image_when_using_upscaler_field_value,
|
|
|
3490 |
user_id_state,
|
3491 |
image_generation_id_state,
|
|
|
|
|
3492 |
*model_configuration_dropdown_fields_array,
|
|
|
3493 |
progress = gr.Progress()
|
|
|
3494 |
):
|
3495 |
|
3496 |
image_generation_id_state_value = image_generation_id_state.value
|
|
|
3620 |
|
3621 |
|
3622 |
add_seed_into_pipe = numerical_bool(add_seed_into_pipe)
|
3623 |
+
use_torch_manual_seed_but_do_not_add_to_pipe_field_value = numerical_bool(use_torch_manual_seed_but_do_not_add_to_pipe_field_value)
|
3624 |
|
3625 |
|
3626 |
|
|
|
3633 |
|
3634 |
|
3635 |
|
3636 |
+
refining_steps_option_for_older_configuration_field_value = numerical_bool(refining_steps_option_for_older_configuration_field_value)
|
3637 |
+
|
3638 |
+
|
3639 |
+
|
3640 |
use_upscaler = numerical_bool(upscaling_selection_field_value)
|
3641 |
|
3642 |
|
|
|
3652 |
if not refiner_denoise_start_valid(refining_denoise_start_field_value):
|
3653 |
error_function("Refiner denoise start is not valid.")
|
3654 |
|
3655 |
+
if refining_steps_option_for_older_configuration_field_value == 1:
|
3656 |
|
3657 |
# For older configrations. Doesn't reflect actual number of steps.
|
3658 |
|
3659 |
+
if not refining_steps_valid(refining_steps_for_older_configuration_field_value):
|
3660 |
+
error_function("Number of steps in refiner that \"denoise start %\" applies to is not valid.")
|
3661 |
+
|
3662 |
+
num_inference_steps_in_refiner = refining_steps_for_older_configuration_field_value
|
3663 |
|
3664 |
|
3665 |
|
|
|
3830 |
|
3831 |
else:
|
3832 |
|
3833 |
+
if use_torch_manual_seed_but_do_not_add_to_pipe_field_value == 1:
|
3834 |
|
3835 |
torch.manual_seed(actual_seed)
|
3836 |
|
|
|
3869 |
|
3870 |
output_type_in_base_model_to_use = "latent"
|
3871 |
|
3872 |
+
current_estimated_total_refiner_steps = rounded_number(num_inference_steps_in_refiner - (num_inference_steps_in_refiner * refining_denoise_start_field_value))
|
3873 |
|
3874 |
if current_estimated_total_refiner_steps < 1:
|
3875 |
|
|
|
3888 |
|
3889 |
|
3890 |
current_base_model_generation_start_time = 0
|
3891 |
+
# global current_base_model_generation_start_time
|
3892 |
+
# current_base_model_generation_start_time = time.time()
|
3893 |
|
3894 |
global saved_final_base_model_pil_image_if_using_refiner
|
3895 |
saved_final_base_model_pil_image_if_using_refiner = None
|
|
|
3898 |
global upscaled_image_canceled_latents
|
3899 |
|
3900 |
upscaled_image_canceled = 0
|
|
|
3901 |
|
3902 |
|
3903 |
|
|
|
3922 |
|
3923 |
seconds_per_step = 0
|
3924 |
|
3925 |
+
# if callback_step_number >= 1:
|
3926 |
+
if callback_step_number >= 2:
|
3927 |
|
3928 |
+
seconds_per_step = ((time.time() - current_base_model_generation_start_time) / callback_step_number)
|
3929 |
|
3930 |
nice_time_per_step = nice_elapsed_time(seconds_per_step)
|
3931 |
|
|
|
4024 |
):
|
4025 |
|
4026 |
current_refiner_generation_start_time = 0
|
4027 |
+
# global current_refiner_generation_start_time
|
4028 |
+
# current_refiner_generation_start_time = time.time()
|
4029 |
|
4030 |
def callback_function_for_refiner_progress(
|
4031 |
callback_pipe,
|
|
|
4048 |
|
4049 |
seconds_per_step = 0
|
4050 |
|
4051 |
+
# if callback_step_number >= 1:
|
4052 |
+
if callback_step_number >= 2:
|
4053 |
|
4054 |
+
seconds_per_step = ((time.time() - current_refiner_generation_start_time) / callback_step_number)
|
4055 |
|
4056 |
nice_time_per_step = nice_elapsed_time(seconds_per_step)
|
4057 |
|
|
|
4110 |
|
4111 |
|
4112 |
current_upscaler_generation_start_time = 0
|
4113 |
+
# global current_upscaler_generation_start_time
|
4114 |
+
# current_upscaler_generation_start_time = time.time()
|
4115 |
|
4116 |
def callback_function_for_upscaler_progress(
|
4117 |
callback_step_index,
|
|
|
4133 |
|
4134 |
seconds_per_step = 0
|
4135 |
|
4136 |
+
# if callback_step_number >= 1:
|
4137 |
+
if callback_step_number >= 2:
|
4138 |
|
4139 |
+
seconds_per_step = ((time.time() - current_upscaler_generation_start_time) / callback_step_number)
|
4140 |
|
4141 |
nice_time_per_step = nice_elapsed_time(seconds_per_step)
|
4142 |
|
|
|
4596 |
image_height,
|
4597 |
actual_seed,
|
4598 |
add_seed_into_pipe,
|
4599 |
+
use_torch_manual_seed_but_do_not_add_to_pipe_field_value,
|
4600 |
guidance_scale,
|
4601 |
base_model_steps,
|
4602 |
display_xformers_usage_in_prompt_info,
|
|
|
4608 |
denoising_end_applicable,
|
4609 |
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
4610 |
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
4611 |
+
refining_steps_option_for_older_configuration_field_value,
|
4612 |
refining_steps_for_older_configuration_field_value,
|
4613 |
use_upscaler,
|
4614 |
upscaler_error,
|
|
|
5015 |
model_configuration_name_value
|
5016 |
)
|
5017 |
|
5018 |
+
data_links_downloaded_object[model_configuration_value] = 1
|
5019 |
|
5020 |
print ("Downloading/loading refiner data...")
|
5021 |
|
|
|
5039 |
|
5040 |
#####################
|
5041 |
#
|
5042 |
+
# Generate Link
|
5043 |
#
|
5044 |
+
#
|
|
|
5045 |
#
|
5046 |
#####################
|
5047 |
|
5048 |
+
def generate_link_function(
|
5049 |
+
page_url_hidden_field_value,
|
5050 |
+
generate_link_field_value,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5051 |
|
5052 |
+
base_model_field_index,
|
5053 |
+
prompt_text,
|
5054 |
+
negative_prompt_text,
|
5055 |
+
scheduler_index,
|
5056 |
+
image_width,
|
5057 |
+
image_height,
|
5058 |
+
guidance_scale,
|
5059 |
+
base_model_steps,
|
5060 |
+
base_model_steps_field_for_sdxl_turbo,
|
5061 |
+
actual_seed,
|
5062 |
+
add_seed_into_pipe,
|
5063 |
+
use_torch_manual_seed_but_do_not_add_to_pipe_field_value,
|
5064 |
+
refining_selection_field_value,
|
5065 |
+
refining_denoise_start_field_value,
|
5066 |
+
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
5067 |
+
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
5068 |
+
refining_steps_option_for_older_configuration_field_value,
|
5069 |
+
refining_steps_for_older_configuration_field_value,
|
5070 |
+
upscaling_selection_field_value,
|
5071 |
+
upscaling_steps,
|
5072 |
+
image_gallery_array_state_value,
|
5073 |
+
prompt_information_array_state_value,
|
5074 |
+
last_model_configuration_name_selected_state_value,
|
5075 |
+
last_refiner_name_selected_state_value,
|
5076 |
+
last_upscaler_name_selected_state_value,
|
5077 |
+
stored_pipe_state,
|
5078 |
+
stored_refiner_state,
|
5079 |
+
stored_upscaler_state,
|
5080 |
+
save_base_image_when_using_refiner_field_value,
|
5081 |
+
save_refined_image_when_using_upscaler_field_value,
|
5082 |
+
user_id_state,
|
5083 |
+
image_generation_id_state,
|
5084 |
+
*model_configuration_dropdown_fields_array
|
5085 |
+
):
|
5086 |
|
5087 |
+
base_model_name_value = base_model_array[base_model_field_index]
|
5088 |
|
5089 |
|
5090 |
|
5091 |
+
position_in_array = 0
|
5092 |
|
5093 |
+
model_configuration_field_object = {}
|
5094 |
|
5095 |
+
for model_configuration_field_index in model_configuration_dropdown_fields_array:
|
5096 |
|
5097 |
+
this_base_model = base_model_array[position_in_array]
|
5098 |
|
5099 |
+
model_configuration_field_object[this_base_model] = model_configuration_field_index
|
5100 |
|
5101 |
+
position_in_array += 1
|
5102 |
|
5103 |
+
model_configuration_field_index = model_configuration_field_object[base_model_name_value]
|
5104 |
+
model_configuration_name_value = base_model_object_of_model_configuration_arrays[base_model_name_value][model_configuration_field_index]
|
5105 |
|
|
|
5106 |
|
|
|
5107 |
|
5108 |
+
scheduler_value = schedulers_array[scheduler_index]
|
5109 |
|
|
|
5110 |
|
|
|
5111 |
|
5112 |
+
if base_model_name_value == "sdxl_turbo":
|
5113 |
+
base_model_steps = base_model_steps_field_for_sdxl_turbo
|
5114 |
|
5115 |
|
5116 |
|
5117 |
+
page_vars = ""
|
5118 |
|
|
|
5119 |
|
|
|
5120 |
|
5121 |
+
if base_model_valid(base_model_name_value):
|
5122 |
+
page_vars += base_model_field_key_in_url + "=" + base_model_name_value + "&"
|
|
|
|
|
5123 |
|
|
|
5124 |
|
5125 |
|
5126 |
+
if model_configuration_valid(base_model_name_value, model_configuration_name_value):
|
5127 |
+
page_vars += model_configuration_key_in_url + "=" + model_configuration_name_value + "&"
|
5128 |
|
|
|
5129 |
|
|
|
5130 |
|
5131 |
+
if scheduler_valid(scheduler_value):
|
5132 |
+
page_vars += scheduler_field_key_in_url + "=" + scheduler_value + "&"
|
5133 |
|
|
|
5134 |
|
|
|
5135 |
|
5136 |
+
if width_valid(image_width):
|
5137 |
+
page_vars += image_width_field_key_in_url + "=" + str(image_width) + "&"
|
5138 |
|
|
|
5139 |
|
|
|
5140 |
|
5141 |
+
if height_valid(image_height):
|
5142 |
+
page_vars += image_height_field_key_in_url + "=" + str(image_height) + "&"
|
5143 |
|
|
|
5144 |
|
|
|
5145 |
|
5146 |
+
if guidance_scale_valid(guidance_scale):
|
5147 |
+
page_vars += guidance_scale_field_key_in_url + "=" + str(guidance_scale) + "&"
|
5148 |
|
5149 |
|
5150 |
|
5151 |
+
if steps_valid(base_model_steps, base_model_name_value):
|
5152 |
+
page_vars += steps_key_in_url + "=" + str(base_model_steps) + "&"
|
5153 |
|
|
|
5154 |
|
|
|
5155 |
|
5156 |
+
if seed_valid(actual_seed):
|
5157 |
+
page_vars += seed_field_key_in_url + "=" + str(actual_seed) + "&"
|
5158 |
|
|
|
5159 |
|
5160 |
|
5161 |
+
nice_add_seed_into_pipe = "yes"
|
5162 |
+
if add_seed_into_pipe == False:
|
5163 |
+
nice_add_seed_into_pipe = "no"
|
5164 |
|
5165 |
+
page_vars += add_seed_key_in_url + "=" + nice_add_seed_into_pipe + "&"
|
5166 |
|
|
|
5167 |
|
|
|
5168 |
|
5169 |
+
if (
|
5170 |
+
(add_seed_into_pipe == False) and
|
5171 |
+
(use_torch_manual_seed_but_do_not_add_to_pipe_field_value == True)
|
5172 |
+
):
|
5173 |
|
5174 |
+
page_vars += use_torch_manual_seed_but_not_in_generator_key_in_url + "=yes&"
|
5175 |
|
5176 |
|
5177 |
|
5178 |
+
nice_refining_selection_field_value = "no"
|
5179 |
+
if refining_selection_field_value == "Yes":
|
5180 |
+
nice_refining_selection_field_value = "yes"
|
5181 |
|
5182 |
+
page_vars += refiner_key_in_url + "=" + nice_refining_selection_field_value + "&"
|
5183 |
|
|
|
5184 |
|
|
|
5185 |
|
5186 |
+
if refiner_denoise_start_valid(refining_denoise_start_field_value):
|
5187 |
+
page_vars += refiner_denoise_start_key_in_url + "=" + str(refining_denoise_start_field_value) + "&"
|
5188 |
|
|
|
5189 |
|
|
|
5190 |
|
5191 |
+
if refining_steps_option_for_older_configuration_field_value == True:
|
5192 |
+
page_vars += refining_steps_option_key_in_url + "=yes&"
|
5193 |
|
5194 |
+
if refining_steps_valid(refining_steps_for_older_configuration_field_value):
|
5195 |
+
page_vars += refining_steps_key_in_url + "=" + str(refining_steps_for_older_configuration_field_value) + "&"
|
5196 |
|
|
|
5197 |
|
|
|
5198 |
|
5199 |
+
nice_refining_use_denoising_start_in_base_model_when_using_refiner_field_value = "yes"
|
5200 |
+
if refining_use_denoising_start_in_base_model_when_using_refiner_field_value == False:
|
5201 |
+
nice_refining_use_denoising_start_in_base_model_when_using_refiner_field_value = "no"
|
5202 |
|
5203 |
+
page_vars += use_denoising_start_in_base_model_when_using_refiner_key_in_url + "=" + nice_refining_use_denoising_start_in_base_model_when_using_refiner_field_value + "&"
|
5204 |
|
|
|
5205 |
|
5206 |
|
5207 |
+
nice_refining_base_model_output_to_refiner_is_in_latent_space_field_value = "yes"
|
5208 |
+
if refining_base_model_output_to_refiner_is_in_latent_space_field_value == False:
|
5209 |
+
nice_refining_base_model_output_to_refiner_is_in_latent_space_field_value = "no"
|
5210 |
|
5211 |
+
page_vars += base_model_output_to_refiner_is_in_latent_space_key_in_url + "=" + nice_refining_base_model_output_to_refiner_is_in_latent_space_field_value + "&"
|
5212 |
|
|
|
5213 |
|
|
|
5214 |
|
5215 |
+
nice_upscaling_selection_field_value = "no"
|
5216 |
+
if upscaling_selection_field_value == "Yes":
|
5217 |
+
nice_upscaling_selection_field_value = "yes"
|
5218 |
|
5219 |
+
page_vars += upscaler_key_in_url + "=" + nice_upscaling_selection_field_value + "&"
|
5220 |
|
5221 |
|
5222 |
|
5223 |
+
if upscaling_steps_valid(upscaling_steps):
|
5224 |
+
page_vars += upscaling_steps_key_in_url + "=" + str(upscaling_steps) + "&"
|
5225 |
|
|
|
5226 |
|
|
|
5227 |
|
5228 |
+
prompt_text = prompt_text[:maximum_prompt_characer_count]
|
5229 |
+
if prompt_valid(prompt_text):
|
5230 |
+
page_vars += prompt_field_key_in_url + "=" + urllib.parse.quote(prompt_text) + "&"
|
5231 |
|
|
|
5232 |
|
5233 |
|
5234 |
+
negative_prompt_text = negative_prompt_text[:maximum_prompt_characer_count]
|
5235 |
+
if prompt_valid(negative_prompt_text):
|
5236 |
+
page_vars += negative_prompt_field_key_in_url + "=" + urllib.parse.quote(negative_prompt_text) + "&"
|
5237 |
|
|
|
5238 |
|
|
|
5239 |
|
5240 |
+
# Remove last &
|
5241 |
|
5242 |
+
page_vars = page_vars[:-1]
|
5243 |
|
5244 |
+
page_url = page_url_hidden_field_value + "?" + page_vars
|
5245 |
|
5246 |
+
return page_url
|
5247 |
|
|
|
5248 |
|
|
|
5249 |
|
5250 |
+
#####################
|
5251 |
+
#
|
5252 |
+
# Generate Link Textbox
|
5253 |
+
#
|
5254 |
+
#
|
5255 |
+
#
|
5256 |
+
#####################
|
5257 |
|
5258 |
+
def generate_link_textbox_function(
|
5259 |
+
page_url_hidden_field_value,
|
5260 |
+
generate_link_field_value,
|
5261 |
|
5262 |
+
base_model_field_index,
|
5263 |
+
prompt_text,
|
5264 |
+
negative_prompt_text,
|
5265 |
+
scheduler_index,
|
5266 |
+
image_width,
|
5267 |
+
image_height,
|
5268 |
+
guidance_scale,
|
5269 |
+
base_model_steps,
|
5270 |
+
base_model_steps_field_for_sdxl_turbo,
|
5271 |
+
actual_seed,
|
5272 |
+
add_seed_into_pipe,
|
5273 |
+
use_torch_manual_seed_but_do_not_add_to_pipe_field_value,
|
5274 |
+
refining_selection_field_value,
|
5275 |
+
refining_denoise_start_field_value,
|
5276 |
+
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
5277 |
+
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
5278 |
+
refining_steps_option_for_older_configuration_field_value,
|
5279 |
+
refining_steps_for_older_configuration_field_value,
|
5280 |
+
upscaling_selection_field_value,
|
5281 |
+
upscaling_steps,
|
5282 |
+
image_gallery_array_state_value,
|
5283 |
+
prompt_information_array_state_value,
|
5284 |
+
last_model_configuration_name_selected_state_value,
|
5285 |
+
last_refiner_name_selected_state_value,
|
5286 |
+
last_upscaler_name_selected_state_value,
|
5287 |
+
stored_pipe_state,
|
5288 |
+
stored_refiner_state,
|
5289 |
+
stored_upscaler_state,
|
5290 |
+
save_base_image_when_using_refiner_field_value,
|
5291 |
+
save_refined_image_when_using_upscaler_field_value,
|
5292 |
+
user_id_state,
|
5293 |
+
image_generation_id_state,
|
5294 |
+
*model_configuration_dropdown_fields_array
|
5295 |
+
):
|
5296 |
|
5297 |
+
page_url = generate_link_function(
|
5298 |
+
page_url_hidden_field_value,
|
5299 |
+
generate_link_field_value,
|
5300 |
+
|
5301 |
+
base_model_field_index,
|
5302 |
+
prompt_text,
|
5303 |
+
negative_prompt_text,
|
5304 |
+
scheduler_index,
|
5305 |
+
image_width,
|
5306 |
+
image_height,
|
5307 |
+
guidance_scale,
|
5308 |
+
base_model_steps,
|
5309 |
+
base_model_steps_field_for_sdxl_turbo,
|
5310 |
+
actual_seed,
|
5311 |
+
add_seed_into_pipe,
|
5312 |
+
use_torch_manual_seed_but_do_not_add_to_pipe_field_value,
|
5313 |
+
refining_selection_field_value,
|
5314 |
+
refining_denoise_start_field_value,
|
5315 |
+
refining_use_denoising_start_in_base_model_when_using_refiner_field_value,
|
5316 |
+
refining_base_model_output_to_refiner_is_in_latent_space_field_value,
|
5317 |
+
refining_steps_option_for_older_configuration_field_value,
|
5318 |
+
refining_steps_for_older_configuration_field_value,
|
5319 |
+
upscaling_selection_field_value,
|
5320 |
+
upscaling_steps,
|
5321 |
+
image_gallery_array_state_value,
|
5322 |
+
prompt_information_array_state_value,
|
5323 |
+
last_model_configuration_name_selected_state_value,
|
5324 |
+
last_refiner_name_selected_state_value,
|
5325 |
+
last_upscaler_name_selected_state_value,
|
5326 |
+
stored_pipe_state,
|
5327 |
+
stored_refiner_state,
|
5328 |
+
stored_upscaler_state,
|
5329 |
+
save_base_image_when_using_refiner_field_value,
|
5330 |
+
save_refined_image_when_using_upscaler_field_value,
|
5331 |
+
user_id_state,
|
5332 |
+
image_generation_id_state,
|
5333 |
+
*model_configuration_dropdown_fields_array
|
5334 |
+
)
|
5335 |
+
|
5336 |
+
generate_link_field_update = gr.Textbox(
|
5337 |
+
visible = True,
|
5338 |
+
value = page_url
|
5339 |
+
)
|
5340 |
+
|
5341 |
+
return {
|
5342 |
+
generate_link_field: generate_link_field_update
|
5343 |
+
}
|
5344 |
+
|
5345 |
+
|
5346 |
+
|
5347 |
+
|
5348 |
+
|
5349 |
+
|
5350 |
+
|
5351 |
+
#####################
|
5352 |
+
#
|
5353 |
+
# Get Query Params
|
5354 |
+
#
|
5355 |
+
# Get variables from the url of the page and update the display to
|
5356 |
+
# reflect them.
|
5357 |
+
#
|
5358 |
+
#####################
|
5359 |
+
|
5360 |
+
def get_query_params(
|
5361 |
+
request: gr.Request
|
5362 |
+
):
|
5363 |
+
|
5364 |
+
raw_url_params = str(request.query_params)
|
5365 |
+
|
5366 |
+
unprocessed_url_object = urllib.parse.parse_qs(raw_url_params)
|
5367 |
+
|
5368 |
+
url_object = {}
|
5369 |
+
|
5370 |
+
for url_param_key in unprocessed_url_object:
|
5371 |
+
|
5372 |
+
url_param_value = unprocessed_url_object[url_param_key][0]
|
5373 |
+
|
5374 |
+
if len(url_param_value) > 0:
|
5375 |
+
|
5376 |
+
url_param_key = str(url_param_key)
|
5377 |
+
|
5378 |
+
url_param_key_lowercase = url_param_key.lower()
|
5379 |
+
|
5380 |
+
url_object[url_param_key_lowercase] = str(unprocessed_url_object[url_param_key][0]).lower()
|
5381 |
+
|
5382 |
+
|
5383 |
+
|
5384 |
+
print ("-----a-----")
|
5385 |
+
print (request.headers)
|
5386 |
+
print ("-----b-----")
|
5387 |
+
print (request.client)
|
5388 |
+
print ("-----c-----")
|
5389 |
+
print (request.query_params)
|
5390 |
+
print ("-----d-----")
|
5391 |
+
print (request.path_params)
|
5392 |
+
print ("-----e-----")
|
5393 |
+
|
5394 |
+
|
5395 |
+
|
5396 |
+
page_url = str(request.headers["referer"])
|
5397 |
+
|
5398 |
+
page_url = page_url.split("?")[0]
|
5399 |
+
|
5400 |
+
page_url_hidden_field_update = gr.Textbox(
|
5401 |
+
value = page_url
|
5402 |
+
)
|
5403 |
+
|
5404 |
+
field_object = {
|
5405 |
+
page_url_hidden_field: page_url_hidden_field_update
|
5406 |
+
}
|
5407 |
+
|
5408 |
+
|
5409 |
+
|
5410 |
+
user_id_number = int(random.randrange(0, 1000000000))
|
5411 |
+
|
5412 |
+
user_id_state_update = gr.State(user_id_number)
|
5413 |
+
|
5414 |
+
field_object.update({user_id_state: user_id_state_update})
|
5415 |
+
|
5416 |
+
|
5417 |
+
|
5418 |
+
base_model_name_value = default_base_model
|
5419 |
+
|
5420 |
+
if base_model_field_key_in_url in url_object:
|
5421 |
+
|
5422 |
+
base_model_field_in_url = url_object[base_model_field_key_in_url].lower()
|
5423 |
+
|
5424 |
+
if base_model_valid(base_model_field_in_url):
|
5425 |
+
|
5426 |
+
base_model_name_value = base_model_field_in_url
|
5427 |
+
|
5428 |
+
base_model_nicely_named_value = base_model_names_object[base_model_name_value]
|
5429 |
+
|
5430 |
+
field_object.update({base_model_field: base_model_nicely_named_value})
|
5431 |
+
|
5432 |
+
|
5433 |
+
|
5434 |
+
if download_data_key_in_url in url_object:
|
5435 |
+
|
5436 |
+
download_data_option_in_url = str(url_object[download_data_key_in_url])
|
5437 |
+
|
5438 |
+
if (
|
5439 |
+
(download_data_option_in_url == "1") or
|
5440 |
+
(download_data_option_in_url == "2")
|
5441 |
+
):
|
5442 |
+
|
5443 |
+
download_data_from_huggingface(download_data_option_in_url)
|
5444 |
+
|
5445 |
+
|
5446 |
+
|
5447 |
+
model_configuration_in_url = ""
|
5448 |
+
|
5449 |
+
if model_configuration_key_in_url in url_object:
|
5450 |
+
|
5451 |
+
model_configuration_in_url = url_object[model_configuration_key_in_url].lower()
|
5452 |
+
|
5453 |
+
for this_base_model in base_model_array:
|
5454 |
+
|
5455 |
+
if base_model_name_value == this_base_model:
|
5456 |
+
|
5457 |
+
model_configuration_name_value = base_model_model_configuration_defaults_object[this_base_model]
|
5458 |
+
|
5459 |
+
if len(model_configuration_in_url) > 0:
|
5460 |
+
|
5461 |
+
for this_model_configuration in base_model_object_of_model_configuration_arrays[this_base_model]:
|
5462 |
+
|
5463 |
+
if model_configuration_valid(base_model_name_value, model_configuration_in_url):
|
5464 |
+
|
5465 |
+
model_configuration_name_value = this_model_configuration
|
5466 |
+
|
5467 |
+
field_object.update({initial_model_configuration_name_selected_state: model_configuration_in_url})
|
5468 |
+
|
5469 |
+
|
5470 |
+
|
5471 |
+
if prompt_field_key_in_url in url_object:
|
5472 |
+
|
5473 |
+
prompt_field_in_url = url_object[prompt_field_key_in_url].lower()
|
5474 |
+
|
5475 |
+
if prompt_valid(prompt_field_in_url):
|
5476 |
+
|
5477 |
+
field_object.update({prompt_field: prompt_field_in_url})
|
5478 |
+
|
5479 |
+
|
5480 |
+
|
5481 |
+
if negative_prompt_field_key_in_url in url_object:
|
5482 |
+
|
5483 |
+
negative_prompt_field_in_url = url_object[negative_prompt_field_key_in_url].lower()
|
5484 |
+
|
5485 |
+
if prompt_valid(negative_prompt_valid):
|
5486 |
+
|
5487 |
+
field_object.update({negative_prompt_field: negative_prompt_field_in_url})
|
5488 |
+
|
5489 |
+
|
5490 |
+
|
5491 |
+
if scheduler_field_key_in_url in url_object:
|
5492 |
+
|
5493 |
+
scheduler_field_in_url = url_object[scheduler_field_key_in_url].lower()
|
5494 |
+
|
5495 |
+
if scheduler_valid(scheduler_field_in_url):
|
5496 |
+
|
5497 |
+
scheduler_name_value = scheduler_field_in_url
|
5498 |
+
|
5499 |
+
scheduler_nicely_named_value = scheduler_long_names_object[scheduler_name_value]
|
5500 |
+
|
5501 |
+
field_object.update({scheduler_field: scheduler_nicely_named_value})
|
5502 |
+
|
5503 |
+
|
5504 |
+
|
5505 |
+
if image_width_field_key_in_url in url_object:
|
5506 |
+
|
5507 |
+
image_width_field_in_url = str(url_object[image_width_field_key_in_url])
|
5508 |
+
|
5509 |
+
if width_valid(image_width_field_in_url):
|
5510 |
+
|
5511 |
+
field_object.update({image_width_field: image_width_field_in_url})
|
5512 |
+
|
5513 |
+
|
5514 |
+
|
5515 |
+
if image_height_field_key_in_url in url_object:
|
5516 |
+
|
5517 |
+
image_height_field_in_url = str(url_object[image_height_field_key_in_url])
|
5518 |
+
|
5519 |
+
if height_valid(image_height_field_in_url):
|
5520 |
+
|
5521 |
+
field_object.update({image_height_field: image_height_field_in_url})
|
5522 |
+
|
5523 |
+
|
5524 |
+
|
5525 |
+
if guidance_scale_field_key_in_url in url_object:
|
5526 |
+
|
5527 |
+
guidance_scale_field_in_url = str(url_object[guidance_scale_field_key_in_url])
|
5528 |
+
|
5529 |
+
if guidance_scale_valid(guidance_scale_field_in_url):
|
5530 |
+
|
5531 |
+
field_object.update({guidance_scale_field: guidance_scale_field_in_url})
|
5532 |
+
|
5533 |
+
|
5534 |
+
|
5535 |
+
if steps_key_in_url in url_object:
|
5536 |
+
|
5537 |
+
steps_in_url = str(url_object[steps_key_in_url])
|
5538 |
+
|
5539 |
+
if steps_valid(steps_in_url, base_model_name_value):
|
5540 |
+
|
5541 |
+
if base_model_name_value == "sdxl_turbo":
|
5542 |
+
|
5543 |
+
field_object.update({base_model_steps_field_for_sdxl_turbo_field: steps_in_url})
|
5544 |
+
|
5545 |
+
else:
|
5546 |
+
|
5547 |
+
field_object.update({base_model_steps_field: steps_in_url})
|
5548 |
+
|
5549 |
+
|
5550 |
+
|
5551 |
+
if seed_field_key_in_url in url_object:
|
5552 |
|
5553 |
seed_field_in_url = url_object[seed_field_key_in_url]
|
5554 |
|
|
|
5558 |
|
5559 |
|
5560 |
|
|
|
|
|
5561 |
add_seed_to_generation = None
|
5562 |
|
5563 |
if add_seed_key_in_url in url_object:
|
|
|
5579 |
|
5580 |
|
5581 |
|
|
|
|
|
5582 |
if use_torch_manual_seed_but_not_in_generator_key_in_url in url_object:
|
5583 |
|
5584 |
use_torch_manual_seed_but_not_in_generator_in_url = url_object[use_torch_manual_seed_but_not_in_generator_key_in_url].lower()
|
|
|
5605 |
|
5606 |
|
5607 |
|
|
|
|
|
5608 |
if refiner_key_in_url in url_object:
|
5609 |
|
5610 |
refiner_in_url = url_object[refiner_key_in_url].lower()
|
|
|
5624 |
|
5625 |
|
5626 |
|
|
|
|
|
5627 |
if refiner_denoise_start_key_in_url in url_object:
|
5628 |
|
5629 |
refiner_denoise_start_in_url = str(url_object[refiner_denoise_start_key_in_url])
|
|
|
5634 |
|
5635 |
|
5636 |
|
5637 |
+
if refining_steps_option_key_in_url in url_object:
|
5638 |
+
|
5639 |
+
refining_steps_option_in_url = url_object[refiner_key_in_url].lower()
|
5640 |
+
|
5641 |
+
refining_steps_option_in_url_formatted = False
|
5642 |
+
|
5643 |
+
if (
|
5644 |
+
(refining_steps_option_in_url == "1") or
|
5645 |
+
(refining_steps_option_in_url == "y") or
|
5646 |
+
(refining_steps_option_in_url == "yes") or
|
5647 |
+
(refining_steps_option_in_url == "true")
|
5648 |
+
):
|
5649 |
+
|
5650 |
+
refining_steps_option_in_url_formatted = True
|
5651 |
+
|
5652 |
+
field_object.update({refining_steps_option_for_older_configuration_field: refining_steps_option_in_url_formatted})
|
5653 |
+
|
5654 |
+
|
5655 |
|
5656 |
if refining_steps_key_in_url in url_object:
|
5657 |
|
|
|
5663 |
|
5664 |
|
5665 |
|
|
|
|
|
5666 |
if use_denoising_start_in_base_model_when_using_refiner_key_in_url in url_object:
|
5667 |
|
5668 |
use_denoising_start_in_base_model_when_using_refiner_in_url = url_object[use_denoising_start_in_base_model_when_using_refiner_key_in_url].lower()
|
|
|
5682 |
|
5683 |
|
5684 |
|
|
|
|
|
5685 |
if base_model_output_to_refiner_is_in_latent_space_key_in_url in url_object:
|
5686 |
|
5687 |
base_model_output_to_refiner_is_in_latent_space_in_url = url_object[base_model_output_to_refiner_is_in_latent_space_key_in_url].lower()
|
|
|
5701 |
|
5702 |
|
5703 |
|
|
|
|
|
5704 |
if upscaler_key_in_url in url_object:
|
5705 |
|
5706 |
upscaler_in_url = url_object[upscaler_key_in_url].lower()
|
|
|
5720 |
|
5721 |
|
5722 |
|
|
|
|
|
5723 |
if upscaling_steps_key_in_url in url_object:
|
5724 |
|
5725 |
upscaling_steps_in_url = str(url_object[upscaling_steps_key_in_url])
|
|
|
5730 |
|
5731 |
|
5732 |
|
5733 |
+
if special_theme_key_in_url in url_object:
|
5734 |
+
|
5735 |
+
special_theme_in_url = str(url_object[special_theme_key_in_url])
|
5736 |
+
|
5737 |
+
if theme_valid(special_theme_in_url):
|
5738 |
+
|
5739 |
+
special_theme_value = False
|
5740 |
+
if (special_theme_in_url == "dark"):
|
5741 |
+
special_theme_value = True
|
5742 |
+
|
5743 |
+
field_object.update({dark_theme_field: special_theme_value})
|
5744 |
+
|
5745 |
+
elif theme_key_in_url in url_object:
|
5746 |
+
|
5747 |
+
theme_in_url = str(url_object[theme_key_in_url])
|
5748 |
+
|
5749 |
+
if theme_valid(theme_in_url):
|
5750 |
+
|
5751 |
+
theme_value = False
|
5752 |
+
if (theme_in_url == "dark"):
|
5753 |
+
theme_value = True
|
5754 |
+
|
5755 |
+
field_object.update({dark_theme_field: theme_value})
|
5756 |
+
|
5757 |
+
|
5758 |
+
|
5759 |
generate_image_button_update = gr.Button(
|
5760 |
interactive = True
|
5761 |
)
|
|
|
5858 |
.generating {border: none !important;}
|
5859 |
|
5860 |
/* Hide footer */
|
5861 |
+
/*
|
5862 |
footer
|
5863 |
{
|
5864 |
display: none !important;
|
5865 |
}
|
5866 |
+
*/
|
5867 |
/* Dropdowns */
|
5868 |
|
5869 |
.sp_dropdown ul
|
|
|
5913 |
width: 100%;
|
5914 |
height: 60px;
|
5915 |
max-height: 80%;
|
5916 |
+
border: 1px solid rgb(209, 209, 209);
|
5917 |
}
|
5918 |
|
5919 |
.textbox_vertical_scroll textarea::-webkit-scrollbar-thumb:hover
|
5920 |
{
|
5921 |
background-color: rgb(184, 184, 184);
|
5922 |
+
border-color: rgb(179, 179, 179);
|
5923 |
}
|
5924 |
|
5925 |
.image_scaling button.image-button img
|
|
|
5927 |
object-fit: scale-down;
|
5928 |
}
|
5929 |
|
5930 |
+
body.dark .textbox_vertical_scroll textarea::-webkit-scrollbar-track
|
5931 |
+
{
|
5932 |
+
background-color: rgb(66, 66, 66) !important;
|
5933 |
+
}
|
5934 |
+
|
5935 |
+
body.dark .textbox_vertical_scroll textarea::-webkit-scrollbar-track:hover
|
5936 |
+
{
|
5937 |
+
background-color: rgb(63, 63, 63) !important;
|
5938 |
+
}
|
5939 |
+
|
5940 |
+
body.dark .textbox_vertical_scroll textarea::-webkit-scrollbar-thumb
|
5941 |
+
{
|
5942 |
+
background-color: rgb(104, 104, 104) !important;
|
5943 |
+
border-color: rgb(94, 94, 94) !important;
|
5944 |
+
}
|
5945 |
+
|
5946 |
+
body.dark .textbox_vertical_scroll textarea::-webkit-scrollbar-thumb:hover
|
5947 |
+
{
|
5948 |
+
background-color: rgb(123, 123, 123) !important;
|
5949 |
+
}
|
5950 |
+
|
5951 |
/* Size of image for image preview */
|
5952 |
|
5953 |
#image_preview_id div.image-container
|
|
|
5965 |
margin: 0 auto;
|
5966 |
}
|
5967 |
|
5968 |
+
/* Refining steps in options section */
|
5969 |
+
|
5970 |
+
#refining_steps_for_older_configuration_field_row_id
|
5971 |
+
{
|
5972 |
+
max-width: 800px;
|
5973 |
+
margin: 0 auto;
|
5974 |
+
}
|
5975 |
+
|
5976 |
+
#refining_steps_for_older_configuration_field_id
|
5977 |
+
{
|
5978 |
+
width: 300px;
|
5979 |
+
}
|
5980 |
+
|
5981 |
+
#refining_steps_message_for_older_configuration_field_id
|
5982 |
+
{
|
5983 |
+
}
|
5984 |
+
|
5985 |
+
.html_field_style_class
|
5986 |
+
{
|
5987 |
+
background-color: var(--block-background-fill);
|
5988 |
+
}
|
5989 |
+
|
5990 |
"""
|
5991 |
|
5992 |
with gr.Blocks(
|
|
|
6017 |
|
6018 |
user_id_state = gr.State(0)
|
6019 |
image_generation_id_state = gr.State("")
|
6020 |
+
|
6021 |
+
page_url_hidden_field = gr.Textbox(
|
6022 |
+
visible = False,
|
6023 |
+
interactive = False
|
6024 |
+
)
|
6025 |
|
6026 |
gr.Markdown(opening_html)
|
6027 |
|
|
|
6089 |
):
|
6090 |
|
6091 |
negative_prompt_for_sdxl_turbo_field = gr.HTML(
|
6092 |
+
value = "<div style=\"padding: 10px; text-align: center;\">Negative prompt is not used for SDXL Turbo.</div>",
|
6093 |
+
elem_classes = "html_field_style_class"
|
6094 |
)
|
6095 |
|
6096 |
with gr.Group(
|
|
|
6149 |
|
6150 |
|
6151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6152 |
with gr.Group(
|
6153 |
visible = upscaler_group_visible
|
6154 |
):
|
|
|
6342 |
):
|
6343 |
|
6344 |
guidance_scale_for_sdxl_turbo_field = gr.HTML(
|
6345 |
+
value = "<div style=\"padding: 10px; text-align: center;\">Guidance scale is not used for SDXL Turbo.</div>",
|
6346 |
+
elem_classes = "html_field_style_class"
|
6347 |
)
|
6348 |
|
6349 |
with gr.Row():
|
|
|
6440 |
|
6441 |
output_image_preview_field_every_value = None
|
6442 |
|
6443 |
+
if use_image_preview == 1:
|
6444 |
|
6445 |
output_image_preview_field_every_value = load_image_preview_frequency_in_seconds
|
6446 |
|
|
|
6540 |
open = True
|
6541 |
):
|
6542 |
|
6543 |
+
with gr.Row():
|
6544 |
+
|
6545 |
+
dark_theme_field = gr.Checkbox(
|
6546 |
+
label = "Use dark theme (?theme=dark)",
|
6547 |
+
value = default_dark_theme_is_selected,
|
6548 |
+
interactive = True,
|
6549 |
+
container = False,
|
6550 |
+
elem_classes = "sp_checkbox"
|
6551 |
+
)
|
6552 |
+
|
6553 |
with gr.Row():
|
6554 |
|
6555 |
add_seed_into_pipe_field = gr.Checkbox(
|
|
|
6563 |
with gr.Row():
|
6564 |
|
6565 |
use_torch_manual_seed_but_do_not_add_to_pipe_field = gr.Checkbox(
|
6566 |
+
label = "Use torch.manual_seed, but don't explicitly add it as a generator during generation (ignored if \"Add seed to generation\" is checked. This is to provide compatibility with PhotoReal site)",
|
6567 |
value = default_use_torch_manual_seed_but_do_not_add_to_pipe_is_selected,
|
6568 |
interactive = True,
|
6569 |
container = False,
|
|
|
6598 |
elem_classes = "sp_checkbox"
|
6599 |
)
|
6600 |
|
6601 |
+
with gr.Row():
|
6602 |
+
|
6603 |
+
refining_steps_option_for_older_configuration_field = gr.Checkbox(
|
6604 |
+
label = "For refiner, choose number of steps that denoise start % applies to.",
|
6605 |
+
value = False,
|
6606 |
+
interactive = True,
|
6607 |
+
container = False,
|
6608 |
+
elem_classes = "sp_checkbox"
|
6609 |
+
)
|
6610 |
+
|
6611 |
+
with gr.Row(
|
6612 |
+
elem_id = "refining_steps_for_older_configuration_field_row_id",
|
6613 |
+
visible = False
|
6614 |
+
) as refining_steps_for_older_configuration_field_row:
|
6615 |
+
|
6616 |
+
refining_steps_for_older_configuration_field = gr.Slider(
|
6617 |
+
elem_id = "refining_steps_for_older_configuration_field_id",
|
6618 |
+
label = "Number of steps in refiner that \"denoise start %\" applies to:",
|
6619 |
+
minimum = 1,
|
6620 |
+
maximum = maximum_refining_steps_for_online_config_field,
|
6621 |
+
value = default_refining_steps_for_online_config_field,
|
6622 |
+
step = 1
|
6623 |
+
)
|
6624 |
+
|
6625 |
+
refining_steps_message_for_older_configuration_field = gr.HTML(
|
6626 |
+
elem_id = "refining_steps_message_for_older_configuration_field_id",
|
6627 |
+
value = "<div style=\"padding: 10px;\">This does not define the actual number of refining steps. By default in our app, the number of steps used for the base model generation applies to the refiner. This option allows you to use a different number. If you set 100 steps here, and a \"denoise start %\" of \"0.75\", 25 steps in the refiner would occur after the base model processing has ended.</div>",
|
6628 |
+
elem_classes = "html_field_style_class"
|
6629 |
+
)
|
6630 |
+
|
6631 |
|
6632 |
|
6633 |
if len(ending_html) > 0:
|
|
|
6720 |
var baseModelNamesObject = {0};
|
6721 |
var modelConfigurationNamesObject = {1};
|
6722 |
var baseModelArray = {2};
|
6723 |
+
var baseModelsNotSupportingDenoisingEndForBaseModelObject = {3}
|
6724 |
+
var allowOtherModelVersions = {4};
|
|
|
6725 |
|
6726 |
var baseModelFullNamesToBaseModelIdConversion = {{}};
|
6727 |
Object.keys(baseModelNamesObject).forEach(key => {{
|
|
|
6818 |
document.getElementById("guidance_scale_field_row_id").style.display = guidanceScaleFieldDisplay;
|
6819 |
document.getElementById("guidance_scale_for_sdxl_turbo_field_row_id").style.display = guidanceScaleForSdxlTurboFieldDisplay;
|
6820 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6821 |
var refiningUseDenoisingStartInBaseModelWhenUsingRefinerFieldDisplay = "block";
|
6822 |
|
6823 |
if (Object.keys(baseModelsNotSupportingDenoisingEndForBaseModelObject).includes(baseModelFieldValue)) {{
|
|
|
6827 |
}}
|
6828 |
|
6829 |
document.getElementById("refining_use_denoising_start_in_base_model_when_using_refiner_field_row_id").style.display = refiningUseDenoisingStartInBaseModelWhenUsingRefinerFieldDisplay;
|
|
|
6830 |
|
6831 |
}}
|
6832 |
|
|
|
6836 |
base_model_names_object,
|
6837 |
model_configuration_names_object,
|
6838 |
base_model_array,
|
|
|
6839 |
base_models_not_supporting_denoising_end_for_base_model_object,
|
6840 |
allow_other_model_versions
|
6841 |
)
|
|
|
6923 |
|
6924 |
|
6925 |
create_image_function_inputs = [
|
|
|
6926 |
base_model_field,
|
|
|
6927 |
prompt_field,
|
6928 |
negative_prompt_field,
|
|
|
6929 |
scheduler_field,
|
|
|
6930 |
image_width_field,
|
6931 |
image_height_field,
|
6932 |
guidance_scale_field,
|
|
|
6935 |
seed_field,
|
6936 |
add_seed_into_pipe_field,
|
6937 |
use_torch_manual_seed_but_do_not_add_to_pipe_field,
|
|
|
6938 |
refining_selection_field,
|
6939 |
refining_denoise_start_field,
|
6940 |
refining_use_denoising_start_in_base_model_when_using_refiner_field,
|
6941 |
refining_base_model_output_to_refiner_is_in_latent_space_field,
|
6942 |
+
refining_steps_option_for_older_configuration_field,
|
6943 |
refining_steps_for_older_configuration_field,
|
|
|
6944 |
upscaling_selection_field,
|
6945 |
upscaling_num_inference_steps_field,
|
|
|
6946 |
image_gallery_array_state,
|
6947 |
prompt_information_array_state,
|
6948 |
last_model_configuration_name_selected_state,
|
|
|
6951 |
stored_pipe_state,
|
6952 |
stored_refiner_state,
|
6953 |
stored_upscaler_state,
|
|
|
6954 |
save_base_image_when_using_refiner_field,
|
6955 |
save_refined_image_when_using_upscaler_field,
|
|
|
6956 |
user_id_state,
|
6957 |
+
image_generation_id_state
|
|
|
|
|
6958 |
]
|
6959 |
|
6960 |
for this_model_configuration_dropdown_field in model_configuration_dropdown_fields_array:
|
|
|
7136 |
|
7137 |
document.querySelectorAll(".textbox_vertical_scroll textarea").forEach(e => e.classList.remove("scroll-hide"));
|
7138 |
|
7139 |
+
var urlParams = new URLSearchParams(window.location.search);
|
7140 |
+
var theme = "";
|
7141 |
+
|
7142 |
+
if (typeof urlParams.get("__theme") === "string") {{
|
7143 |
+
theme = (urlParams.get("__theme")).toLowerCase();
|
7144 |
+
}}
|
7145 |
+
else if (typeof urlParams.get("theme") === "string") {{
|
7146 |
+
theme = (urlParams.get("theme")).toLowerCase();
|
7147 |
+
}}
|
7148 |
+
|
7149 |
+
var use_dark = 0;
|
7150 |
+
if (theme === "dark") {{
|
7151 |
+
use_dark = 1;
|
7152 |
+
|
7153 |
+
}}
|
7154 |
+
else if (theme === "light") {{
|
7155 |
+
use_dark = 0;
|
7156 |
+
}}
|
7157 |
+
else {{
|
7158 |
+
|
7159 |
+
if (
|
7160 |
+
window.matchMedia &&
|
7161 |
+
window.matchMedia("(prefers-color-scheme: dark)").matches
|
7162 |
+
) {{
|
7163 |
+
use_dark = 1;
|
7164 |
+
}}
|
7165 |
+
|
7166 |
+
}}
|
7167 |
+
|
7168 |
+
if (use_dark) {{
|
7169 |
+
document.getElementsByTagName("body")[0].classList.add("dark");
|
7170 |
+
}}
|
7171 |
+
|
7172 |
}}
|
7173 |
|
7174 |
""".format(
|
|
|
7198 |
|
7199 |
sd_interface_load_outputs = create_image_function_inputs + [
|
7200 |
initial_model_configuration_name_selected_state,
|
7201 |
+
generate_image_button,
|
7202 |
+
dark_theme_field,
|
7203 |
+
page_url_hidden_field
|
7204 |
]
|
7205 |
|
7206 |
|
7207 |
|
7208 |
every_value_in_seconds_for_image_preview = None
|
7209 |
|
7210 |
+
if use_image_preview == 1:
|
7211 |
|
7212 |
every_value_in_seconds_for_image_preview = load_image_preview_frequency_in_seconds
|
7213 |
|
|
|
7219 |
outputs = sd_interface_load_outputs,
|
7220 |
show_progress = "hidden",
|
7221 |
queue = False,
|
|
|
7222 |
js = script_on_load_js
|
7223 |
).then(
|
7224 |
fn = set_base_model_and_model_configuration_from_query_params,
|
|
|
7226 |
outputs = model_base_model_and_model_configuration_outputs,
|
7227 |
show_progress = "hidden",
|
7228 |
queue = False
|
|
|
|
|
|
|
|
|
|
|
|
|
7229 |
).then(
|
7230 |
fn = load_image_preview,
|
7231 |
inputs = [
|
|
|
7241 |
|
7242 |
|
7243 |
|
7244 |
+
dark_theme_function_js = """
|
7245 |
+
|
7246 |
+
async (
|
7247 |
+
dark_theme_value
|
7248 |
+
) => {{
|
7249 |
+
"use strict";
|
7250 |
+
|
7251 |
+
if (dark_theme_value) {{
|
7252 |
+
document.getElementsByTagName("body")[0].classList.add("dark");
|
7253 |
+
}}
|
7254 |
+
else {{
|
7255 |
+
document.getElementsByTagName("body")[0].classList.remove("dark");
|
7256 |
+
}}
|
7257 |
+
|
7258 |
+
}}
|
7259 |
+
|
7260 |
+
""".format()
|
7261 |
+
|
7262 |
+
|
7263 |
+
|
7264 |
+
dark_theme_field_change_event = dark_theme_field.change(
|
7265 |
+
fn = None,
|
7266 |
+
inputs = [
|
7267 |
+
dark_theme_field
|
7268 |
+
],
|
7269 |
+
outputs = None,
|
7270 |
+
js = dark_theme_function_js
|
7271 |
+
)
|
7272 |
+
|
7273 |
+
|
7274 |
+
|
7275 |
+
with gr.Group():
|
7276 |
+
|
7277 |
+
with gr.Row():
|
7278 |
+
|
7279 |
+
generate_link_button = gr.Button(
|
7280 |
+
value = "Create link with your selections",
|
7281 |
+
variant = "secondary"
|
7282 |
+
)
|
7283 |
+
|
7284 |
+
with gr.Row():
|
7285 |
+
|
7286 |
+
generate_link_field = gr.Textbox(
|
7287 |
+
visible = False,
|
7288 |
+
label = "The link below contains the details entered above. If you share this link, someone would need to generate the image in order to view it. The image is not saved.",
|
7289 |
+
value = "",
|
7290 |
+
show_copy_button = True,
|
7291 |
+
lines = 2,
|
7292 |
+
max_lines = 4,
|
7293 |
+
autoscroll = False,
|
7294 |
+
interactive = False,
|
7295 |
+
container = True,
|
7296 |
+
elem_classes = "textbox_vertical_scroll"
|
7297 |
+
)
|
7298 |
+
|
7299 |
+
|
7300 |
+
|
7301 |
+
generate_link_inputs = [
|
7302 |
+
page_url_hidden_field,
|
7303 |
+
generate_link_field
|
7304 |
+
] + create_image_function_inputs
|
7305 |
+
|
7306 |
+
generate_link_button_click_event = generate_link_button.click(
|
7307 |
+
fn = generate_link_textbox_function,
|
7308 |
+
inputs = generate_link_inputs,
|
7309 |
+
outputs = [
|
7310 |
+
generate_link_field
|
7311 |
+
],
|
7312 |
+
show_progress = "hidden",
|
7313 |
+
queue = False
|
7314 |
+
)
|
7315 |
+
|
7316 |
+
|
7317 |
+
|
7318 |
+
choose_number_of_steps_that_denoise_start_applies_to_function_js = """
|
7319 |
+
|
7320 |
+
async (
|
7321 |
+
chooseNumberOfStepsThatDenoiseStartAppliesToValue
|
7322 |
+
) => {{
|
7323 |
+
"use strict";
|
7324 |
+
|
7325 |
+
var refiningStepsForOlderConfigurationFieldRowDisplay = "none";
|
7326 |
+
if (chooseNumberOfStepsThatDenoiseStartAppliesToValue) {{
|
7327 |
+
refiningStepsForOlderConfigurationFieldRowDisplay = "block";
|
7328 |
+
}}
|
7329 |
+
document.getElementById("refining_steps_for_older_configuration_field_row_id").style.display = refiningStepsForOlderConfigurationFieldRowDisplay;
|
7330 |
+
|
7331 |
+
}}
|
7332 |
+
|
7333 |
+
""".format()
|
7334 |
+
|
7335 |
+
|
7336 |
+
|
7337 |
+
refining_steps_option_for_older_configuration_field_change_event = refining_steps_option_for_older_configuration_field.change(
|
7338 |
+
fn = None,
|
7339 |
+
inputs = [
|
7340 |
+
refining_steps_option_for_older_configuration_field
|
7341 |
+
],
|
7342 |
+
outputs = None,
|
7343 |
+
js = choose_number_of_steps_that_denoise_start_applies_to_function_js
|
7344 |
+
)
|
7345 |
+
|
7346 |
+
|
7347 |
+
|
7348 |
sd_interface.queue(
|
7349 |
max_size = max_queue_size
|
7350 |
)
|
|
|
7357 |
|
7358 |
inbrowser = True
|
7359 |
|
7360 |
+
|
7361 |
+
|
7362 |
+
if __name__ == "__main__":
|
7363 |
+
|
7364 |
+
# queue needed for preview
|
7365 |
+
sd_interface.queue().launch(
|
7366 |
+
|
7367 |
+
#sd_interface.launch(
|
7368 |
+
inbrowser = inbrowser,
|
7369 |
+
share = None,
|
7370 |
+
show_api = False,
|
7371 |
+
quiet = True,
|
7372 |
+
show_error = True,
|
7373 |
+
state_session_capacity = 10000,
|
7374 |
+
max_threads = 40
|
7375 |
+
)
|