mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-14 15:24:34 +08:00
Update nodes.py
This commit is contained in:
parent
b0938d7908
commit
4a2ae659c1
13
nodes.py
13
nodes.py
@ -1992,19 +1992,22 @@ class OffsetMask:
|
|||||||
if shift_y != 0:
|
if shift_y != 0:
|
||||||
mask = torch.roll(mask, shifts=shift_y, dims=1)
|
mask = torch.roll(mask, shifts=shift_y, dims=1)
|
||||||
else:
|
else:
|
||||||
if incremental:
|
|
||||||
for i in range(batch_size):
|
for i in range(batch_size):
|
||||||
|
if incremental:
|
||||||
temp_x = min(x * (i+1), width-1)
|
temp_x = min(x * (i+1), width-1)
|
||||||
temp_y = min(y * (i+1), height-1)
|
temp_y = min(y * (i+1), height-1)
|
||||||
|
else:
|
||||||
|
temp_x = min(x, width-1)
|
||||||
|
temp_y = min(y, height-1)
|
||||||
if temp_x > 0:
|
if temp_x > 0:
|
||||||
if padding_mode == 'empty':
|
if padding_mode == 'empty':
|
||||||
mask[i] = torch.cat([torch.zeros((height, temp_x)), mask[i, :, :-temp_x]], dim=1)
|
mask[i] = torch.cat([torch.zeros((height, temp_x)), mask[i, :, :-temp_x]], dim=1)
|
||||||
elif padding_mode in ['replicate', 'reflect']:
|
elif padding_mode in ['replicate', 'reflect']:
|
||||||
mask[i] = pad(mask[i, :, :-temp_x], (0, temp_x), mode=padding_mode)
|
mask[i] = pad(mask[i, :, :-temp_x], (0, temp_x), mode=padding_mode)
|
||||||
|
|
||||||
elif temp_x < 0:
|
elif temp_x < 0:
|
||||||
if padding_mode == 'empty':
|
if padding_mode == 'empty':
|
||||||
mask[i] = torch.cat([mask[i, :, -temp_x:], torch.zeros((height, -temp_x))], dim=1)
|
mask[i] = torch.cat([mask[i, :, :temp_x], torch.zeros((height, -temp_x))], dim=1)
|
||||||
elif padding_mode in ['replicate', 'reflect']:
|
elif padding_mode in ['replicate', 'reflect']:
|
||||||
mask[i] = pad(mask[i, :, -temp_x:], (temp_x, 0), mode=padding_mode)
|
mask[i] = pad(mask[i, :, -temp_x:], (temp_x, 0), mode=padding_mode)
|
||||||
|
|
||||||
@ -2013,12 +2016,12 @@ class OffsetMask:
|
|||||||
mask[i] = torch.cat([torch.zeros((temp_y, width)), mask[i, :-temp_y, :]], dim=0)
|
mask[i] = torch.cat([torch.zeros((temp_y, width)), mask[i, :-temp_y, :]], dim=0)
|
||||||
elif padding_mode in ['replicate', 'reflect']:
|
elif padding_mode in ['replicate', 'reflect']:
|
||||||
mask[i] = pad(mask[i, :-temp_y, :], (0, temp_y), mode=padding_mode)
|
mask[i] = pad(mask[i, :-temp_y, :], (0, temp_y), mode=padding_mode)
|
||||||
|
|
||||||
elif temp_y < 0:
|
elif temp_y < 0:
|
||||||
if padding_mode == 'empty':
|
if padding_mode == 'empty':
|
||||||
mask[i] = torch.cat([mask[i, -temp_y:, :], torch.zeros((-temp_y, width))], dim=0)
|
mask[i] = torch.cat([mask[i, :temp_y, :], torch.zeros((-temp_y, width))], dim=0)
|
||||||
elif padding_mode in ['replicate', 'reflect']:
|
elif padding_mode in ['replicate', 'reflect']:
|
||||||
mask[i] = pad(mask[i, -temp_y:, :], (temp_y, 0), mode=padding_mode)
|
mask[i] = pad(mask[i, -temp_y:, :], (temp_y, 0), mode=padding_mode)
|
||||||
|
|
||||||
return mask,
|
return mask,
|
||||||
|
|
||||||
class WidgetToString:
|
class WidgetToString:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user