Skip to content

Commit

Permalink
Merge pull request #8 from bmad4ever/feature-make-seamsless
Browse files Browse the repository at this point in the history
Minor fix & change
  • Loading branch information
bmad4ever authored Aug 26, 2024
2 parents 48dd2ca + deb3087 commit bb11a44
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For better context, see the examples below and the remaining workflows in the [w


### Vertically seamless texture example workflow
![latent quilting workflow](workflows/seamless%20image%20SB%20plus%20seamless%20sampling.png)
![latent quilting workflow](workflows/seamless%20image%20SP%20plus%20seamless%20sampling.png)
</details>


Expand Down Expand Up @@ -140,9 +140,11 @@ _________________________

Seamless nodes have the following additional inputs:

* **lookup**: the texture from which the patches are obtained; if no lookup is provided, the src is used instead.
* **lookup**: the texture from which the patches are obtained; if no lookup is provided, the src is used instead.
* **ori**: the orientation in which to make the texture seamless: `H` for horizontally; `V` for vertically; `H & V` for both.


When using Seamless SP nodes, the lookup must have at least the same width or height as the source, depending on the value of `ori`. To patch the texture horizontally, the lookup must have at least the same height, and to patch vertically, it must have at least the same width.

Additionally, overlap is constrained to 50% since at least two opposite sides overlap with the texture. While 50% is the maximum possible overlap, where both overlaps meet, this upper limit should not typically be used.
_________________________
### Make Seamless SP vs MP
Expand Down
16 changes: 8 additions & 8 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def INPUT_TYPES(cls):
inputs = get_quilting_shared_input_types()
inputs.pop("parallelization_lvl")
inputs.pop("tolerance")
inputs.pop("seed")
inputs["version"][1]["min"] = 1
inputs["overlap"][1]["max"] = .5
return {
Expand All @@ -603,13 +604,13 @@ def INPUT_TYPES(cls):
FUNCTION = "compute"
CATEGORY = NODES_CATEGORY

def compute(self, src, ori, block_size, overlap, seed, version, blend_into_patch, lookup=None):
def compute(self, src, ori, block_size, overlap, version, blend_into_patch, lookup=None):
# note that src = lookup is the current algorithm policy when lookup is not provided.
# this policy could change in the future, so do not apply it here too despite being idempotent.
h, _ = src.shape[1:3]
blk_size_upper_bound = block_size_upper_bound_for_seamless(ori, h, overlap)
block_sizes = get_block_sizes(src, block_size, blk_size_upper_bound)
rng: numpy.random.Generator = np.random.default_rng(seed=seed)
rng: numpy.random.Generator = np.random.default_rng(seed=0)

lookup_batch_size = lookup.shape[0] if lookup is not None else 0
finish_event, t, shm_name, shm_jobs = setup_pbar_seamless_v2(ori, max(src.shape[0], lookup_batch_size))
Expand Down Expand Up @@ -734,13 +735,12 @@ def __call__(self, latent, lookup, job_id):
overlap = overlap_percentage_to_pixels(self.block_size, self.overlap)
validate_seamless_args(self.ori, latent, lookup, self.block_size, overlap)
gen_args = GenParams(self.block_size, overlap, 0, self.blend_into_patch, self.version)

return func(latent, gen_args, lookup, self.rng, UiCoordData(self.jobs_shm_name, job_id))
return func(latent, lookup, gen_args, self.rng, UiCoordData(self.jobs_shm_name, job_id))

@classmethod
def INPUT_TYPES(cls):
inputs = LatentQuilting.INPUT_TYPES()["required"] #get_quilting_shared_input_types()
for to_remove in ["tolerance", "parallelization_lvl", "scale", "src"]:
inputs = LatentQuilting.INPUT_TYPES()["required"]
for to_remove in ["tolerance", "parallelization_lvl", "scale", "src", "seed"]:
inputs.pop(to_remove)
inputs["version"][1]["min"] = 1
inputs["overlap"][1]["max"] = .5
Expand All @@ -759,10 +759,10 @@ def INPUT_TYPES(cls):
FUNCTION = "compute"
CATEGORY = NODES_CATEGORY

def compute(self, src, ori, block_size, overlap, seed, version, blend_into_patch, lookup=None):
def compute(self, src, ori, block_size, overlap, version, blend_into_patch, lookup=None):
src = src["samples"]
lookup = lookup["samples"] if lookup is not None else None
rng: numpy.random.Generator = np.random.default_rng(seed=seed)
rng: numpy.random.Generator = np.random.default_rng(seed=0)

lookup_batch_size = lookup.shape[0] if lookup is not None else 0
finish_event, t, shm_name, shm_jobs = setup_pbar_seamless_v2(ori, max(src.shape[0], lookup_batch_size))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui_quilting"
description = "image and latent quilting nodes for comfyui"
version = "2.0.0"
version = "2.1.1"
license = {text = "MIT License"}
dependencies = [
"joblib~=1.3.2",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit bb11a44

Please sign in to comment.