From f1b27ee6d059d107cedbab804b5c29d6455fa39a Mon Sep 17 00:00:00 2001 From: Aptronymist <108482020+Aptronymist@users.noreply.github.com> Date: Wed, 30 Aug 2023 13:13:48 -0400 Subject: [PATCH] preliminary settings reorg moved around some options regarding images, consolidated image processing, post processing, and upscaling --- modules/shared.py | 80 ++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/modules/shared.py b/modules/shared.py index fceb7c0e1..80101b839 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -447,51 +447,51 @@ options_templates.update(options_section(('system-paths', "System Paths"), { options_templates.update(options_section(('saving-images', "Image Options"), { "samples_save": OptionInfo(True, "Always save all generated images"), "samples_format": OptionInfo('jpg', 'File format for generated images', gr.Dropdown, lambda: {"choices": ["jpg", "png", "webp", "tiff", "jp2"]}), + "jpeg_quality": OptionInfo(90, "Quality for saved jpeg images", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}), + "img_max_size_mp": OptionInfo(250, "Maximum allowed image size in megapixels", gr.Number), + "webp_lossless": OptionInfo(False, "Use lossless compression for webp images"), + "save_selected_only": OptionInfo(True, "When using 'Save' button, only save a single selected image"), + "samples_save_zip": OptionInfo(True, "Create zip archive when downloading multiple images"), + "image_sep_metadata": OptionInfo("

Metadata/Logging

", "", gr.HTML), "image_metadata": OptionInfo(True, "Include metadata in saved images"), + "save_txt": OptionInfo(False, "Create text file next to every image with generation parameters"), + "save_log_fn": OptionInfo("", "Create JSON log file for each saved image", component_args=hide_dirs), "image_watermark_enabled": OptionInfo(False, "Include watermark in saved images"), "image_watermark": OptionInfo('', "Image watermark string"), - "samples_filename_pattern": OptionInfo("[seq]-[prompt_words]", "Images filename pattern", component_args=hide_dirs), - "directories_max_prompt_words": OptionInfo(8, "Max prompt words for [prompt_words] pattern", gr.Slider, {"minimum": 1, "maximum": 99, "step": 1, **hide_dirs}), - "save_images_add_number": OptionInfo(True, "Add number to filename when saving", component_args=hide_dirs), - "samples_save_zip": OptionInfo(True, "Create zip archive when downloading multiple images"), + "image_sep_grid": OptionInfo("

Grid Options

", "", gr.HTML), "grid_save": OptionInfo(True, "Always save all generated image grids"), "grid_format": OptionInfo('jpg', 'File format for grids', gr.Dropdown, lambda: {"choices": ["jpg", "png", "webp", "tiff", "jp2"]}), + "n_rows": OptionInfo(-1, "Grid row count", gr.Slider, {"minimum": -1, "maximum": 16, "step": 1}), "grid_extended_filename": OptionInfo(True, "Add extended info (seed, prompt) to filename when saving grid"), "grid_only_if_multiple": OptionInfo(True, "Do not save grids consisting of one picture"), "grid_prevent_empty_spots": OptionInfo(True, "Prevent empty spots in grid (when set to autodetect)"), - "n_rows": OptionInfo(-1, "Grid row count", gr.Slider, {"minimum": -1, "maximum": 16, "step": 1}), - "save_txt": OptionInfo(False, "Create text file next to every image with generation parameters"), - "save_log_fn": OptionInfo("", "Create JSON log file for each saved image", component_args=hide_dirs), + "save_sep_options": OptionInfo("

Intermediate Image Saving

", "", gr.HTML), + "save_init_img": OptionInfo(True, "Save copy of img2img init images (helps track workflow)"), "save_images_before_highres_fix": OptionInfo(False, "Save copy of image before applying highres fix"), "save_images_before_refiner": OptionInfo(False, "Save copy of image before running refiner"), "save_images_before_face_restoration": OptionInfo(False, "Save copy of image before doing face restoration"), "save_images_before_color_correction": OptionInfo(False, "Save copy of image before applying color correction"), "save_mask": OptionInfo(False, "Save copy of the inpainting greyscale mask"), "save_mask_composite": OptionInfo(False, "Save copy of inpainting masked composite"), - "save_init_img": OptionInfo(False, "Save copy of processing init images"), - "jpeg_quality": OptionInfo(90, "Quality for saved jpeg images", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}), - "webp_lossless": OptionInfo(False, "Use lossless compression for webp images"), - "img_max_size_mp": OptionInfo(250, "Maximum allowed image size in megapixels", gr.Number), - "use_original_name_batch": OptionInfo(True, "Use original name for output filename during batch process"), - "use_upscaler_name_as_suffix": OptionInfo(True, "Use upscaler name as filename suffix in the extras tab"), - "save_selected_only": OptionInfo(True, "When using 'Save' button, only save a single selected image"), - "save_to_dirs": OptionInfo(False, "Save images to a subdirectory"), - "grid_save_to_dirs": OptionInfo(False, "Save grids to a subdirectory"), - "use_save_to_dirs_for_ui": OptionInfo(False, "Save images to a subdirectory when using Save button"), - "directories_filename_pattern": OptionInfo("[date]", "Directory name pattern", component_args=hide_dirs), + })) options_templates.update(options_section(('image-processing', "Image Processing"), { - "img2img_color_correction": OptionInfo(False, "Apply color correction to match original colors"), - "img2img_fix_steps": OptionInfo(False, "For image processing do exact number of steps as specified"), - "img2img_background_color": OptionInfo("#ffffff", "Image transparent color fill", ui_components.FormColorPicker, {}), - "inpainting_mask_weight": OptionInfo(1.0, "Inpainting conditioning mask strength", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), - "initial_noise_multiplier": OptionInfo(1.0, "Noise multiplier for image processing", gr.Slider, {"minimum": 0.1, "maximum": 1.5, "step": 0.01}), - "CLIP_stop_at_last_layers": OptionInfo(1, "Clip skip", gr.Slider, {"minimum": 1, "maximum": 8, "step": 1, "visible": False}), + })) -options_templates.update(options_section(('saving-paths', "Image Paths"), { +options_templates.update(options_section(('saving-paths', "Image Naming & Paths"), { + "save_to_dirs": OptionInfo(False, "Save images to a subdirectory"), + "grid_save_to_dirs": OptionInfo(False, "Save grids to a subdirectory"), + "use_save_to_dirs_for_ui": OptionInfo(False, "Save images to a subdirectory when using Save button"), + "grid_sep_options": OptionInfo("

Naming

", "", gr.HTML), + "save_images_add_number": OptionInfo(True, "Add number to filename when saving", component_args=hide_dirs), + "directories_max_prompt_words": OptionInfo(8, "Max prompt words for [prompt_words] pattern", gr.Slider, {"minimum": 1, "maximum": 99, "step": 1, **hide_dirs}), + "use_original_name_batch": OptionInfo(True, "Use original name for output filename during batch process"), + "use_upscaler_name_as_suffix": OptionInfo(True, "Use upscaler name as filename suffix in the extras tab"), + "samples_filename_pattern": OptionInfo("[seq]-[prompt_words]", "Images filename pattern", component_args=hide_dirs), + "directories_filename_pattern": OptionInfo("[date]", "Directory name pattern", component_args=hide_dirs), "outdir_samples": OptionInfo("", "Output directory for images", component_args=hide_dirs), "outdir_txt2img_samples": OptionInfo("outputs/text", 'Output directory for txt2img images', component_args=hide_dirs), "outdir_img2img_samples": OptionInfo("outputs/image", 'Output directory for img2img images', component_args=hide_dirs), @@ -576,6 +576,24 @@ options_templates.update(options_section(('postprocessing', "Postprocessing"), { 'postprocessing_enable_in_main_ui': OptionInfo([], "Enable addtional postprocessing operations", ui_components.DropdownMulti, lambda: {"choices": [x.name for x in shared_items.postprocessing_scripts()]}), 'postprocessing_operation_order': OptionInfo([], "Postprocessing operation order", ui_components.DropdownMulti, lambda: {"choices": [x.name for x in shared_items.postprocessing_scripts()]}), 'upscaling_max_images_in_cache': OptionInfo(5, "Maximum number of images in upscaling cache", gr.Slider, {"minimum": 0, "maximum": 10, "step": 1}), + "postprocessing_sep_upscalers": OptionInfo("

Upscalers

", "", gr.HTML), + "face_restoration_model": OptionInfo("CodeFormer", "Face restoration model", gr.Radio, lambda: {"choices": [x.name() for x in face_restorers]}), + "code_former_weight": OptionInfo(0.2, "CodeFormer weight parameter", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01}), + "face_restoration_unload": OptionInfo(False, "Move face restoration model from VRAM into RAM after processing"), + "upscaler_for_img2img": OptionInfo("None", "Default upscaler for image resize operations", gr.Dropdown, lambda: {"choices": [x.name for x in sd_upscalers]}), + "realesrgan_enabled_models": OptionInfo(["R-ESRGAN 4x+", "R-ESRGAN 4x+ Anime6B"], "Real-ESRGAN available models", gr.CheckboxGroup, lambda: {"choices": shared_items.realesrgan_models_names()}), + "ESRGAN_tile": OptionInfo(192, "Tile size for ESRGAN upscalers", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}), + "ESRGAN_tile_overlap": OptionInfo(8, "Tile overlap in pixels for ESRGAN upscalers", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}), + "SCUNET_tile": OptionInfo(256, "Tile size for SCUNET upscalers", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}), + "SCUNET_tile_overlap": OptionInfo(8, "Tile overlap for SCUNET upscalers", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}), + "use_old_hires_fix_width_height": OptionInfo(False, "Hires fix uses width & height to set final resolution"), + "dont_fix_second_order_samplers_schedule": OptionInfo(False, "Do not fix prompt schedule for second order samplers"), + "img2img_color_correction": OptionInfo(False, "Apply color correction to match original colors"), + "img2img_fix_steps": OptionInfo(False, "For image processing do exact number of steps as specified"), + "img2img_background_color": OptionInfo("#ffffff", "Image transparent color fill", ui_components.FormColorPicker, {}), + "inpainting_mask_weight": OptionInfo(1.0, "Inpainting conditioning mask strength", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), + "initial_noise_multiplier": OptionInfo(1.0, "Noise multiplier for image processing", gr.Slider, {"minimum": 0.1, "maximum": 1.5, "step": 0.01}), + "CLIP_stop_at_last_layers": OptionInfo(1, "Clip skip", gr.Slider, {"minimum": 1, "maximum": 8, "step": 1, "visible": False}), })) options_templates.update(options_section(('training', "Training"), { @@ -609,17 +627,7 @@ options_templates.update(options_section(('interrogate', "Interrogate"), { })) options_templates.update(options_section(('upscaling', "Upscaling"), { - "face_restoration_model": OptionInfo("CodeFormer", "Face restoration model", gr.Radio, lambda: {"choices": [x.name() for x in face_restorers]}), - "code_former_weight": OptionInfo(0.2, "CodeFormer weight parameter", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01}), - "face_restoration_unload": OptionInfo(False, "Move face restoration model from VRAM into RAM after processing"), - "upscaler_for_img2img": OptionInfo("None", "Default upscaler for image resize operations", gr.Dropdown, lambda: {"choices": [x.name for x in sd_upscalers]}), - "realesrgan_enabled_models": OptionInfo(["R-ESRGAN 4x+", "R-ESRGAN 4x+ Anime6B"], "Real-ESRGAN available models", gr.CheckboxGroup, lambda: {"choices": shared_items.realesrgan_models_names()}), - "ESRGAN_tile": OptionInfo(192, "Tile size for ESRGAN upscalers", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}), - "ESRGAN_tile_overlap": OptionInfo(8, "Tile overlap in pixels for ESRGAN upscalers", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}), - "SCUNET_tile": OptionInfo(256, "Tile size for SCUNET upscalers", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}), - "SCUNET_tile_overlap": OptionInfo(8, "Tile overlap for SCUNET upscalers", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}), - "use_old_hires_fix_width_height": OptionInfo(False, "Hires fix uses width & height to set final resolution"), - "dont_fix_second_order_samplers_schedule": OptionInfo(False, "Do not fix prompt schedule for second order samplers"), + })) options_templates.update(options_section(('extra_networks', "Extra Networks"), {