diff --git a/CHANGELOG.md b/CHANGELOG.md index 56ed408..31f4344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### v2.3.1 - 2024 Nov.04 +- Implement **Range** Settings + ### v2.3.0 - 2024 Sep.20 - Refactor diff --git a/README.md b/README.md index fd14a40..3baac21 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ Hires upscale: 2, Hires steps: 16, Hires upscaler: 2xNomosUni_esrgan_multijpg @@ -228,6 +228,13 @@ Hires upscale: 1.5, Hires steps: 12, Hires upscaler: 2xNomosUni_esrgan_multijpg - **Reset:** Reset all `Basic` and `Advanced` parameters to the default values - **Randomize:** Randomize the `Brightness`, `Contrast`, `Saturation`, `R`, `G`, `B` parameters +## Settings +> The following settings are in the **Vectorscope CC** section under the **Stable Diffusion** category of the **Settings** tab + +- Append the parameters to the infotext +- Disable `do_not_save_to_config` to use the Webui **Defaults** functionality +- Set the `minimum` and `maximum` range for each parameter + ## Roadmap - [X] Extension Released! - [X] Add Support for **X/Y/Z Plot** @@ -323,7 +330,7 @@ In the **Script** `Dropdown` at the bottom, there is now a new **`High Dynamic R - This script will generate multiple images *("Brackets")* of varying brightness, then merge them into 1 HDR image - **(Recommended)** Use a deterministic sampler and high enough steps. `Euler` *(**not** `Euler a`)* works well in my experience -#### Settings +#### Options - **Brackets:** The numer of images to generate - **Gaps:** The brightness difference between each image - **Automatically Merge:** When enabled, this will merge the images using an `OpenCV` algorithm and save to the `HDR` folder in the `outputs` folder diff --git a/lib_cc/const.py b/lib_cc/const.py index 45f1766..29e9011 100644 --- a/lib_cc/const.py +++ b/lib_cc/const.py @@ -1,3 +1,4 @@ +from modules.shared import opts import random @@ -12,7 +13,37 @@ class Param: return round(random.uniform(self.minimum, self.maximum), 2) -Brightness = Param(-5.0, 5.0, 0.0) -Contrast = Param(-5.0, 5.0, 0.0) -Saturation = Param(0.25, 1.75, 1.0) -Color = Param(-4.0, 4.0, 0.0) +Brightness: Param = None +Contrast: Param = None +Saturation: Param = None +Color: Param = None + + +def init(): + global Brightness + Brightness = Param( + getattr(opts, "cc_brightness_min", -5.0), + getattr(opts, "cc_brightness_max", 5.0), + 0.0, + ) + + global Contrast + Contrast = Param( + getattr(opts, "cc_contrast_min", -5.0), + getattr(opts, "cc_contrast_max", 5.0), + 0.0, + ) + + global Saturation + Saturation = Param( + getattr(opts, "cc_saturation_min", 0.25), + getattr(opts, "cc_saturation_max", 1.75), + 1.0, + ) + + global Color + Color = Param( + getattr(opts, "cc_color_min", -4.0), + getattr(opts, "cc_color_max", 4.0), + 0.0, + ) diff --git a/lib_cc/settings.py b/lib_cc/settings.py index 6867f99..d50dd61 100644 --- a/lib_cc/settings.py +++ b/lib_cc/settings.py @@ -1,6 +1,7 @@ from modules.shared import OptionInfo, opts from modules import scripts from json import load, dump +from gradio import Slider import os section = ("cc", "Vectorscope CC") @@ -11,7 +12,7 @@ def settings(): "cc_metadata", OptionInfo( True, - "Append Vectorscope CC parameters to generation information", + "Append Vectorscope CC parameters to generation infotext", section=section, category_id="sd", ), @@ -26,12 +27,42 @@ def settings(): category_id="sd", onchange=reset_ui_config, ) - .needs_reload_ui() - .info( - "uncheck this option if you wish to use the built-in Defaults function) (enable this option again if the extension is not functioning correctly after an update" - ), + .info("uncheck this option if you wish to use the built-in Defaults function") + .info("enable again if the extension is not working correctly after an update") + .needs_reload_ui(), ) + for lbl, minVal, maxVal in [ + ("Brightness", (-5.0, 0.0), (0.0, 5.0)), + ("Contrast", (-5.0, 0.0), (0.0, 5.0)), + ("Saturation", (0.25, 1.0), (1.0, 1.75)), + ("Color", (-4.0, 0.0), (0.0, 4.0)), + ]: + + opts.add_option( + f"cc_{lbl.lower()}_min", + OptionInfo( + minVal[0], + f"{lbl} - Min", + Slider, + {"step": 0.05, "minimum": minVal[0], "maximum": minVal[1]}, + section=section, + category_id="sd", + ).needs_reload_ui(), + ) + + opts.add_option( + f"cc_{lbl.lower()}_max", + OptionInfo( + maxVal[1], + f"{lbl} - Max", + Slider, + {"step": 0.05, "minimum": maxVal[0], "maximum": maxVal[1]}, + section=section, + category_id="sd", + ).needs_reload_ui(), + ) + def reset_ui_config(): extension = "cc.py" diff --git a/scripts/cc.py b/scripts/cc.py index 158c35e..f1d9c5c 100644 --- a/scripts/cc.py +++ b/scripts/cc.py @@ -1,5 +1,6 @@ from modules.sd_samplers_kdiffusion import KDiffusionSampler -from modules import shared, scripts +from modules.shared import opts +from modules import scripts from lib_cc.colorpicker import create_colorpicker from lib_cc.callback import hook_callbacks @@ -11,12 +12,13 @@ from random import seed import gradio as gr -VERSION = "2.3.0" +VERSION = "2.3.1" style_manager = StyleManager() style_manager.load_styles() hook_callbacks() +const.init() class VectorscopeCC(scripts.Script): @@ -125,7 +127,7 @@ class VectorscopeCC(scripts.Script): ) delete_btn = gr.Button(value="Delete Style", scale=2) - if getattr(shared.opts, "cc_no_defaults", True): + if getattr(opts, "cc_no_defaults", True): style_choice.do_not_save_to_config = True [ @@ -280,7 +282,7 @@ class VectorscopeCC(scripts.Script): ] for comp, name in self.infotext_fields: - if getattr(shared.opts, "cc_no_defaults", True): + if getattr(opts, "cc_no_defaults", True): comp.do_not_save_to_config = True self.paste_field_names.append(name) @@ -366,7 +368,7 @@ class VectorscopeCC(scripts.Script): print(f"> G: {g}") print(f"> B: {b}\n") - if getattr(shared.opts, "cc_metadata", True): + if getattr(opts, "cc_metadata", True): p.extra_generation_params.update( { "Vec CC Enabled": enable,