From ec40acf7f71d1c40b026bfa774f6a1bc15c1aaee Mon Sep 17 00:00:00 2001 From: shiimizu Date: Tue, 30 Jan 2024 18:59:39 -0800 Subject: [PATCH] Support GLIGEN. --- README.md | 4 +--- utils.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c40d667..baf9d65 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,6 @@ This extension enables **large image drawing & upscaling with limited VRAM** via - [x] Img2img upscale - [x] Ultra-Large image generation -Some conditioning nodes like SetArea or GLIGEN aren't working at the moment. - ## Tiled Diffusion
@@ -35,7 +33,7 @@ Some conditioning nodes like SetArea or GLIGEN aren't working at the moment. | Name | Description | |-------------------|--------------------------------------------------------------| -| `method` | Tiling strategy. `MultiDiffusion` or `Mixture of Diffusers`. | +| `method` | Tiling [strategy](https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111/blob/fbb24736c9bc374c7f098f82b575fcd14a73936a/scripts/tilediffusion.py#L39-L46). `MultiDiffusion` or `Mixture of Diffusers`. | | `tile_width` | Tile's width | | `tile_height` | Tile's height | | `tile_overlap` | Tile's overlap | diff --git a/utils.py b/utils.py index 6ed3a3e..97a2323 100644 --- a/utils.py +++ b/utils.py @@ -98,6 +98,18 @@ def hook_samplers_pre_run_control(): fn = inject_code(pre_run_control, payload) return create_hook(fn, 'comfy.samplers') +def hook_gligen__set_position(): + from comfy.gligen import Gligen + payload = [{ + "target_line": "module = self.module_list[key]", + "code_to_insert": """ + nonlocal objs + if x.shape[0] > objs.shape[0]: + objs = objs.repeat(-(x.shape[0] // -objs.shape[0]),1,1) + """}] + fn = inject_code(Gligen._set_position, payload, 'a') + return create_hook(fn, 'comfy.gligen', 'Gligen._set_position', 'Gligen._set_position') + def create_hook(fn, module_name:str, target = None, orig_key = None): if target is None: target = fn.__name__ if orig_key is None: orig_key = f'{target}_original' @@ -131,6 +143,7 @@ def hook_all(restore=False, hooks=None): hook_calc_cond_uncond_batch(), hook_sag_create_blur_map(), hook_samplers_pre_run_control(), + hook_gligen__set_position(), ] for m in sys.modules: for hook in hooks: