From ab0553ccf4bbc5b86e81871c07c8c49385254ae1 Mon Sep 17 00:00:00 2001 From: Haoming Date: Thu, 7 Mar 2024 15:50:16 +0800 Subject: [PATCH] support ADetailer fix #21 --- CHANGELOG.md | 3 +++ README.md | 4 +++- scripts/cc.py | 16 +++++++++++----- scripts/cc_callback.py | 3 +++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55024b0..a98ba26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### v2.0.1 - 2024 Mar.07 +- Support **ADetailer** + ### v2.0.0 - 2024 Mar.05 - Improved Logics diff --git a/README.md b/README.md index f10145b..4cd709c 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,9 @@ Refer to the parameters and sample images below and play around with the values. #### Advanced Settings - **Process Hires. fix:** By default, this Extension only functions during the **txt2img** phase, so that **Hires. fix** may "fix" the artifacts introduced during **txt2img**. Enable this to process **Hires. fix** phase too. - - This option does not affect **img2img** + - This option does not affect **img2img** +- **Process ADetailer:** Enable to process **[ADetailer](https://github.com/Bing-su/adetailer)** phase too. + - Will usually cause a square of inconsistent colors #### Noise Settings > let `x` denote the Tensor ; let `y` denote the operations diff --git a/scripts/cc.py b/scripts/cc.py index de92600..c7ce30a 100644 --- a/scripts/cc.py +++ b/scripts/cc.py @@ -10,7 +10,7 @@ import gradio as gr import random -VERSION = 'v2.0.0' +VERSION = 'v2.0.1' style_manager = StyleManager() @@ -73,7 +73,9 @@ class VectorscopeCC(scripts.Script): refresh_btn.click(fn=lambda _: gr.update(choices=style_manager.list_style()), outputs=style_choice) with gr.Accordion("Advanced Settings", open=False): - doHR = gr.Checkbox(label="Process Hires. fix") + 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") @@ -91,6 +93,7 @@ class VectorscopeCC(scripts.Script): gr.update(value=const.COLOR.default), gr.update(value=const.COLOR.default), gr.update(value=False), + gr.update(value=False), gr.update(value='Straight Abs.'), gr.update(value='Flat') ] @@ -105,7 +108,7 @@ class VectorscopeCC(scripts.Script): 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, method, scaling]).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 = [] @@ -120,6 +123,7 @@ class VectorscopeCC(scripts.Script): (b, "Vec CC B"), (method, "Vec CC Noise"), (doHR, "Vec CC Proc HrF"), + (doAD, "Vec CC Proc Ade"), (scaling, "Vec CC Scaling"), ] @@ -127,9 +131,9 @@ class VectorscopeCC(scripts.Script): comp.do_not_save_to_config = True self.paste_field_names.append(name) - return [enable, latent, bri, con, sat, r, g, b, doHR, method, scaling] + 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, method:str, scaling:str): + 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") @@ -218,6 +222,7 @@ class VectorscopeCC(scripts.Script): 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 @@ -241,6 +246,7 @@ class VectorscopeCC(scripts.Script): 'b': b, 'method': method, 'doHR': doHR, + 'doAD': doAD, 'scaling': scaling, 'step': steps } diff --git a/scripts/cc_callback.py b/scripts/cc_callback.py index 438d44c..9c7ff30 100644 --- a/scripts/cc_callback.py +++ b/scripts/cc_callback.py @@ -80,6 +80,9 @@ def cc_callback(self, d): if getattr(self.p, "is_hr_pass", False) and not self.vec_cc["doHR"]: return original_callback(self, d) + if getattr(self.p, "_ad_inner", False) and not self.vec_cc["doAD"]: + return original_callback(self, d) + is_xl: bool = self.p.sd_model.is_sdxl mode = str(self.vec_cc["mode"])