use 0.0 for the configured default image size limit

This prevents the current default value from being saved into the
config files, in case we later decide to adopt a different value.
This commit is contained in:
Wagner Bruna 2025-06-08 18:37:46 -03:00
parent a95e1ecf9c
commit 2a21635535

View file

@ -48,6 +48,7 @@ default_ttsmaxlen = 4096
default_visionmaxres = 1024 default_visionmaxres = 1024
net_save_slots = 10 net_save_slots = 10
savestate_limit = 3 #3 savestate slots savestate_limit = 3 #3 savestate slots
default_sdsizelimit = 0.7 # megapixels
# abuse prevention # abuse prevention
stop_token_max = 256 stop_token_max = 256
@ -1612,6 +1613,7 @@ def sd_apply_resolution_limits(width, height, sdclamped, sdsizelimit):
else: else:
small = small_up small = small_up
sdsizelimit = sdsizelimit or default_sdsizelimit
sizelimit = max(min(int(sdsizelimit * 1000000), 2048*2048), 64*64) sizelimit = max(min(int(sdsizelimit * 1000000), 2048*2048), 64*64)
if small * big > sizelimit: if small * big > sizelimit:
print(f"\nImgGen: Scaling down image to stay below {sdsizelimit}MP.") print(f"\nImgGen: Scaling down image to stay below {sdsizelimit}MP.")
@ -4315,7 +4317,7 @@ def show_gui():
sd_vaeauto_var = ctk.IntVar(value=0) sd_vaeauto_var = ctk.IntVar(value=0)
sd_notile_var = ctk.IntVar(value=0) sd_notile_var = ctk.IntVar(value=0)
sd_clamped_var = ctk.StringVar(value="0") sd_clamped_var = ctk.StringVar(value="0")
sd_size_limit_var = ctk.StringVar(value="0.7") sd_size_limit_var = ctk.StringVar(value="0.0")
sd_threads_var = ctk.StringVar(value=str(default_threads)) sd_threads_var = ctk.StringVar(value=str(default_threads))
sd_quant_var = ctk.IntVar(value=0) sd_quant_var = ctk.IntVar(value=0)
@ -5010,7 +5012,7 @@ def show_gui():
makelabelentry(images_tab, "Clamped Mode (Limit Resolution):", sd_clamped_var, row, 50, padx=290,singleline=True,tooltip="Limit generation steps and resolution settings for shared use.\nSet to 0 to disable, otherwise value is the size limit (min 512px).") makelabelentry(images_tab, "Clamped Mode (Limit Resolution):", sd_clamped_var, row, 50, padx=290,singleline=True,tooltip="Limit generation steps and resolution settings for shared use.\nSet to 0 to disable, otherwise value is the size limit (min 512px).")
row += 2 row += 2
makelabelentry(images_tab, "Size Limit:", sd_size_limit_var, row, 50, padx=290,singleline=True,tooltip="Image size limit, in megapixels. Protects against reaching backend limits, which could cause a server crash.") makelabelentry(images_tab, "Size Limit:", sd_size_limit_var, row, 50, padx=290,singleline=True,tooltip=f"Image size limit, in megapixels. Protects against reaching backend limits,\nwhich could cause a server crash. Leave at 0.0 for the default value ({default_sdsizelimit}MP)")
row += 2 row += 2
makelabelentry(images_tab, "Image Threads:" , sd_threads_var, row, 50,padx=290,singleline=True,tooltip="How many threads to use during image generation.\nIf left blank, uses same value as threads.") makelabelentry(images_tab, "Image Threads:" , sd_threads_var, row, 50,padx=290,singleline=True,tooltip="How many threads to use during image generation.\nIf left blank, uses same value as threads.")
@ -5280,7 +5282,7 @@ def show_gui():
args.sdthreads = (0 if sd_threads_var.get()=="" else int(sd_threads_var.get())) args.sdthreads = (0 if sd_threads_var.get()=="" else int(sd_threads_var.get()))
args.sdclamped = (0 if int(sd_clamped_var.get())<=0 else int(sd_clamped_var.get())) args.sdclamped = (0 if int(sd_clamped_var.get())<=0 else int(sd_clamped_var.get()))
args.sdsizelimit = (float(sd_size_limit_var.get()) if sd_size_limit_var.get()!="" else 0.7) args.sdsizelimit = (float(sd_size_limit_var.get()) if sd_size_limit_var.get()!="" else 0.0)
args.sdnotile = (True if sd_notile_var.get()==1 else False) args.sdnotile = (True if sd_notile_var.get()==1 else False)
if sd_vaeauto_var.get()==1: if sd_vaeauto_var.get()==1:
args.sdvaeauto = True args.sdvaeauto = True
@ -5487,7 +5489,7 @@ def show_gui():
sd_model_var.set(dict["sdmodel"] if ("sdmodel" in dict and dict["sdmodel"]) else "") sd_model_var.set(dict["sdmodel"] if ("sdmodel" in dict and dict["sdmodel"]) else "")
sd_clamped_var.set(int(dict["sdclamped"]) if ("sdclamped" in dict and dict["sdclamped"]) else 0) sd_clamped_var.set(int(dict["sdclamped"]) if ("sdclamped" in dict and dict["sdclamped"]) else 0)
sd_size_limit_var.set(int(dict["sdsizelimit"]) if ("sdsizelimit" in dict and dict["sdsizelimit"]) else 0.7) sd_size_limit_var.set(int(dict["sdsizelimit"]) if ("sdsizelimit" in dict and dict["sdsizelimit"]) else 0.0)
sd_threads_var.set(str(dict["sdthreads"]) if ("sdthreads" in dict and dict["sdthreads"]) else str(default_threads)) sd_threads_var.set(str(dict["sdthreads"]) if ("sdthreads" in dict and dict["sdthreads"]) else str(default_threads))
sd_quant_var.set(1 if ("sdquant" in dict and dict["sdquant"]) else 0) sd_quant_var.set(1 if ("sdquant" in dict and dict["sdquant"]) else 0)
sd_vae_var.set(dict["sdvae"] if ("sdvae" in dict and dict["sdvae"]) else "") sd_vae_var.set(dict["sdvae"] if ("sdvae" in dict and dict["sdvae"]) else "")
@ -7222,7 +7224,7 @@ if __name__ == '__main__':
sdparsergroup = parser.add_argument_group('Image Generation Commands') sdparsergroup = parser.add_argument_group('Image Generation Commands')
sdparsergroup.add_argument("--sdmodel", metavar=('[filename]'), help="Specify an image generation safetensors or gguf model to enable image generation.", default="") sdparsergroup.add_argument("--sdmodel", metavar=('[filename]'), help="Specify an image generation safetensors or gguf model to enable image generation.", default="")
sdparsergroup.add_argument("--sdthreads", metavar=('[threads]'), help="Use a different number of threads for image generation if specified. Otherwise, has the same value as --threads.", type=int, default=0) sdparsergroup.add_argument("--sdthreads", metavar=('[threads]'), help="Use a different number of threads for image generation if specified. Otherwise, has the same value as --threads.", type=int, default=0)
sdparsergroup.add_argument("--sdsizelimit", metavar=('[limit]'), help="If specified, limit image size to this value, in megapixels (eg. 0.41 would allow images up to 512x768 or 640x640). Values above 0.7MP are usually not recommended due to backend limitations, and may cause a server crash.", type=float, default=0.7) sdparsergroup.add_argument("--sdsizelimit", metavar=('[limit]'), help=f"If specified, limit image size to this value, in megapixels (eg. 0.41 would allow images up to 512x768 or 640x640). Values above {default_sdsizelimit}MP (the default) are usually not recommended due to backend limitations, and may cause a server crash. If 0, use the default value.", type=float, default=0.0)
sdparsergroup.add_argument("--sdclamped", metavar=('[maxres]'), help="If specified, limit generation steps and resolution settings for shared use. Accepts an extra optional parameter that indicates maximum resolution (eg. 768 clamps to 768x768, min 512px, disabled if 0).", nargs='?', const=512, type=int, default=0) sdparsergroup.add_argument("--sdclamped", metavar=('[maxres]'), help="If specified, limit generation steps and resolution settings for shared use. Accepts an extra optional parameter that indicates maximum resolution (eg. 768 clamps to 768x768, min 512px, disabled if 0).", nargs='?', const=512, type=int, default=0)
sdparsergroup.add_argument("--sdt5xxl", metavar=('[filename]'), help="Specify a T5-XXL safetensors model for use in SD3 or Flux. Leave blank if prebaked or unused.", default="") sdparsergroup.add_argument("--sdt5xxl", metavar=('[filename]'), help="Specify a T5-XXL safetensors model for use in SD3 or Flux. Leave blank if prebaked or unused.", default="")
sdparsergroup.add_argument("--sdclipl", metavar=('[filename]'), help="Specify a Clip-L safetensors model for use in SD3 or Flux. Leave blank if prebaked or unused.", default="") sdparsergroup.add_argument("--sdclipl", metavar=('[filename]'), help="Specify a Clip-L safetensors model for use in SD3 or Flux. Leave blank if prebaked or unused.", default="")