option - ui

This commit is contained in:
Haoming
2025-08-05 14:17:08 +08:00
parent 1786cbec4f
commit 85fb27b8b4
3 changed files with 22 additions and 23 deletions
+5 -4
View File
@@ -1,6 +1,7 @@
import gradio as gr
from modules import scripts, sd_models
from modules.shared import opts
from modules.infotext_utils import PasteField
from modules.ui_common import create_refresh_button
from modules.ui_components import InputAccordion
@@ -17,20 +18,20 @@ class ScriptRefiner(scripts.ScriptBuiltinUI):
return "Refiner"
def show(self, is_img2img):
return scripts.AlwaysVisible
return scripts.AlwaysVisible if opts.show_refiner else None
def ui(self, is_img2img):
with InputAccordion(False, label="Refiner", elem_id=self.elem_id("enable")) as enable_refiner:
with gr.Row():
refiner_checkpoint = gr.Dropdown(label='Checkpoint', info='(use model of same architecture)', elem_id=self.elem_id("checkpoint"), choices=["", *sd_models.checkpoint_tiles(use_short=True)], value='', tooltip="switch to another model in the middle of generation")
create_refresh_button(refiner_checkpoint, sd_models.list_models, lambda: {"choices": sd_models.checkpoint_tiles(use_short=True)}, self.elem_id("checkpoint_refresh"))
refiner_switch_at = gr.Slider(value=0.8, label="Switch at", minimum=0.01, maximum=1.0, step=0.01, elem_id=self.elem_id("switch_at"), tooltip="fraction of sampling steps when the switch to refiner model should happen; 1=never, 0.5=switch in the middle of generation")
def lookup_checkpoint(title):
info = sd_models.get_closet_checkpoint_match(title)
return None if info is None else info.short_title
self.infotext_fields = [
PasteField(enable_refiner, lambda d: 'Refiner' in d),
PasteField(refiner_checkpoint, lambda d: lookup_checkpoint(d.get('Refiner')), api="refiner_checkpoint"),