diff --git a/extensions-builtin/sdnext-modernui b/extensions-builtin/sdnext-modernui index f14464f3f..bbb5f99e6 160000 --- a/extensions-builtin/sdnext-modernui +++ b/extensions-builtin/sdnext-modernui @@ -1 +1 @@ -Subproject commit f14464f3f7bb0de9ef854a40f7f56f8dd0378f42 +Subproject commit bbb5f99e6e103a1fe32ca43ca8f2fd4552c5dd09 diff --git a/installer.py b/installer.py index fb195112f..d3d842fa5 100644 --- a/installer.py +++ b/installer.py @@ -1445,21 +1445,29 @@ def get_version(force=False): version = { 'app': 'sd.next', 'version': 'unknown', 'branch': 'unknown' } cwd = os.getcwd() try: - os.chdir('extensions-builtin/sdnext-modernui') - res = subprocess.run('git rev-parse --abbrev-ref HEAD', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True) - branch_ui = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else '' - branch_ui = 'dev' if 'dev' in branch_ui else 'main' - version['ui'] = branch_ui + if os.path.exists('extensions-builtin/sdnext-modernui'): + os.chdir('extensions-builtin/sdnext-modernui') + res = subprocess.run('git rev-parse --abbrev-ref HEAD', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True) + branch_ui = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else '' + branch_ui = 'dev' if 'dev' in branch_ui else 'main' + version['ui'] = branch_ui + else: + version['ui'] = 'unavailable' except Exception: version['ui'] = 'unknown' finally: os.chdir(cwd) try: - os.chdir('extensions-builtin/sdnext-kanvas') - res = subprocess.run('git rev-parse --abbrev-ref HEAD', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True) - branch_kanvas = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else '' - branch_kanvas = 'dev' if 'dev' in branch_kanvas else 'main' - version['kanvas'] = branch_kanvas + if os.environ.get('SD_KANVAS_DISABLE', None) is not None: + version['kanvas'] = 'disabled' + elif os.path.exists('extensions-builtin/sdnext-kanvas'): + os.chdir('extensions-builtin/sdnext-kanvas') + res = subprocess.run('git rev-parse --abbrev-ref HEAD', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True, check=True) + branch_kanvas = res.stdout.decode(encoding = 'utf8', errors='ignore') if len(res.stdout) > 0 else '' + branch_kanvas = 'dev' if 'dev' in branch_kanvas else 'main' + version['kanvas'] = branch_kanvas + else: + version['kanvas'] = 'unavailable' except Exception: version['kanvas'] = 'unknown' finally: diff --git a/modules/devices.py b/modules/devices.py index f8ef7d3d1..facdcff4a 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -458,9 +458,9 @@ def set_sdpa_params(): log.warning(f'Torch attention: type="sdpa" {err}') try: - torch.backends.cuda.enable_flash_sdp('Flash' in opts.sdp_options) - torch.backends.cuda.enable_mem_efficient_sdp('Memory' in opts.sdp_options) - torch.backends.cuda.enable_math_sdp('Math' in opts.sdp_options) + torch.backends.cuda.enable_flash_sdp('Flash' in opts.sdp_options or 'Flash attention' in opts.sdp_options) + torch.backends.cuda.enable_mem_efficient_sdp('Memory' in opts.sdp_options or 'Memory attention' in opts.sdp_options) + torch.backends.cuda.enable_math_sdp('Math' in opts.sdp_options or 'Math attention' in opts.sdp_options) if hasattr(torch.backends.cuda, "allow_fp16_bf16_reduction_math_sdp"): # only valid for torch >= 2.5 torch.backends.cuda.allow_fp16_bf16_reduction_math_sdp(True) log.debug(f'Torch attention: type="sdpa" kernels={opts.sdp_options} overrides={opts.sdp_overrides}') diff --git a/modules/images_resize.py b/modules/images_resize.py index 03646484e..1f2ba0cea 100644 --- a/modules/images_resize.py +++ b/modules/images_resize.py @@ -154,5 +154,6 @@ def resize_image(resize_mode: int, im: Union[Image.Image, torch.Tensor], width: shared.log.error(f'Invalid resize mode: {resize_mode}') t1 = time.time() fn = f'{sys._getframe(2).f_code.co_name}:{sys._getframe(1).f_code.co_name}' # pylint: disable=protected-access - shared.log.debug(f'Image resize: source={im.width}:{im.height} target={width}:{height} mode="{shared.resize_modes[resize_mode]}" upscaler="{upscaler_name}" type={output_type} time={t1-t0:.2f} fn={fn}') # pylint: disable=protected-access + if im.width != width or im.height != height: + shared.log.debug(f'Image resize: source={im.width}:{im.height} target={width}:{height} mode="{shared.resize_modes[resize_mode]}" upscaler="{upscaler_name}" type={output_type} time={t1-t0:.2f} fn={fn}') # pylint: disable=protected-access return np.array(res) if output_type == 'np' else res diff --git a/modules/ui_control.py b/modules/ui_control.py index a9d2bb801..9671f01d5 100644 --- a/modules/ui_control.py +++ b/modules/ui_control.py @@ -5,6 +5,7 @@ from modules.control import unit from modules import errors, shared, progress, generation_parameters_copypaste, call_queue, scripts_manager, masking, images, processing_vae, timer # pylint: disable=ungrouped-imports from modules import ui_common, ui_sections, ui_guidance from modules import ui_control_helpers as helpers +import installer gr_height = 512 @@ -185,9 +186,11 @@ def create_ui(_blocks: gr.Blocks=None): with gr.Tabs(elem_classes=['control-tabs'], elem_id='control-tab-input'): input_mode = gr.Label(value='select', visible=False) with gr.Tab('Image', id='in-image') as tab_image: - input_image = gr.HTML(value="Kanvas placeholder", elem_id='control_input_select') - input_changed = gr.Button('Kanvas change', elem_id='control_input_change', visible=False) - # input_image = gr.Image(label="Input", show_label=False, type="pil", interactive=True, tool="editor", height=gr_height, image_mode='RGB', elem_id='control_input_select', elem_classes=['control-image']) + if (installer.version['kanvas'] == 'disabled') or (installer.version['kanvas'] == 'unavailable'): + input_image = gr.Image(label="Input", show_label=False, type="pil", interactive=True, tool="editor", height=gr_height, image_mode='RGB', elem_id='control_input_select', elem_classes=['control-image']) + else: + input_image = gr.HTML(value='

Kanvas not initialized

', elem_id='kanvas-container') + input_changed = gr.Button('Kanvas change', elem_id='kanvas-change-button', visible=False) btn_interrogate = ui_sections.create_interrogate_button('control', what='input') with gr.Tab('Video', id='in-video') as tab_video: input_video = gr.Video(label="Input", show_label=False, interactive=True, height=gr_height, elem_classes=['control-image']) diff --git a/modules/ui_control_helpers.py b/modules/ui_control_helpers.py index 7794c5c58..99504491a 100644 --- a/modules/ui_control_helpers.py +++ b/modules/ui_control_helpers.py @@ -52,6 +52,7 @@ def interrogate(): prompt = None if input_source is None or len(input_source) == 0: shared.log.warning('Interrogate: no input source') + return prompt try: from modules.interrogate.interrogate import interrogate as interrogate_fn prompt = interrogate_fn(input_source[0]) diff --git a/modules/ui_javascript.py b/modules/ui_javascript.py index 1897d1b58..49ff5d157 100644 --- a/modules/ui_javascript.py +++ b/modules/ui_javascript.py @@ -102,8 +102,7 @@ def reload_javascript(): css_base = theme.reload_gradio_theme() css_timesheet = "timesheet.css" - css_kanvas = "kanvas.css" - css = html_css([css_base, css_timesheet, css_kanvas]) + css = html_css([css_base, css_timesheet]) body = html_body() def template_response(*args, **kwargs): diff --git a/webui.py b/webui.py index 8dc29d5bc..0b6e2b109 100644 --- a/webui.py +++ b/webui.py @@ -12,7 +12,7 @@ from threading import Thread import modules.loader import modules.hashes -from installer import log, git_commit, custom_excepthook +from installer import log, git_commit, custom_excepthook, version from modules import timer, paths, shared, extensions, gr_tempdir, modelloader, modeldata from modules.call_queue import queue_lock, wrap_queued_call, wrap_gradio_gpu_call # pylint: disable=unused-import import modules.devices @@ -263,6 +263,7 @@ def mount_subpath(app): def start_ui(): log.debug('UI start sequence') + log.debug(f'UI image support: kanvas={version["kanvas"]}') modules.script_callbacks.before_ui_callback() timer.startup.record("before-ui") shared.demo = modules.ui.create_ui(timer.startup) diff --git a/wiki b/wiki index 3e40abb7e..9e9871c5a 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 3e40abb7ea2530d91f376c676a61d119434f9551 +Subproject commit 9e9871c5acda37d2101a09d456c7fccc0f56a518