From 1bfd098ba2ec5aedc58504bc02833522c838b90a Mon Sep 17 00:00:00 2001 From: Haoming Date: Tue, 25 Jun 2024 15:54:12 +0800 Subject: [PATCH] formatting Alt + Shift + F goes brrr --- CHANGELOG.md | 8 +- scripts/cc.py | 398 ++++++++++++++++++++++++++++---------- scripts/cc_callback.py | 11 +- scripts/cc_colorpicker.py | 5 +- scripts/cc_const.py | 1 + scripts/cc_hdr.py | 14 +- scripts/cc_scaling.py | 5 +- scripts/cc_settings.py | 11 +- scripts/cc_style.py | 4 +- scripts/cc_xyz.py | 25 ++- style.css | 24 +-- 11 files changed, 374 insertions(+), 132 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a98ba26..0871331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v2.0.3 - 2024 Jun.25 +- Format + +### v2.0.2 - 2024 Jun.24 +- Bug Fix + ### v2.0.1 - 2024 Mar.07 - Support **ADetailer** @@ -30,7 +36,7 @@ - Better **Hires. fix** logic ### v1.4.9 - 2023 Nov.01 -- Improve Sliders values refresh +- Improve Sliders values refresh ### v1.4.8 - 2023 Nov.01 - Removed "**magic numbers**" diff --git a/scripts/cc.py b/scripts/cc.py index d89aa23..390e840 100644 --- a/scripts/cc.py +++ b/scripts/cc.py @@ -10,7 +10,7 @@ import gradio as gr import random -VERSION = 'v2.0.1' +VERSION = "v2.0.3" style_manager = StyleManager() @@ -29,55 +29,158 @@ class VectorscopeCC(scripts.Script): return scripts.AlwaysVisible def ui(self, is_img2img): - mode = ("img" if is_img2img else "txt") - m = f"\"{mode}\"" + mode = "img" if is_img2img else "txt" + m = f'"{mode}"' - with gr.Accordion(f"Vectorscope CC {VERSION}", elem_id=f"vec-cc-{mode}", open=False): + with gr.Accordion( + f"Vectorscope CC {VERSION}", elem_id=f"vec-cc-{mode}", open=False + ): with gr.Row(): enable = gr.Checkbox(label="Enable") latent = gr.Checkbox(label="Alt. (Stronger Effects)") with gr.Row(): - bri = gr.Slider(label="Brightness", minimum=const.Brightness.minimum, maximum=const.Brightness.maximum, step=0.05, value=const.Brightness.default) - con = gr.Slider(label="Contrast", minimum=const.Contrast.minimum, maximum=const.Contrast.maximum, step=0.05, value=const.Contrast.default) - sat = gr.Slider(label="Saturation", minimum=const.Saturation.minimum, maximum=const.Saturation.maximum, step=0.05, value=const.Saturation.default) + bri = gr.Slider( + label="Brightness", + minimum=const.Brightness.minimum, + maximum=const.Brightness.maximum, + step=0.05, + value=const.Brightness.default, + ) + con = gr.Slider( + label="Contrast", + minimum=const.Contrast.minimum, + maximum=const.Contrast.maximum, + step=0.05, + value=const.Contrast.default, + ) + sat = gr.Slider( + label="Saturation", + minimum=const.Saturation.minimum, + maximum=const.Saturation.maximum, + step=0.05, + value=const.Saturation.default, + ) with gr.Row(): with gr.Column(): - r = gr.Slider(label="R", info='Cyan | Red', minimum=const.COLOR.minimum, maximum=const.COLOR.maximum, step=0.05, value=const.COLOR.default, elem_id=f"cc-r-{mode}") - g = gr.Slider(label="G", info='Magenta | Green',minimum=const.COLOR.minimum, maximum=const.COLOR.maximum, step=0.05, value=const.COLOR.default, elem_id=f"cc-g-{mode}") - b = gr.Slider(label="B", info='Yellow | Blue',minimum=const.COLOR.minimum, maximum=const.COLOR.maximum, step=0.05, value=const.COLOR.default, elem_id=f"cc-b-{mode}") + r = gr.Slider( + label="R", + info="Cyan | Red", + minimum=const.COLOR.minimum, + maximum=const.COLOR.maximum, + step=0.05, + value=const.COLOR.default, + elem_id=f"cc-r-{mode}", + ) + g = gr.Slider( + label="G", + info="Magenta | Green", + minimum=const.COLOR.minimum, + maximum=const.COLOR.maximum, + step=0.05, + value=const.COLOR.default, + elem_id=f"cc-g-{mode}", + ) + b = gr.Slider( + label="B", + info="Yellow | Blue", + minimum=const.COLOR.minimum, + maximum=const.COLOR.maximum, + step=0.05, + value=const.COLOR.default, + elem_id=f"cc-b-{mode}", + ) - r.input(None, [r, g, b], None, _js=f'(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}') - g.input(None, [r, g, b], None, _js=f'(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}') - b.input(None, [r, g, b], None, _js=f'(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}') + r.input( + None, + [r, g, b], + None, + _js=f"(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}", + ) + g.input( + None, + [r, g, b], + None, + _js=f"(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}", + ) + b.input( + None, + [r, g, b], + None, + _js=f"(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}", + ) create_colorpicker(is_img2img) with gr.Accordion("Styles", open=False): with gr.Row(): - style_choice = gr.Dropdown(label="Styles", choices=style_manager.list_style(), scale = 3) - apply_btn = gr.Button(value="Apply Style", elem_id=f"cc-apply-{mode}", scale = 2) - refresh_btn = gr.Button(value="Refresh Style", scale = 2) + style_choice = gr.Dropdown( + label="Styles", choices=style_manager.list_style(), scale=3 + ) + apply_btn = gr.Button( + value="Apply Style", elem_id=f"cc-apply-{mode}", scale=2 + ) + refresh_btn = gr.Button(value="Refresh Style", scale=2) with gr.Row(): - style_name = gr.Textbox(label="Style Name", scale = 3) - save_btn = gr.Button(value="Save Style", elem_id=f"cc-save-{mode}", scale = 2) - delete_btn = gr.Button(value="Delete Style", scale = 2) + style_name = gr.Textbox(label="Style Name", scale=3) + save_btn = gr.Button( + value="Save Style", elem_id=f"cc-save-{mode}", scale=2 + ) + delete_btn = gr.Button(value="Delete Style", scale=2) - apply_btn.click(fn=style_manager.get_style, inputs=style_choice, outputs=[latent, bri, con, sat, r, g, b]).then(None, [r, g, b], None, _js=f'(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}') - save_btn.click(fn=lambda *args: gr.update(choices=style_manager.save_style(*args)), inputs=[style_name, latent, bri, con, sat, r, g, b], outputs=style_choice) - delete_btn.click(fn=lambda name: gr.update(choices=style_manager.delete_style(name)), inputs=style_name, outputs=style_choice) - refresh_btn.click(fn=lambda _: gr.update(choices=style_manager.list_style()), outputs=style_choice) + apply_btn.click( + fn=style_manager.get_style, + inputs=style_choice, + outputs=[latent, bri, con, sat, r, g, b], + ).then( + None, + [r, g, b], + None, + _js=f"(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}", + ) + save_btn.click( + fn=lambda *args: gr.update(choices=style_manager.save_style(*args)), + inputs=[style_name, latent, bri, con, sat, r, g, b], + outputs=style_choice, + ) + delete_btn.click( + fn=lambda name: gr.update(choices=style_manager.delete_style(name)), + inputs=style_name, + outputs=style_choice, + ) + refresh_btn.click( + fn=lambda _: gr.update(choices=style_manager.list_style()), + outputs=style_choice, + ) with gr.Accordion("Advanced Settings", open=False): with gr.Row(): doHR = gr.Checkbox(label="Process Hires. fix") doAD = gr.Checkbox(label="Process Adetailer") - method = gr.Radio(["Straight", "Straight Abs.", "Cross", "Cross Abs.", "Ones", "N.Random", "U.Random", "Multi-Res", "Multi-Res Abs."], label="Noise Settings", value="Straight Abs.") - scaling = gr.Radio(["Flat", "Cos", "Sin", "1 - Cos", "1 - Sin"], label="Scaling Settings", value="Flat") + method = gr.Radio( + [ + "Straight", + "Straight Abs.", + "Cross", + "Cross Abs.", + "Ones", + "N.Random", + "U.Random", + "Multi-Res", + "Multi-Res Abs.", + ], + label="Noise Settings", + value="Straight Abs.", + ) + scaling = gr.Radio( + ["Flat", "Cos", "Sin", "1 - Cos", "1 - Sin"], + label="Scaling Settings", + value="Flat", + ) with gr.Row(): reset_btn = gr.Button(value="Reset") @@ -94,22 +197,92 @@ class VectorscopeCC(scripts.Script): gr.update(value=const.COLOR.default), gr.update(value=False), gr.update(value=False), - gr.update(value='Straight Abs.'), - gr.update(value='Flat') + gr.update(value="Straight Abs."), + gr.update(value="Flat"), ] def on_random(): return [ - gr.update(value=round(random.uniform(const.Brightness.minimum, const.Brightness.maximum), 2)), - gr.update(value=round(random.uniform(const.Contrast.minimum, const.Contrast.maximum), 2)), - gr.update(value=round(random.uniform(const.Saturation.minimum, const.Saturation.maximum), 2)), - gr.update(value=round(random.uniform(const.COLOR.minimum, const.COLOR.maximum), 2)), - gr.update(value=round(random.uniform(const.COLOR.minimum, const.COLOR.maximum), 2)), - gr.update(value=round(random.uniform(const.COLOR.minimum, const.COLOR.maximum), 2)) + gr.update( + value=round( + random.uniform( + const.Brightness.minimum, const.Brightness.maximum + ), + 2, + ) + ), + gr.update( + value=round( + random.uniform( + const.Contrast.minimum, const.Contrast.maximum + ), + 2, + ) + ), + gr.update( + value=round( + random.uniform( + const.Saturation.minimum, const.Saturation.maximum + ), + 2, + ) + ), + gr.update( + value=round( + random.uniform( + const.COLOR.minimum, const.COLOR.maximum + ), + 2, + ) + ), + gr.update( + value=round( + random.uniform( + const.COLOR.minimum, const.COLOR.maximum + ), + 2, + ) + ), + gr.update( + value=round( + random.uniform( + const.COLOR.minimum, const.COLOR.maximum + ), + 2, + ) + ), ] - reset_btn.click(fn=on_reset, inputs=[], outputs=[latent, bri, con, sat, r, g, b, doHR, doAD, method, scaling]).then(None, [r, g, b], None, _js=f'(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}') - random_btn.click(fn=on_random, inputs=[], outputs=[bri, con, sat, r, g, b]).then(None, [r, g, b], None, _js=f'(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}') + reset_btn.click( + fn=on_reset, + inputs=[], + outputs=[ + latent, + bri, + con, + sat, + r, + g, + b, + doHR, + doAD, + method, + scaling, + ], + ).then( + None, + [r, g, b], + None, + _js=f"(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}", + ) + random_btn.click( + fn=on_random, inputs=[], outputs=[bri, con, sat, r, g, b] + ).then( + None, + [r, g, b], + None, + _js=f"(r, g, b) => {{ VectorscopeCC.updateCursor(r, g, b, {m}); }}", + ) self.paste_field_names = [] self.infotext_fields = [ @@ -133,98 +306,121 @@ class VectorscopeCC(scripts.Script): return [enable, latent, bri, con, sat, r, g, b, doHR, doAD, method, scaling] - def process(self, p, enable:bool, latent:bool, bri:float, con:float, sat:float, r:float, g:float, b:float, doHR:bool, doAD:bool, method:str, scaling:str): - if 'Enable' in self.xyzCache.keys(): - enable = (self.xyzCache['Enable'].lower().strip() == "true") + def process( + self, + p, + enable: bool, + latent: bool, + bri: float, + con: float, + sat: float, + r: float, + g: float, + b: float, + doHR: bool, + doAD: bool, + method: str, + scaling: str, + ): + if "Enable" in self.xyzCache.keys(): + enable = self.xyzCache["Enable"].lower().strip() == "true" if not enable: - if 'Enable' not in self.xyzCache.keys(): + if "Enable" not in self.xyzCache.keys(): if len(self.xyzCache) > 0: - print('\n[Vec.CC] x [X/Y/Z Plot] Extension is not Enabled!\n') + print("\n[Vec.CC] x [X/Y/Z Plot] Extension is not Enabled!\n") self.xyzCache.clear() - KDiffusionSampler.vec_cc = {'enable': False} + KDiffusionSampler.vec_cc = {"enable": False} return p - if 'Random' in self.xyzCache.keys(): + if "Random" in self.xyzCache.keys(): if len(self.xyzCache) > 1: - print('\n[X/Y/Z Plot] x [Vec.CC] Randomize is Enabled.\nSome settings will not apply!\n') + print( + "\n[X/Y/Z Plot] x [Vec.CC] Randomize is Enabled.\nSome settings will not apply!\n" + ) else: - print('\n[X/Y/Z Plot] x [Vec.CC] Randomize is Enabled.\n') + print("\n[X/Y/Z Plot] x [Vec.CC] Randomize is Enabled.\n") cc_seed = None for k, v in self.xyzCache.items(): match k: - case 'Alt': - latent = (self.xyzCache['Alt'].lower().strip() == "true") - case 'Brightness': + case "Alt": + latent = self.xyzCache["Alt"].lower().strip() == "true" + case "Brightness": bri = float(v) - case 'Contrast': + case "Contrast": con = float(v) - case 'Saturation': + case "Saturation": sat = float(v) - case 'R': + case "R": r = float(v) - case 'G': + case "G": g = float(v) - case 'B': + case "B": b = float(v) - case 'DoHR': - doHR = (self.xyzCache['DoHR'].lower().strip() == "true") - case 'Method': + case "DoHR": + doHR = self.xyzCache["DoHR"].lower().strip() == "true" + case "Method": method = str(v) - case 'Scaling': + case "Scaling": scaling = str(v) - case 'Random': + case "Random": cc_seed = int(v) self.xyzCache.clear() - if method == 'Disabled': - KDiffusionSampler.vec_cc = {'enable': False} + if method == "Disabled": + KDiffusionSampler.vec_cc = {"enable": False} return p - steps:int = p.steps + steps: int = p.steps # is img2img & do full steps - if not hasattr(p, 'enable_hr') and not shared.opts.img2img_fix_steps: - if getattr(p, 'denoising_strength', 1.0) < 1.0: - steps = int(steps * getattr(p, 'denoising_strength', 1.0) + 1.0) + if not hasattr(p, "enable_hr") and not shared.opts.img2img_fix_steps: + if getattr(p, "denoising_strength", 1.0) < 1.0: + steps = int(steps * getattr(p, "denoising_strength", 1.0) + 1.0) if cc_seed: random.seed(cc_seed) - bri = round(random.uniform(const.Brightness.minimum, const.Brightness.maximum), 2) - con = round(random.uniform(const.Contrast.minimum, const.Contrast.maximum), 2) - sat = round(random.uniform(const.Saturation.minimum, const.Saturation.maximum), 2) + bri = round( + random.uniform(const.Brightness.minimum, const.Brightness.maximum), 2 + ) + con = round( + random.uniform(const.Contrast.minimum, const.Contrast.maximum), 2 + ) + sat = round( + random.uniform(const.Saturation.minimum, const.Saturation.maximum), 2 + ) r = round(random.uniform(const.COLOR.minimum, const.COLOR.maximum), 2) g = round(random.uniform(const.COLOR.minimum, const.COLOR.maximum), 2) b = round(random.uniform(const.COLOR.minimum, const.COLOR.maximum), 2) - print(f'\n-> Seed: {cc_seed}') - print(f'Brightness:\t{bri}') - print(f'Contrast:\t{con}') - print(f'Saturation:\t{sat}') - print(f'R:\t\t{r}') - print(f'G:\t\t{g}') - print(f'B:\t\t{b}\n') + print(f"\n-> Seed: {cc_seed}") + print(f"Brightness:\t{bri}") + print(f"Contrast:\t{con}") + print(f"Saturation:\t{sat}") + print(f"R:\t\t{r}") + print(f"G:\t\t{g}") + print(f"B:\t\t{b}\n") - if getattr(shared.opts, 'cc_metadata', True): - p.extra_generation_params['Vec CC Enabled'] = enable - p.extra_generation_params['Vec CC Alt'] = latent - p.extra_generation_params['Vec CC Brightness'] = bri - p.extra_generation_params['Vec CC Contrast'] = con - p.extra_generation_params['Vec CC Saturation'] = sat - p.extra_generation_params['Vec CC R'] = r - p.extra_generation_params['Vec CC G'] = g - p.extra_generation_params['Vec CC B'] = b - p.extra_generation_params['Vec CC Noise'] = method - p.extra_generation_params['Vec CC Proc HrF'] = doHR - p.extra_generation_params['Vec CC Proc Ade'] = doAD - p.extra_generation_params['Vec CC Scaling'] = scaling - p.extra_generation_params['Vec CC Version'] = VERSION + if getattr(shared.opts, "cc_metadata", True): + p.extra_generation_params["Vec CC Enabled"] = enable + p.extra_generation_params["Vec CC Alt"] = latent + p.extra_generation_params["Vec CC Brightness"] = bri + p.extra_generation_params["Vec CC Contrast"] = con + p.extra_generation_params["Vec CC Saturation"] = sat + p.extra_generation_params["Vec CC R"] = r + p.extra_generation_params["Vec CC G"] = g + p.extra_generation_params["Vec CC B"] = b + p.extra_generation_params["Vec CC Noise"] = method + p.extra_generation_params["Vec CC Proc HrF"] = doHR + p.extra_generation_params["Vec CC Proc Ade"] = doAD + p.extra_generation_params["Vec CC Scaling"] = scaling + p.extra_generation_params["Vec CC Version"] = VERSION bri /= steps con /= steps @@ -233,22 +429,22 @@ class VectorscopeCC(scripts.Script): g /= steps b /= steps - mode = 'x' if latent else 'denoised' + mode = "x" if latent else "denoised" KDiffusionSampler.vec_cc = { - 'enable': True, - 'mode' : mode, - 'bri': bri, - 'con': con, - 'sat': sat, - 'r': r, - 'g': g, - 'b': b, - 'method': method, - 'doHR': doHR, - 'doAD': doAD, - 'scaling': scaling, - 'step': steps + "enable": True, + "mode": mode, + "bri": bri, + "con": con, + "sat": sat, + "r": r, + "g": g, + "b": b, + "method": method, + "doHR": doHR, + "doAD": doAD, + "scaling": scaling, + "step": steps, } return p diff --git a/scripts/cc_callback.py b/scripts/cc_callback.py index 9c7ff30..79e88a7 100644 --- a/scripts/cc_callback.py +++ b/scripts/cc_callback.py @@ -54,7 +54,9 @@ class NoiseMethods: wn = max(1, int(w / (r**i))) hn = max(1, int(h / (r**i))) - noise[b] += (upsampler(torch.randn(1, c, hn, wn).to(device)) * discount**i)[0] + noise[b] += ( + upsampler(torch.randn(1, c, hn, wn).to(device)) * discount**i + )[0] if wn == 1 or hn == 1: break @@ -62,7 +64,7 @@ class NoiseMethods: return noise / noise.std() -def RGB_2_CbCr(r:float, g:float, b:float) -> float: +def RGB_2_CbCr(r: float, g: float, b: float) -> float: """Convert RGB channels into YCbCr for SDXL""" cb = -0.15 * r - 0.29 * g + 0.44 * b cr = 0.44 * r - 0.37 * g - 0.07 * b @@ -72,6 +74,7 @@ def RGB_2_CbCr(r:float, g:float, b:float) -> float: original_callback = KDiffusionSampler.callback_state + @torch.no_grad() def cc_callback(self, d): if not self.vec_cc["enable"]: @@ -150,7 +153,7 @@ def cc_callback(self, d): # Contrast source[i][0] += NoiseMethods.get_delta(source[i][0]) * con - #CbCr + # CbCr source[i][1] -= target[i][1] * cr source[i][2] += target[i][2] * cb @@ -160,10 +163,12 @@ def cc_callback(self, d): return original_callback(self, d) + KDiffusionSampler.callback_state = cc_callback def restore_callback(): KDiffusionSampler.callback_state = original_callback + script_callbacks.on_script_unloaded(restore_callback) diff --git a/scripts/cc_colorpicker.py b/scripts/cc_colorpicker.py index 5904852..fb49d76 100644 --- a/scripts/cc_colorpicker.py +++ b/scripts/cc_colorpicker.py @@ -7,17 +7,18 @@ DOT = os.path.join(scripts.basedir(), "scripts", "dot.png") def create_colorpicker(is_img: bool): + m = "img" if is_img else "txt" gr.Image( WHEEL, interactive=False, container=False, - elem_id=f"cc-colorwheel-{'img' if is_img else 'txt'}", + elem_id=f"cc-colorwheel-{m}", ) gr.Image( DOT, interactive=False, container=False, - elem_id=f"cc-temp-{'img' if is_img else 'txt'}", + elem_id=f"cc-temp-{m}", ) diff --git a/scripts/cc_const.py b/scripts/cc_const.py index 7731555..02b079d 100644 --- a/scripts/cc_const.py +++ b/scripts/cc_const.py @@ -4,6 +4,7 @@ class Param: self.maximum = maximum self.default = default + Brightness = Param(-5.0, 5.0, 0.0) Contrast = Param(-5.0, 5.0, 0.0) Saturation = Param(0.25, 1.75, 1.0) diff --git a/scripts/cc_hdr.py b/scripts/cc_hdr.py index d89fd18..384ba87 100644 --- a/scripts/cc_hdr.py +++ b/scripts/cc_hdr.py @@ -51,9 +51,15 @@ class VectorHDR(scripts.Script): def ui(self, is_img2img): with gr.Row(): count = gr.Slider(label="Brackets", minimum=3, maximum=9, step=2, value=7) - gap = gr.Slider(label="Gaps", minimum=0.50, maximum=2.50, step=0.25, value=1.50) + gap = gr.Slider( + label="Gaps", minimum=0.50, maximum=2.50, step=0.25, value=1.50 + ) - with gr.Accordion("Merge Options", elem_id="vec-hdr-" + ("img" if is_img2img else "txt"), open=False): + with gr.Accordion( + "Merge Options", + elem_id="vec-hdr-" + ("img" if is_img2img else "txt"), + open=False, + ): auto = gr.Checkbox(label="Automatically Merge", value=True) with gr.Row(): @@ -74,7 +80,9 @@ class VectorHDR(scripts.Script): return [count, gap, auto, depth, fmt, gamma] - def run(self, p, count: int, gap: float, auto: bool, depth: str, fmt: str, gamma: float): + def run( + self, p, count: int, gap: float, auto: bool, depth: str, fmt: str, gamma: float + ): center = count // 2 p.seed = get_fixed_seed(p.seed) diff --git a/scripts/cc_scaling.py b/scripts/cc_scaling.py index 9498dce..a934be2 100644 --- a/scripts/cc_scaling.py +++ b/scripts/cc_scaling.py @@ -1,5 +1,6 @@ from math import cos, sin, pi + def apply_scaling( alg: str, current_step: int, @@ -25,8 +26,8 @@ def apply_scaling( case "Sin": mod = sin(rad) case "1 - Cos": - mod = (1 - cos(rad)) + mod = 1 - cos(rad) case "1 - Sin": - mod = (1 - sin(rad)) + mod = 1 - sin(rad) return [bri * mod, con * mod, (sat - 1.0) * mod + 1.0, r * mod, g * mod, b * mod] diff --git a/scripts/cc_settings.py b/scripts/cc_settings.py index 3205ad6..852c106 100644 --- a/scripts/cc_settings.py +++ b/scripts/cc_settings.py @@ -1,6 +1,15 @@ from modules import script_callbacks, shared + def on_ui_settings(): - shared.opts.add_option("cc_metadata", shared.OptionInfo(True, "Append Vectorscope CC parameters to generation information", section=("infotext", "Infotext"))) + shared.opts.add_option( + "cc_metadata", + shared.OptionInfo( + True, + "Append Vectorscope CC parameters to generation information", + section=("infotext", "Infotext"), + ), + ) + script_callbacks.on_ui_settings(on_ui_settings) diff --git a/scripts/cc_style.py b/scripts/cc_style.py index b7fde75..5764d8b 100644 --- a/scripts/cc_style.py +++ b/scripts/cc_style.py @@ -58,7 +58,9 @@ class StyleManager: def save_style(self, style_name, latent, bri, con, sat, r, g, b): if style_name in self.STYLE_SHEET["styles"].keys(): - print(f'\n[Warning] Duplicated Style Name "{style_name}" Detected! Values were not saved!\n') + print( + f'\n[Warning] Duplicated Style Name "{style_name}" Detected! Values were not saved!\n' + ) return self.list_style() style = { diff --git a/scripts/cc_xyz.py b/scripts/cc_xyz.py index 0670047..2376b24 100644 --- a/scripts/cc_xyz.py +++ b/scripts/cc_xyz.py @@ -3,7 +3,10 @@ import modules.scripts as scripts def grid_reference(): for data in scripts.scripts_data: - if data.script_class.__module__ in ('scripts.xyz_grid', 'xyz_grid.py') and hasattr(data, "module"): + if data.script_class.__module__ in ( + "scripts.xyz_grid", + "xyz_grid.py", + ) and hasattr(data, "module"): return data.module raise SystemError("Could not find X/Y/Z Plot...") @@ -39,17 +42,27 @@ def xyz_support(cache: dict): xyz_grid = grid_reference() extra_axis_options = [ - xyz_grid.AxisOption("[Vec.CC] Enable", str, apply_field("Enable"), choices=choices_bool), - xyz_grid.AxisOption("[Vec.CC] Alt.", str, apply_field("Alt"), choices=choices_bool), + xyz_grid.AxisOption( + "[Vec.CC] Enable", str, apply_field("Enable"), choices=choices_bool + ), + xyz_grid.AxisOption( + "[Vec.CC] Alt.", str, apply_field("Alt"), choices=choices_bool + ), xyz_grid.AxisOption("[Vec.CC] Brightness", float, apply_field("Brightness")), xyz_grid.AxisOption("[Vec.CC] Contrast", float, apply_field("Contrast")), xyz_grid.AxisOption("[Vec.CC] Saturation", float, apply_field("Saturation")), xyz_grid.AxisOption("[Vec.CC] R", float, apply_field("R")), xyz_grid.AxisOption("[Vec.CC] G", float, apply_field("G")), xyz_grid.AxisOption("[Vec.CC] B", float, apply_field("B")), - xyz_grid.AxisOption("[Adv.CC] Proc. H.Fix", str, apply_field("DoHR"), choices=choices_bool), - xyz_grid.AxisOption("[Adv.CC] Method", str, apply_field("Method"), choices=choices_method), - xyz_grid.AxisOption("[Adv.CC] Scaling", str, apply_field("Scaling"), choices=choices_scaling), + xyz_grid.AxisOption( + "[Adv.CC] Proc. H.Fix", str, apply_field("DoHR"), choices=choices_bool + ), + xyz_grid.AxisOption( + "[Adv.CC] Method", str, apply_field("Method"), choices=choices_method + ), + xyz_grid.AxisOption( + "[Adv.CC] Scaling", str, apply_field("Scaling"), choices=choices_scaling + ), xyz_grid.AxisOption("[Adv.CC] Randomize", int, apply_field("Random")), ] diff --git a/style.css b/style.css index 6da9383..c1bd42f 100644 --- a/style.css +++ b/style.css @@ -16,21 +16,21 @@ user-select: none; } - #vec-cc-txt button, #vec-cc-txt label { - border-radius: 0.5em; - } +#vec-cc-txt button, #vec-cc-txt label { + border-radius: 0.5em; +} - #vec-cc-img button, #vec-cc-img label { - border-radius: 0.5em; - } +#vec-cc-img button, #vec-cc-img label { + border-radius: 0.5em; +} - #vec-cc-txt fieldset > div { - gap: 0.2em 0.4em; - } +#vec-cc-txt fieldset>div { + gap: 0.2em 0.4em; +} - #vec-cc-img fieldset > div { - gap: 0.2em 0.4em; - } +#vec-cc-img fieldset>div { + gap: 0.2em 0.4em; +} #vec-hdr-txt label, #vec-hdr-img label { border-radius: 0.5em;