|
|
@ -301,17 +301,35 @@ class LatentComposite:
|
|
|
|
"samples_from": ("LATENT",),
|
|
|
|
"samples_from": ("LATENT",),
|
|
|
|
"x": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}),
|
|
|
|
"x": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}),
|
|
|
|
"y": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}),
|
|
|
|
"y": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}),
|
|
|
|
|
|
|
|
"feather": ("INT", {"default": 0, "min": 0, "max": 4096, "step": 8}),
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
RETURN_TYPES = ("LATENT",)
|
|
|
|
RETURN_TYPES = ("LATENT",)
|
|
|
|
FUNCTION = "composite"
|
|
|
|
FUNCTION = "composite"
|
|
|
|
|
|
|
|
|
|
|
|
CATEGORY = "latent"
|
|
|
|
CATEGORY = "latent"
|
|
|
|
|
|
|
|
|
|
|
|
def composite(self, samples_to, samples_from, x, y, composite_method="normal"):
|
|
|
|
def composite(self, samples_to, samples_from, x, y, composite_method="normal", feather=0):
|
|
|
|
x = x // 8
|
|
|
|
x = x // 8
|
|
|
|
y = y // 8
|
|
|
|
y = y // 8
|
|
|
|
|
|
|
|
feather = feather // 8
|
|
|
|
s = samples_to.clone()
|
|
|
|
s = samples_to.clone()
|
|
|
|
s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x]
|
|
|
|
if feather == 0:
|
|
|
|
|
|
|
|
s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
s_from = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x]
|
|
|
|
|
|
|
|
mask = torch.ones_like(s_from)
|
|
|
|
|
|
|
|
for t in range(feather):
|
|
|
|
|
|
|
|
if y != 0:
|
|
|
|
|
|
|
|
mask[:,:,t:1+t,:] *= ((1.0/feather) * (t + 1))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if y + samples_from.shape[2] < samples_to.shape[2]:
|
|
|
|
|
|
|
|
mask[:,:,mask.shape[2] -1 -t: mask.shape[2]-t,:] *= ((1.0/feather) * (t + 1))
|
|
|
|
|
|
|
|
if x != 0:
|
|
|
|
|
|
|
|
mask[:,:,:,t:1+t] *= ((1.0/feather) * (t + 1))
|
|
|
|
|
|
|
|
if x + samples_from.shape[3] < samples_to.shape[3]:
|
|
|
|
|
|
|
|
mask[:,:,:,mask.shape[3]- 1 - t: mask.shape[3]- t] *= ((1.0/feather) * (t + 1))
|
|
|
|
|
|
|
|
rev_mask = torch.ones_like(mask) - mask
|
|
|
|
|
|
|
|
s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] = samples_from[:,:,:samples_to.shape[2] - y, :samples_to.shape[3] - x] * mask + s[:,:,y:y+samples_from.shape[2],x:x+samples_from.shape[3]] * rev_mask
|
|
|
|
return (s,)
|
|
|
|
return (s,)
|
|
|
|
|
|
|
|
|
|
|
|
class LatentCrop:
|
|
|
|
class LatentCrop:
|
|
|
|