Skip to content

Commit 3b52e7b

Browse files
committed
add scripts paths inside ui-config
1 parent 0fd2d77 commit 3b52e7b

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,3 @@ When you press the "Apply hires fix" button, the extension regenerates the image
8888

8989
### small todo:
9090
- add hires fix args into metadata
91-
- add scripts paths inside ui-config

replacer/ui/make_advanced_options.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
getAvoidancePromptExamplesNumber, getMaskColorStr
77
)
88
from replacer import replacer_scripts
9-
from replacer.ui.tools_ui import IS_WEBUI_1_9, AttrDict, IS_WEBUI_1_5
9+
from replacer.ui.tools_ui import IS_WEBUI_1_9, AttrDict, IS_WEBUI_1_5, setCustomScriptSourceForComponents
1010

1111

1212

@@ -179,6 +179,7 @@ def makeAdvancedOptions(comp: AttrDict, isDedicatedPage: bool):
179179
elem_id="replacer_mask_mode")
180180

181181
comp.soft_inpaint_inputs = []
182+
setCustomScriptSourceForComponents("soft_inpainting")
182183
if replacer_scripts.script_soft_inpaint:
183184
try:
184185
with gr.Row():
@@ -195,6 +196,7 @@ def makeAdvancedOptions(comp: AttrDict, isDedicatedPage: bool):
195196
except Exception as e:
196197
errors.report(f"Cannot add soft inpaint accordion {e}", exc_info=True)
197198
replacer_scripts.script_soft_inpaint = None
199+
setCustomScriptSourceForComponents(None)
198200

199201

200202
with gr.Tab('Avoidance'):
@@ -266,6 +268,7 @@ def makeAdvancedOptions(comp: AttrDict, isDedicatedPage: bool):
266268
if IS_WEBUI_1_5:
267269
comp.custom_mask_brush_color.visible = False
268270

271+
setCustomScriptSourceForComponents("inpaint_diff")
269272
with (gr.Tab('Inpaint Diff') if replacer_scripts.InpaintDifferenceGlobals
270273
else gr.Group()) as comp.inpaint_diff_tab:
271274
with gr.Row():
@@ -298,4 +301,5 @@ def makeAdvancedOptions(comp: AttrDict, isDedicatedPage: bool):
298301
if not replacer_scripts.InpaintDifferenceGlobals:
299302
comp.inpaint_diff_tab.visible = False
300303
comp.inpaint_diff_tab.render = False
304+
setCustomScriptSourceForComponents(None)
301305

replacer/ui/replacer_tab_ui.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from replacer.ui.make_advanced_options import makeAdvancedOptions
1414
from replacer.ui.make_hiresfix_options import makeHiresFixOptions
1515
from replacer.ui.tools_ui import ( update_mask_brush_color, get_current_image, unloadModels, AttrDict,
16-
getSubmitJsFunction, sendBackToReplacer, IS_WEBUI_1_8, OuputPanelWatcher, ui_toprow
16+
getSubmitJsFunction, sendBackToReplacer, IS_WEBUI_1_8, OuputPanelWatcher, ui_toprow,
17+
setCustomScriptSourceForComponents,
1718
)
1819

1920

@@ -172,6 +173,7 @@ def init_tab(self, isDedicatedPage: bool):
172173
"extensions to increase consistency, if it fits to your scenario")
173174

174175
comp.cn_inputs = []
176+
setCustomScriptSourceForComponents("controlnet")
175177
if replacer_scripts.script_controlnet:
176178
try:
177179
with gr.Row():
@@ -189,6 +191,7 @@ def init_tab(self, isDedicatedPage: bool):
189191
except Exception as e:
190192
errors.report(f"Cannot add controlnet accordion {e}", exc_info=True)
191193
replacer_scripts.script_controlnet = None
194+
setCustomScriptSourceForComponents(None)
192195

193196

194197
with gr.Column(scale=15):

replacer/ui/tools_ui.py

+13
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,16 @@ def prepareExpectedUIBehavior(gArgs: GenerationArgs):
134134

135135
gArgs.detectionPrompt = gArgs.detectionPrompt.strip()
136136
gArgs.avoidancePrompt = gArgs.avoidancePrompt.strip()
137+
138+
139+
custom_script_source = None
140+
141+
def setCustomScriptSourceForComponents(text: str):
142+
global custom_script_source
143+
custom_script_source = text
144+
145+
146+
def watchSetCustomScriptSourceForComponents(component, **kwargs):
147+
global custom_script_source
148+
if custom_script_source is not None:
149+
component.custom_script_source = custom_script_source

scripts/replacer_main_ui.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from replacer.ui.tools_ui import IS_WEBUI_1_5
88
from replacer.ui import replacer_tab_ui
99
from replacer.tools import getReplacerFooter
10-
from replacer.ui.tools_ui import watchOuputPanel
10+
from replacer.ui.tools_ui import watchOuputPanel, watchSetCustomScriptSourceForComponents
1111
from replacer import replacer_scripts
1212

1313

@@ -67,6 +67,7 @@ def hideSegmentAnythingAccordions(component, **kwargs):
6767
script_callbacks.on_after_component(replacer_scripts.watchControlNetUI)
6868
script_callbacks.on_after_component(replacer_scripts.watchSoftInpaintUI)
6969
script_callbacks.on_after_component(watchOuputPanel)
70+
script_callbacks.on_after_component(watchSetCustomScriptSourceForComponents)
7071
script_callbacks.on_ui_settings(on_ui_settings)
7172
script_callbacks.on_after_component(replacer_scripts.addButtonIntoComparisonTab)
7273
script_callbacks.on_after_component(replacer_scripts.watchImageComparison)

0 commit comments

Comments
 (0)