Skip to content

Commit

Permalink
build: update requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
brycedrennan committed Sep 22, 2024
1 parent dc64ce2 commit 43ea730
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 109 deletions.
8 changes: 4 additions & 4 deletions imaginairy/cli/clickshell_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ def invoke_(self, arg): # pylint: disable=unused-argument
return False

invoke_ = update_wrapper(invoke_, command.callback)
invoke_.__name__ = "do_%s" % command.name
invoke_.__name__ = f"do_{command.name}"
return invoke_


class ModClickShell(ClickShell):
def add_command(self, cmd, name):
# Use the MethodType to add these as bound methods to our current instance
setattr(self, "do_%s" % name, get_method_type(mod_get_invoke(cmd), self))
setattr(self, "help_%s" % name, get_method_type(get_help(cmd), self))
setattr(self, "complete_%s" % name, get_method_type(get_complete(cmd), self))
setattr(self, f"do_{name}", get_method_type(mod_get_invoke(cmd), self))
setattr(self, f"help_{name}", get_method_type(get_help(cmd), self))
setattr(self, f"complete_{name}", get_method_type(get_complete(cmd), self))


class ModShell(Shell):
Expand Down
4 changes: 2 additions & 2 deletions imaginairy/enhancers/video_interpolation/rife/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ def pad_image(img):
if montage:
write_buffer.put(np.concatenate((lastframe, lastframe), 1))
for mid in output:
mid = (mid[0] * 255.0).byte().cpu().numpy().transpose(1, 2, 0)
mid = (mid[0] * 255.0).byte().cpu().numpy().transpose(1, 2, 0) # type: ignore
write_buffer.put(np.concatenate((lastframe, mid[:h, :w]), 1))
else:
write_buffer.put(lastframe)
for mid in output:
mid = (mid[0] * 255.0).byte().cpu().numpy().transpose(1, 2, 0)
mid = (mid[0] * 255.0).byte().cpu().numpy().transpose(1, 2, 0) # type: ignore
write_buffer.put(mid[:h, :w])
pbar.update(1)
lastframe = frame
Expand Down
2 changes: 1 addition & 1 deletion imaginairy/img_processors/control_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_canny_edges(img: "Tensor") -> "Tensor":

img = torch.clamp((img + 1.0) / 2.0, min=0.0, max=1.0)
img = einops.rearrange(img[0], "c h w -> h w c")
img = (255.0 * img).cpu().numpy().astype(np.uint8).squeeze()
img = (255.0 * img).cpu().numpy().astype(np.uint8).squeeze() # type: ignore
blurred = cv2.GaussianBlur(img, (5, 5), 0).astype(np.uint8) # type: ignore

if len(blurred.shape) > 2:
Expand Down
2 changes: 1 addition & 1 deletion imaginairy/modules/diffusion/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def make_attn(in_channels, attn_type="vanilla", attn_kwargs=None):
if attn_type == "vanilla-xformers":
# print(f"building MemoryEfficientAttnBlock with {in_channels} in_channels...")
return MemoryEfficientAttnBlock(in_channels)
if type == "memory-efficient-cross-attn":
if attn_type == "memory-efficient-cross-attn":
attn_kwargs["query_dim"] = in_channels
return MemoryEfficientCrossAttentionWrapper(**attn_kwargs)
if attn_type == "none":
Expand Down
2 changes: 1 addition & 1 deletion imaginairy/modules/sgm/autoencoding/lpips/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, input_nc=3, ndf=64, n_layers=3, use_actnorm=False):
super().__init__()
norm_layer = nn.BatchNorm2d if not use_actnorm else ActNorm
if (
type(norm_layer) == functools.partial
type(norm_layer) == functools.partial # noqa
): # no need to use bias as BatchNorm2d has affine parameters
use_bias = norm_layer.func != nn.BatchNorm2d
else:
Expand Down
2 changes: 1 addition & 1 deletion imaginairy/modules/sgm/diffusionmodules/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def make_attn(in_channels, attn_type="vanilla", attn_kwargs=None):
# f"building MemoryEfficientAttnBlock with {in_channels} in_channels..."
# )
return MemoryEfficientAttnBlock(in_channels)
elif type == "memory-efficient-cross-attn":
elif attn_type == "memory-efficient-cross-attn":
attn_kwargs["query_dim"] = in_channels
return MemoryEfficientCrossAttentionWrapper(**attn_kwargs)
elif attn_type == "none":
Expand Down
2 changes: 1 addition & 1 deletion imaginairy/utils/animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def make_bounce_animation(
def _ensure_pillow_images(
imgs: "List[Image.Image | LazyLoadingImage | torch.Tensor]",
) -> "List[Image.Image]":
converted_frames: "List[Image.Image]" = []
converted_frames: List[Image.Image] = []
for frame in imgs:
if isinstance(frame, torch.Tensor):
converted_frames.append(model_latents_to_pillow_imgs(frame)[0])
Expand Down
2 changes: 1 addition & 1 deletion imaginairy/weight_management/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def could_convert(self, source_weights):
return source_keys.issubset(self.all_valid_prefixes)

def cast_weights(self, source_weights) -> dict[str, "Tensor"]:
converted_state_dict: dict[str, "Tensor"] = {}
converted_state_dict: dict[str, Tensor] = {}
for source_key in source_weights:
try:
source_prefix, suffix = source_key.rsplit(sep=".", maxsplit=1)
Expand Down
Loading

0 comments on commit 43ea730

Please sign in to comment.