Skip to content

Commit 66c7396

Browse files
committed
belated webui 1.6.0 support
1 parent 16c6fd6 commit 66c7396

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You also can draw your mask instead of or in addition to detection, and take adv
1212
1. Install [sd-webui-segment-anything](https://github.com/continue-revolution/sd-webui-segment-anything) extension. If it bothers you, you can hide it in the Replacer's settings. Go to tab `Extension` -> `Avaliable` -> click `Load from` and search _"sd-webui-segment-anything"_
1313
2. Download model [sam_hq_vit_l.pth](https://huggingface.co/lkeab/hq-sam/resolve/main/sam_hq_vit_l.pth), or others from the list bellow, and put it into `extensions/sd-webui-segment-anything/models/sam`
1414
3. For faster hires fix, download [lcm-lora-sdv1-5](https://huggingface.co/latent-consistency/lcm-lora-sdv1-5/blob/main/pytorch_lora_weights.safetensors), rename it into `lcm-lora-sdv1-5.safetensors`, put into `models/Lora`. Or if you have already lcm lora, then change hires suffix in the extension options
15-
4. Install this extension. Go to tab `Extension` -> `Available` -> click `Load from` and search _"Replacer"_. Be sure your sd-webui version is >= 1.7.0. For AMD and Intel GPUs you need to enable cpu in Replacer's settings
15+
4. Install this extension. Go to tab `Extension` -> `Available` -> click `Load from` and search _"Replacer"_. Be sure your sd-webui version is >= 1.6.0. For AMD and Intel GPUs you need to enable cpu in Replacer's settings
1616
5. Reload UI
1717

1818

replacer/tab_ui.py

+25-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import gradio as gr
2-
from modules import shared, sd_samplers, ui_toprow, ui, ui_settings, errors
2+
from modules import shared, sd_samplers, ui, ui_settings, errors
3+
try:
4+
from modules import ui_toprow
5+
except:
6+
ui_toprow = None
37
from modules.ui_components import ToolButton, ResizeHandleRow
48
from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call
59
from modules.ui_common import create_output_panel, refresh_symbol, update_generation_info
@@ -50,6 +54,8 @@ def unloadModels():
5054

5155

5256
def getSubmitJsFunction(galleryId, buttonsId, extraShowButtonsId):
57+
if not ui_toprow:
58+
return ''
5359
return 'function(){'\
5460
'var arguments_ = Array.from(arguments);'\
5561
f'arguments_.push("{extraShowButtonsId}", "{buttonsId}", "{galleryId}");'\
@@ -134,11 +140,14 @@ def getReplacerTabUI(isDedicatedPage):
134140
)
135141

136142
runButtonIdPart='replacer'
137-
toprow = ui_toprow.Toprow(is_compact=True, is_img2img=False, id_part=runButtonIdPart)
138-
toprow.create_inline_toprow_image()
139-
run_button = toprow.submit
140-
run_button.variant = 'secondary'
141-
run_button.value = 'Run'
143+
if ui_toprow:
144+
toprow = ui_toprow.Toprow(is_compact=True, is_img2img=False, id_part=runButtonIdPart)
145+
toprow.create_inline_toprow_image()
146+
run_button = toprow.submit
147+
run_button.variant = 'secondary'
148+
run_button.value = 'Run'
149+
else:
150+
run_button = gr.Button("Run")
142151

143152

144153
with gr.Accordion("Advanced options", open=False, elem_id='replacer_advanced_options'):
@@ -475,11 +484,14 @@ def getReplacerTabUI(isDedicatedPage):
475484
)
476485

477486
with gr.Row():
478-
toprow = ui_toprow.Toprow(is_compact=True, is_img2img=False, id_part=f'{runButtonIdPart}_hf')
479-
toprow.create_inline_toprow_image()
480-
apply_hires_fix_button = toprow.submit
481-
apply_hires_fix_button.variant = 'secondary'
482-
apply_hires_fix_button.value = 'Apply HiresFix'
487+
if ui_toprow:
488+
toprow = ui_toprow.Toprow(is_compact=True, is_img2img=False, id_part=f'{runButtonIdPart}_hf')
489+
toprow.create_inline_toprow_image()
490+
apply_hires_fix_button = toprow.submit
491+
apply_hires_fix_button.variant = 'secondary'
492+
apply_hires_fix_button.value = 'Apply HiresFix'
493+
else:
494+
apply_hires_fix_button = gr.Button('Apply HiresFix')
483495

484496
with gr.Row():
485497
with gr.Accordion("HiresFix options", open=False):
@@ -733,7 +745,7 @@ def tab_batch_video_on_select():
733745
html_info,
734746
html_log,
735747
],
736-
show_progress=False,
748+
show_progress=ui_toprow is None,
737749
)
738750

739751

@@ -766,7 +778,7 @@ def tab_batch_video_on_select():
766778
html_info,
767779
html_log,
768780
],
769-
show_progress=False,
781+
show_progress=ui_toprow is None,
770782
)
771783

772784

0 commit comments

Comments
 (0)