diff --git a/README.md b/README.md index eaf0716..a457cc2 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,9 @@ Check ComfyUI here: https://github.com/comfyanonymous/ComfyUI - `fill_holes`: Whether to fully fill any holes (small or large) in the mask, that is, mark fully enclosed areas as part of the mask. - `blur_radius_pixels`: Whether to blur the mask, to be used in combination with `grow_mask_pixels`. Some models prefer blurred masks, some don't. - `adjust_to_preferred_sizes`: This will try to have width and/or height of the context area match any of the sizes in `preferred_sizes` by growing the context area (not upscaling), e.g. 512, 1024. Some models prefer this. +- `preferred_sizes`: Comma-separated list of preferred sizes, e.g. "512,1024". Default is 1024 because it fits most of the use cases of this feature. - `prefer_square_size`: This will try to have width=height (if possible). Some models prefer this. -- `internal_upscale_factor`: Upscale the image and mask between the crop and stitch phases. This means the sampling happens only around the context area but at a higher resolution (e.g. 2 for x2), then it is downsampled and merged with the original image. This in practice gets more details from models. If you want to obtain a higher resolution image, please upscale it before cropping/sampling/stitching. +- `internal_upscale_factor`: Upscale the image and mask between the crop and stitch phases. This means the sampling happens only around the context area but at a higher resolution (e.g. 2 for x2), then it is downsampled and merged with the original image. This in practice gets more details from models. If you want to obtain a higher resolution image, please upscale it before cropping/sampling/stitching. This can also be lower than 1 for the rare cases you need it, such as the original image too large and the model generating double heads. ## Simple example This example inpaints by sampling on a small section of the larger image. It runs ~20x faster than sampling on the whole image. diff --git a/__pycache__/__init__.cpython-311.pyc b/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..e73a111 Binary files /dev/null and b/__pycache__/__init__.cpython-311.pyc differ diff --git a/__pycache__/inpaint_cropandstitch.cpython-311.pyc b/__pycache__/inpaint_cropandstitch.cpython-311.pyc new file mode 100644 index 0000000..008e1d9 Binary files /dev/null and b/__pycache__/inpaint_cropandstitch.cpython-311.pyc differ diff --git a/inpaint_cropandstitch.py b/inpaint_cropandstitch.py index 6349ca2..706f488 100644 --- a/inpaint_cropandstitch.py +++ b/inpaint_cropandstitch.py @@ -26,9 +26,9 @@ class InpaintCrop: "fill_holes": ("BOOLEAN", {"default": False}), "blur_radius_pixels": ("FLOAT", {"default": 3.0, "min": 0.0, "max": nodes.MAX_RESOLUTION, "step": 0.1}), "adjust_to_preferred_sizes": ("BOOLEAN", {"default": False}), - "preferred_sizes": ("STRING", {"default": "128,256,512,768,1024,1344,1536,2048"}), + "preferred_sizes": ("STRING", {"default": "1024"}), "prefer_square_size": ("BOOLEAN", {"default": False}), - "internal_upscale_factor": ("FLOAT", {"default": 1.00, "min": 1.0, "max": 100.0, "step": 0.01}), + "internal_upscale_factor": ("FLOAT", {"default": 1.00, "min": 0.01, "max": 100.0, "step": 0.01}), }, "optional": { "optional_context_mask": ("MASK",), @@ -111,7 +111,7 @@ class InpaintCrop: # Upscale image and masks if requested, they will be downsized at stitch phase effective_upscale_factor_x = 1.0 effective_upscale_factor_y = 1.0 - if internal_upscale_factor > 1.001: + if internal_upscale_factor < 0.999 or internal_upscale_factor > 1.001: samples = image samples = samples.movedim(-1, 1) width = round(samples.shape[3] * internal_upscale_factor) @@ -272,7 +272,7 @@ class InpaintStitch: inpaint_height = inpainted_image.shape[1] # Downscale inpainted before stitching if we upscaled it before - if stitch['rescale_x'] > 1.001 or stitch['rescale_y'] > 1.001: + if stitch['rescale_x'] < 0.999 or stitch['rescale_x'] > 1.001 or stitch['rescale_y'] < 0.999 or stitch['rescale_y'] > 1.001: samples = inpainted_image.movedim(-1, 1) width = round(float(inpaint_width)/stitch['rescale_x']) height = round(float(inpaint_height)/stitch['rescale_y'])