From 9104bba22da778428cf24c4ee915e2b03c96afb1 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 25 Mar 2024 14:22:39 -0400 Subject: [PATCH] update ar and gallery permissions --- modules/api/gallery.py | 2 +- modules/ui_sections.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/api/gallery.py b/modules/api/gallery.py index f792da5d6..55afb1500 100644 --- a/modules/api/gallery.py +++ b/modules/api/gallery.py @@ -105,7 +105,7 @@ def register_api(app: FastAPI): # register api folders = [f for f in folders if os.path.isdir(f)] if shared.demo is not None: for f in folders: - if os.path.isabs(f) and f not in shared.demo.allowed_paths: + if f not in shared.demo.allowed_paths: debug(f'Browser folders allow: {f}') shared.demo.allowed_paths.append(quote(f)) debug(f'Browser folders: {folders}') diff --git a/modules/ui_sections.py b/modules/ui_sections.py index 5b4538b98..2f18c545e 100644 --- a/modules/ui_sections.py +++ b/modules/ui_sections.py @@ -56,6 +56,7 @@ def create_toprow(is_img2img: bool = False, id_part: str = None): def ar_change(ar, width, height): + """ if ar == 'AR': return gr.update(interactive=True), gr.update(interactive=True) try: @@ -69,6 +70,20 @@ def ar_change(ar, width, height): return gr.update(interactive=False, value=int(height * w / h)), gr.update(interactive=True, value=height) else: return gr.update(interactive=True, value=width), gr.update(interactive=False, value=width) + """ + if ar == 'AR': + return gr.update(), gr.update() + try: + (w, h) = [float(x) for x in ar.split(':')] + except Exception as e: + shared.log.warning(f"Invalid aspect ratio: {ar} {e}") + return gr.update(), gr.update() + if w > h: + return gr.update(), gr.update(value=int(width * h / w)) + elif w < h: + return gr.update(value=int(height * w / h)), gr.update() + else: + return gr.update(), gr.update() def create_resolution_inputs(tab):