Skip to content

Commit

Permalink
Merge branch 'comfyanonymous:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pythongosssss authored Feb 12, 2023
2 parents 9d1edfd + 3fd6b70 commit f558942
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
22 changes: 20 additions & 2 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,35 @@ def INPUT_TYPES(s):
"samples_from": ("LATENT",),
"x": ("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",)
FUNCTION = "composite"

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
y = y // 8
feather = feather // 8
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,)

class LatentCrop:
Expand Down
16 changes: 15 additions & 1 deletion webshit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
<link rel="stylesheet" type="text/css" href="litegraph.css">
<script type="text/javascript" src="litegraph.core.js"></script>
</head>
<style>
.customtext_input {
background-color: #FFFFFF;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #202020;
}
.customtext_input {
background-color: #202020;
color: white;
}
}
</style>
<body style='width:100%; height:100%; overflow: hidden;'>
<style>
.modal {
Expand Down Expand Up @@ -198,7 +212,7 @@
};
w.input_div = document.createElement('div');
w.input_div.contentEditable = true;
w.input_div.style.backgroundColor = "#FFFFFF";
w.input_div.className = "customtext_input";
w.input_div.style.overflow = 'hidden';
w.input_div.style.overflowY = 'auto';
w.input_div.style.padding = 2;
Expand Down

0 comments on commit f558942

Please sign in to comment.