diff --git a/TODO.md b/TODO.md index 2a6b118d3..ed0b7c875 100644 --- a/TODO.md +++ b/TODO.md @@ -21,6 +21,7 @@ Stuff to be added... - Stream-load models as option for slow storage - AMD optimizations - Apple optimizations +- Support multiple models locations ## Investigate diff --git a/javascript/dragdrop.js b/javascript/dragdrop.js index e4cd41ec4..9015e4bd5 100644 --- a/javascript/dragdrop.js +++ b/javascript/dragdrop.js @@ -5,17 +5,13 @@ function isValidImageList( files ) { } function dropReplaceImage( imgWrap, files ) { - if ( ! isValidImageList( files ) ) { - return; - } - + if (!isValidImageList(files)) return; const tmpFile = files[0]; - imgWrap.querySelector('.modify-upload button + button, .touch-none + div button + button')?.click(); const callback = () => { const fileInput = imgWrap.querySelector('input[type="file"]'); - if ( fileInput ) { - if ( files.length === 0 ) { + if (fileInput) { + if (files.length === 0) { files = new DataTransfer(); files.items.add(tmpFile); fileInput.files = files.files; @@ -26,7 +22,7 @@ function dropReplaceImage( imgWrap, files ) { } }; - if ( imgWrap.closest('#pnginfo_image') ) { + if (imgWrap.closest('#pnginfo_image')) { // special treatment for PNG Info tab, wait for fetch request to finish const oldFetch = window.fetch; window.fetch = async (input, options) => { @@ -44,16 +40,14 @@ function dropReplaceImage( imgWrap, files ) { return response; }; } else { - window.requestAnimationFrame( () => callback() ); + window.requestAnimationFrame(() => callback()); } } window.document.addEventListener('dragover', e => { const target = e.composedPath()[0]; const imgWrap = target.closest('[data-testid="image"]'); - if ( !imgWrap && target.placeholder && target.placeholder.indexOf("Prompt") == -1) { - return; - } + if ( !imgWrap && target.placeholder && target.placeholder.indexOf("Prompt") == -1) return; e.stopPropagation(); e.preventDefault(); e.dataTransfer.dropEffect = 'copy'; @@ -62,37 +56,20 @@ window.document.addEventListener('dragover', e => { window.document.addEventListener('drop', e => { const target = e.composedPath()[0]; if (!target.placeholder) return; - if (target.placeholder.indexOf("Prompt") == -1) { - return; - } + if (target.placeholder.indexOf("Prompt") == -1) return; const imgWrap = target.closest('[data-testid="image"]'); - if ( !imgWrap ) { - return; - } + if (!imgWrap) return; e.stopPropagation(); e.preventDefault(); const files = e.dataTransfer.files; - dropReplaceImage( imgWrap, files ); + dropReplaceImage(imgWrap, files); }); window.addEventListener('paste', e => { const files = e.clipboardData.files; - if ( ! isValidImageList( files ) ) { - return; - } - - const visibleImageFields = [...gradioApp().querySelectorAll('[data-testid="image"]')] - .filter(el => uiElementIsVisible(el)); - if ( ! visibleImageFields.length ) { - return; - } - - const firstFreeImageField = visibleImageFields - .filter(el => el.querySelector('input[type=file]'))?.[0]; - - dropReplaceImage( - firstFreeImageField ? - firstFreeImageField : - visibleImageFields[visibleImageFields.length - 1] - , files ); + if ( ! isValidImageList( files ) ) return; + const visibleImageFields = [...gradioApp().querySelectorAll('[data-testid="image"]')].filter(el => uiElementIsVisible(el)); + if ( ! visibleImageFields.length ) return; + const firstFreeImageField = visibleImageFields.filter(el => el.querySelector('input[type=file]'))?.[0]; + dropReplaceImage(firstFreeImageField ? firstFreeImageField : visibleImageFields[visibleImageFields.length - 1], files); }); diff --git a/modules/scripts_auto_postprocessing.py b/modules/scripts_auto_postprocessing.py index 30d6d6586..e37c977fc 100644 --- a/modules/scripts_auto_postprocessing.py +++ b/modules/scripts_auto_postprocessing.py @@ -27,15 +27,11 @@ class ScriptPostprocessingForMainUI(scripts.Script): def create_auto_preprocessing_script_data(): - from modules import scripts - res = [] - for name in shared.opts.postprocessing_enable_in_main_ui: script = next(iter([x for x in scripts.postprocessing_scripts_data if x.script_class.name == name]), None) if script is None: continue - constructor = lambda s=script: ScriptPostprocessingForMainUI(s.script_class()) res.append(scripts.ScriptClassData(script_class=constructor, path=script.path, basedir=script.basedir, module=script.module)) diff --git a/modules/shared.py b/modules/shared.py index b234d2d2a..e7d504a3b 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -20,6 +20,7 @@ errors.install(gr) demo: gr.Blocks = None log = setup_log parser = cmd_args.parser +url = 'https://github.com/vladmandic/automatic' if os.environ.get('IGNORE_CMD_ARGS_ERRORS', None) is None: cmd_opts = parser.parse_args() diff --git a/modules/ui.py b/modules/ui.py index 0e8bd192a..811e9261a 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -926,31 +926,6 @@ def create_ui(): with gr.Blocks(analytics_enabled=False) as extras_interface: ui_postprocessing.create_ui() - """ - with gr.Blocks(analytics_enabled=False) as pnginfo_interface: - with gr.Row().style(equal_height=False): - with gr.Column(variant='panel'): - image = gr.Image(elem_id="pnginfo_image", label="Source", source="upload", interactive=True, type="pil") - - with gr.Column(variant='panel'): - html = gr.HTML() - generation_info = gr.Textbox(visible=False, elem_id="pnginfo_generation_info") - html2 = gr.HTML() - with gr.Row(): - buttons = parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"]) - - for tabname, button in buttons.items(): - parameters_copypaste.register_paste_params_button(parameters_copypaste.ParamBinding( - paste_button=button, tabname=tabname, source_text_component=generation_info, source_image_component=image, - )) - - image.change( - fn=wrap_gradio_call(modules.extras.run_pnginfo), - inputs=[image], - outputs=[html, generation_info, html2], - ) - """ - def update_interp_description(value): interp_description_css = "
{}
" interp_descriptions = {