mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
Submodule extensions-builtin/sdnext-modernui updated: b987359783...235e3f71ab
@@ -23,7 +23,7 @@ def fix_prompt_batch(p, prompts, negative_prompts, prompts_2, negative_prompts_2
|
||||
if type(negative_prompts) is str:
|
||||
negative_prompts = [negative_prompts]
|
||||
|
||||
if hasattr(p, 'init_images') and p.init_images is not None and len(p.init_images) > 1:
|
||||
if hasattr(p, 'init_images') and (p.init_images is not None) and (len(p.init_images) > 1) and not getattr(p, 'skip_processing', False):
|
||||
while len(prompts) < len(p.init_images):
|
||||
prompts.append(prompts[-1] if prompts else '')
|
||||
while len(negative_prompts) < len(p.init_images):
|
||||
|
||||
@@ -77,19 +77,23 @@ class NaPatchIn(PatchIn):
|
||||
self,
|
||||
vid: torch.Tensor, # l c
|
||||
vid_shape: torch.LongTensor,
|
||||
cache: Cache = Cache(disable=True),
|
||||
) -> torch.Tensor:
|
||||
cache = cache.namespace("patch")
|
||||
vid_shape_before_patchify = cache("vid_shape_before_patchify", lambda: vid_shape)
|
||||
t, h, w = self.patch_size
|
||||
if not t == h == w == 1:
|
||||
vid, vid_shape = na.rearrange(
|
||||
vid, vid_shape, "(T t) (H h) (W w) c -> T H W (t h w c)", t=t, h=h, w=w
|
||||
)
|
||||
vid = na.unflatten(vid, vid_shape)
|
||||
for i in range(len(vid)):
|
||||
if h > 1 and vid_shape[i, 1] % h != 0:
|
||||
if t > 1 and vid_shape_before_patchify[i, 0] % t != 0:
|
||||
vid[i] = torch.cat([vid[i][:1]] * (t - vid[i].size(0) % t) + [vid[i]], dim=0)
|
||||
if h > 1 and vid_shape_before_patchify[i, 1] % h != 0:
|
||||
vid[i] = torch.cat([vid[i][:, :1]] * (h - vid[i].size(1) % h) + [vid[i]], dim=1)
|
||||
if w > 1 and vid_shape[i, 2] % w != 0:
|
||||
if w > 1 and vid_shape_before_patchify[i, 2] % w != 0:
|
||||
vid[i] = torch.cat([vid[i][:, :, :1]] * (w - vid[i].size(2) % w) + [vid[i]], dim=2)
|
||||
vid[i] = rearrange(vid[i], "(T t) (H h) (W w) c -> T H W (t h w c)", t=t, h=h, w=w)
|
||||
vid, vid_shape = na.flatten(vid)
|
||||
# slice vid after patching in when using sequence parallelism
|
||||
# slice vid after patchting in when using sequence parallelism
|
||||
vid = slice_inputs(vid, dim=0)
|
||||
if vid.dtype != self.proj.weight.dtype:
|
||||
vid = vid.to(self.proj.weight.dtype)
|
||||
@@ -107,6 +111,8 @@ class NaPatchOut(PatchOut):
|
||||
torch.FloatTensor,
|
||||
torch.LongTensor,
|
||||
]:
|
||||
cache = cache.namespace("patch")
|
||||
vid_shape_before_patchify = cache.get("vid_shape_before_patchify")
|
||||
t, h, w = self.patch_size
|
||||
if vid.dtype != self.proj.weight.dtype:
|
||||
vid = vid.to(self.proj.weight.dtype)
|
||||
@@ -120,12 +126,14 @@ class NaPatchOut(PatchOut):
|
||||
cache=cache.namespace("vid"),
|
||||
)
|
||||
if not t == h == w == 1:
|
||||
vid, vid_shape = na.rearrange(
|
||||
vid, vid_shape, "T H W (t h w c) -> (T t) (H h) (W w) c", t=t, h=h, w=w
|
||||
)
|
||||
vid = na.unflatten(vid, vid_shape)
|
||||
for i in range(len(vid)):
|
||||
if h > 1 and vid_shape[i, 1] % h != 0:
|
||||
vid[i] = vid[i][:, (h - vid_shape[i, 1] % h) :]
|
||||
if w > 1 and vid_shape[i, 2] % w != 0:
|
||||
vid[i] = vid[i][:, :, (w - vid_shape[i, 2] % w) :]
|
||||
vid[i] = rearrange(vid[i], "T H W (t h w c) -> (T t) (H h) (W w) c", t=t, h=h, w=w)
|
||||
if t > 1 and vid_shape_before_patchify is not None and vid_shape_before_patchify[i, 0] % t != 0:
|
||||
vid[i] = vid[i][(t - vid_shape_before_patchify[i, 0] % t) :]
|
||||
if h > 1 and vid_shape_before_patchify is not None and vid_shape_before_patchify[i, 1] % h != 0:
|
||||
vid[i] = vid[i][:, (h - vid_shape_before_patchify[i, 1] % h) :]
|
||||
if w > 1 and vid_shape_before_patchify is not None and vid_shape_before_patchify[i, 2] % w != 0:
|
||||
vid[i] = vid[i][:, :, (w - vid_shape_before_patchify[i, 2] % w) :]
|
||||
vid, vid_shape = na.flatten(vid)
|
||||
return vid, vid_shape
|
||||
|
||||
Reference in New Issue
Block a user