feat: add detection prompt dataset for quick selection
This commit is contained in:
parent
3b55e64990
commit
22e1b08e4f
|
|
@ -501,8 +501,8 @@ example_inpaint_prompts = get_config_item_or_set_default(
|
|||
validator=lambda x: isinstance(x, list) and all(isinstance(v, str) for v in x),
|
||||
expected_type=list
|
||||
)
|
||||
example_enhance_prompts = get_config_item_or_set_default(
|
||||
key='example_enhance_prompts',
|
||||
example_enhance_detection_prompts = get_config_item_or_set_default(
|
||||
key='example_enhance_detection_prompts',
|
||||
default_value=[
|
||||
'face', 'eye', 'mouth', 'hair', 'hand', 'body'
|
||||
],
|
||||
|
|
@ -547,7 +547,7 @@ metadata_created_by = get_config_item_or_set_default(
|
|||
)
|
||||
|
||||
example_inpaint_prompts = [[x] for x in example_inpaint_prompts]
|
||||
example_enhance_prompts = [[x] for x in example_enhance_prompts]
|
||||
example_enhance_detection_prompts = [[x] for x in example_enhance_detection_prompts]
|
||||
|
||||
default_inpaint_mask_model = get_config_item_or_set_default(
|
||||
key='default_inpaint_mask_model',
|
||||
|
|
|
|||
25
webui.py
25
webui.py
|
|
@ -254,6 +254,16 @@ with shared.gradio_root:
|
|||
value=modules.config.default_inpaint_mask_cloth_category,
|
||||
visible=False)
|
||||
inpaint_mask_dino_prompt_text = gr.Textbox(label='Detection prompt', value='', visible=False, info='Use singular whenever possible')
|
||||
example_inpaint_mask_dino_prompt_text = gr.Dataset(
|
||||
samples=modules.config.example_enhance_detection_prompts,
|
||||
label='Detection Prompt Quick List',
|
||||
components=[inpaint_mask_dino_prompt_text],
|
||||
visible=modules.config.default_enhance_inpaint_mask_model == 'sam')
|
||||
example_inpaint_mask_dino_prompt_text.click(lambda x: x[0],
|
||||
inputs=example_inpaint_mask_dino_prompt_text,
|
||||
outputs=inpaint_mask_dino_prompt_text,
|
||||
show_progress=False, queue=False)
|
||||
|
||||
with gr.Accordion("Advanced options", visible=False, open=False) as inpaint_mask_advanced_options:
|
||||
inpaint_mask_sam_model = gr.Dropdown(label='SAM model', choices=flags.inpaint_mask_sam_model, value=modules.config.default_inpaint_mask_sam_model)
|
||||
inpaint_mask_box_threshold = gr.Slider(label="Box Threshold", minimum=0.0, maximum=1.0, value=0.3, step=0.05)
|
||||
|
|
@ -283,9 +293,16 @@ with shared.gradio_root:
|
|||
|
||||
return mask
|
||||
|
||||
inpaint_mask_model.change(lambda x: [gr.update(visible=x == 'u2net_cloth_seg'), gr.update(visible=x == 'sam'), gr.update(visible=x == 'sam')],
|
||||
|
||||
inpaint_mask_model.change(lambda x: [gr.update(visible=x == 'u2net_cloth_seg')] +
|
||||
[gr.update(visible=x == 'sam')] * 2 +
|
||||
[gr.Dataset.update(visible=x == 'sam',
|
||||
samples=modules.config.example_enhance_detection_prompts)],
|
||||
inputs=inpaint_mask_model,
|
||||
outputs=[inpaint_mask_cloth_category, inpaint_mask_dino_prompt_text, inpaint_mask_advanced_options],
|
||||
outputs=[inpaint_mask_cloth_category,
|
||||
inpaint_mask_dino_prompt_text,
|
||||
inpaint_mask_advanced_options,
|
||||
example_inpaint_mask_dino_prompt_text],
|
||||
queue=False, show_progress=False)
|
||||
|
||||
with gr.TabItem(label='Describe') as desc_tab:
|
||||
|
|
@ -342,8 +359,8 @@ with shared.gradio_root:
|
|||
interactive=True,
|
||||
visible=modules.config.default_enhance_inpaint_mask_model == 'sam')
|
||||
example_enhance_mask_dino_prompt_text = gr.Dataset(
|
||||
samples=modules.config.example_enhance_prompts,
|
||||
label='Additional Prompt Quick List',
|
||||
samples=modules.config.example_enhance_detection_prompts,
|
||||
label='Detection Prompt Quick List',
|
||||
components=[enhance_mask_dino_prompt_text],
|
||||
visible=modules.config.default_enhance_inpaint_mask_model == 'sam')
|
||||
example_enhance_mask_dino_prompt_text.click(lambda x: x[0],
|
||||
|
|
|
|||
Loading…
Reference in New Issue