support ADetailer

fix #21
pull/32/head
Haoming 2024-03-07 15:50:16 +08:00
parent c76f34ffec
commit ab0553ccf4
4 changed files with 20 additions and 6 deletions

View File

@ -1,3 +1,6 @@
### v2.0.1 - 2024 Mar.07
- Support **ADetailer**
### v2.0.0 - 2024 Mar.05 ### v2.0.0 - 2024 Mar.05
- Improved Logics - Improved Logics

View File

@ -65,7 +65,9 @@ Refer to the parameters and sample images below and play around with the values.
#### Advanced Settings #### 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. - **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 #### Noise Settings
> let `x` denote the Tensor ; let `y` denote the operations > let `x` denote the Tensor ; let `y` denote the operations

View File

@ -10,7 +10,7 @@ import gradio as gr
import random import random
VERSION = 'v2.0.0' VERSION = 'v2.0.1'
style_manager = StyleManager() 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) refresh_btn.click(fn=lambda _: gr.update(choices=style_manager.list_style()), outputs=style_choice)
with gr.Accordion("Advanced Settings", open=False): 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.") 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") 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=const.COLOR.default), gr.update(value=const.COLOR.default),
gr.update(value=False), gr.update(value=False),
gr.update(value=False),
gr.update(value='Straight Abs.'), gr.update(value='Straight Abs.'),
gr.update(value='Flat') 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)) 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}); }}') 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.paste_field_names = []
@ -120,6 +123,7 @@ class VectorscopeCC(scripts.Script):
(b, "Vec CC B"), (b, "Vec CC B"),
(method, "Vec CC Noise"), (method, "Vec CC Noise"),
(doHR, "Vec CC Proc HrF"), (doHR, "Vec CC Proc HrF"),
(doAD, "Vec CC Proc Ade"),
(scaling, "Vec CC Scaling"), (scaling, "Vec CC Scaling"),
] ]
@ -127,9 +131,9 @@ class VectorscopeCC(scripts.Script):
comp.do_not_save_to_config = True comp.do_not_save_to_config = True
self.paste_field_names.append(name) 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(): if 'Enable' in self.xyzCache.keys():
enable = (self.xyzCache['Enable'].lower().strip() == "true") 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 B'] = b
p.extra_generation_params['Vec CC Noise'] = method p.extra_generation_params['Vec CC Noise'] = method
p.extra_generation_params['Vec CC Proc HrF'] = doHR 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 Scaling'] = scaling
p.extra_generation_params['Vec CC Version'] = VERSION p.extra_generation_params['Vec CC Version'] = VERSION
@ -241,6 +246,7 @@ class VectorscopeCC(scripts.Script):
'b': b, 'b': b,
'method': method, 'method': method,
'doHR': doHR, 'doHR': doHR,
'doAD': doAD,
'scaling': scaling, 'scaling': scaling,
'step': steps 'step': steps
} }

View File

@ -80,6 +80,9 @@ def cc_callback(self, d):
if getattr(self.p, "is_hr_pass", False) and not self.vec_cc["doHR"]: if getattr(self.p, "is_hr_pass", False) and not self.vec_cc["doHR"]:
return original_callback(self, d) 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 is_xl: bool = self.p.sd_model.is_sdxl
mode = str(self.vec_cc["mode"]) mode = str(self.vec_cc["mode"])