Merge pull request #295 from EyeDeck/master
Add --hide-ui-dir-config command line flag
This commit is contained in:
commit
051e9195f1
|
@ -40,6 +40,7 @@ parser.add_argument("--listen", action='store_true', help="launch gradio with 0.
|
||||||
parser.add_argument("--port", type=int, help="launch gradio with given server port, you need root/admin rights for ports < 1024, defaults to 7860 if available", default=None)
|
parser.add_argument("--port", type=int, help="launch gradio with given server port, you need root/admin rights for ports < 1024, defaults to 7860 if available", default=None)
|
||||||
parser.add_argument("--show-negative-prompt", action='store_true', help="does not do anything", default=False)
|
parser.add_argument("--show-negative-prompt", action='store_true', help="does not do anything", default=False)
|
||||||
parser.add_argument("--ui-config-file", type=str, help="filename to use for ui configuration", default=os.path.join(script_path, 'ui-config.json'))
|
parser.add_argument("--ui-config-file", type=str, help="filename to use for ui configuration", default=os.path.join(script_path, 'ui-config.json'))
|
||||||
|
parser.add_argument("--hide-ui-dir-config", action='store_true', help="hide directory configuration from webui", default=False)
|
||||||
parser.add_argument("--ui-settings-file", type=str, help="filename to use for ui settings", default=os.path.join(script_path, 'config.json'))
|
parser.add_argument("--ui-settings-file", type=str, help="filename to use for ui settings", default=os.path.join(script_path, 'config.json'))
|
||||||
parser.add_argument("--gradio-debug", action='store_true', help="launch gradio with --debug option")
|
parser.add_argument("--gradio-debug", action='store_true', help="launch gradio with --debug option")
|
||||||
|
|
||||||
|
@ -92,19 +93,20 @@ class Options:
|
||||||
self.component_args = component_args
|
self.component_args = component_args
|
||||||
|
|
||||||
data = None
|
data = None
|
||||||
|
hide_dirs = {"visible": False} if cmd_opts.hide_ui_dir_config else None
|
||||||
data_labels = {
|
data_labels = {
|
||||||
"samples_filename_format": OptionInfo("", "Samples filename format using following tags: [STEPS],[CFG],[PROMPT],[PROMPT_SPACES],[WIDTH],[HEIGHT],[SAMPLER],[SEED]. Leave blank for default."),
|
"samples_filename_format": OptionInfo("", "Samples filename format using following tags: [STEPS],[CFG],[PROMPT],[PROMPT_SPACES],[WIDTH],[HEIGHT],[SAMPLER],[SEED]. Leave blank for default."),
|
||||||
"outdir_samples": OptionInfo("", "Output directory for images; if empty, defaults to two directories below"),
|
"outdir_samples": OptionInfo("", "Output directory for images; if empty, defaults to two directories below", component_args=hide_dirs),
|
||||||
"outdir_txt2img_samples": OptionInfo("outputs/txt2img-images", 'Output directory for txt2img images'),
|
"outdir_txt2img_samples": OptionInfo("outputs/txt2img-images", 'Output directory for txt2img images', component_args=hide_dirs),
|
||||||
"outdir_img2img_samples": OptionInfo("outputs/img2img-images", 'Output directory for img2img images'),
|
"outdir_img2img_samples": OptionInfo("outputs/img2img-images", 'Output directory for img2img images', component_args=hide_dirs),
|
||||||
"outdir_extras_samples": OptionInfo("outputs/extras-images", 'Output directory for images from extras tab'),
|
"outdir_extras_samples": OptionInfo("outputs/extras-images", 'Output directory for images from extras tab', component_args=hide_dirs),
|
||||||
"outdir_grids": OptionInfo("", "Output directory for grids; if empty, defaults to two directories below"),
|
"outdir_grids": OptionInfo("", "Output directory for grids; if empty, defaults to two directories below", component_args=hide_dirs),
|
||||||
"outdir_txt2img_grids": OptionInfo("outputs/txt2img-grids", 'Output directory for txt2img grids'),
|
"outdir_txt2img_grids": OptionInfo("outputs/txt2img-grids", 'Output directory for txt2img grids', component_args=hide_dirs),
|
||||||
"outdir_img2img_grids": OptionInfo("outputs/img2img-grids", 'Output directory for img2img grids'),
|
"outdir_img2img_grids": OptionInfo("outputs/img2img-grids", 'Output directory for img2img grids', component_args=hide_dirs),
|
||||||
"save_to_dirs": OptionInfo(False, "When writing images, create a directory with name derived from the prompt"),
|
"save_to_dirs": OptionInfo(False, "When writing images, create a directory with name derived from the prompt"),
|
||||||
"grid_save_to_dirs": OptionInfo(False, "When writing grids, create a directory with name derived from the prompt"),
|
"grid_save_to_dirs": OptionInfo(False, "When writing grids, create a directory with name derived from the prompt"),
|
||||||
"save_to_dirs_prompt_len": OptionInfo(10, "When using above, how many words from prompt to put into directory name", gr.Slider, {"minimum": 1, "maximum": 32, "step": 1}),
|
"save_to_dirs_prompt_len": OptionInfo(10, "When using above, how many words from prompt to put into directory name", gr.Slider, {"minimum": 1, "maximum": 32, "step": 1}),
|
||||||
"outdir_save": OptionInfo("log/images", "Directory for saving images using the Save button"),
|
"outdir_save": OptionInfo("log/images", "Directory for saving images using the Save button", component_args=hide_dirs),
|
||||||
"samples_save": OptionInfo(True, "Save indiviual samples"),
|
"samples_save": OptionInfo(True, "Save indiviual samples"),
|
||||||
"samples_format": OptionInfo('png', 'File format for individual samples'),
|
"samples_format": OptionInfo('png', 'File format for individual samples'),
|
||||||
"grid_save": OptionInfo(True, "Save image grids"),
|
"grid_save": OptionInfo(True, "Save image grids"),
|
||||||
|
|
|
@ -661,19 +661,20 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
||||||
info = opts.data_labels[key]
|
info = opts.data_labels[key]
|
||||||
t = type(info.default)
|
t = type(info.default)
|
||||||
|
|
||||||
if info.component is not None:
|
|
||||||
args = info.component_args() if callable(info.component_args) else info.component_args
|
args = info.component_args() if callable(info.component_args) else info.component_args
|
||||||
item = info.component(label=info.label, value=fun, **(args or {}))
|
|
||||||
|
if info.component is not None:
|
||||||
|
comp = info.component
|
||||||
elif t == str:
|
elif t == str:
|
||||||
item = gr.Textbox(label=info.label, value=fun, lines=1)
|
comp = gr.Textbox
|
||||||
elif t == int:
|
elif t == int:
|
||||||
item = gr.Number(label=info.label, value=fun)
|
comp = gr.Number
|
||||||
elif t == bool:
|
elif t == bool:
|
||||||
item = gr.Checkbox(label=info.label, value=fun)
|
comp = gr.Checkbox
|
||||||
else:
|
else:
|
||||||
raise Exception(f'bad options item type: {str(t)} for key {key}')
|
raise Exception(f'bad options item type: {str(t)} for key {key}')
|
||||||
|
|
||||||
return item
|
return comp(label=info.label, value=fun, **(args or {}))
|
||||||
|
|
||||||
components = []
|
components = []
|
||||||
keys = list(opts.data_labels.keys())
|
keys = list(opts.data_labels.keys())
|
||||||
|
@ -684,6 +685,10 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
||||||
up = []
|
up = []
|
||||||
|
|
||||||
for key, value, comp in zip(opts.data_labels.keys(), args, components):
|
for key, value, comp in zip(opts.data_labels.keys(), args, components):
|
||||||
|
comp_args = opts.data_labels[key].component_args
|
||||||
|
if comp_args and isinstance(comp_args, dict) and comp_args.get('visible') is False:
|
||||||
|
continue
|
||||||
|
|
||||||
opts.data[key] = value
|
opts.data[key] = value
|
||||||
up.append(comp.update(value=value))
|
up.append(comp.update(value=value))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user