Skip to content

Commit

Permalink
fix: 🚀 pending fixes
Browse files Browse the repository at this point in the history
should be ready to go
  • Loading branch information
melMass committed Aug 12, 2023
1 parent 30d6cfe commit ea5d73d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion nodes/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def INPUT_TYPES(cls):
),
"bgcolor": (
"COLOR",
{"default": "black"},
{"default": "#000000"},
),
},
}
Expand Down
12 changes: 6 additions & 6 deletions nodes/transform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import torch
import torchvision.transforms.functional as F
import torchvision.transforms.functional as TF
from ..utils import log, hex_to_rgb, tensor2pil, pil2tensor
from math import sqrt, ceil
from typing import cast
Expand Down Expand Up @@ -30,7 +30,7 @@ def INPUT_TYPES(cls):
["edge", "constant", "reflect", "symmetric"],
{"default": "edge"},
),
"constant_color": ("COLOR", {"default": "black"}),
"constant_color": ("COLOR", {"default": "#000000"}),
},
}

Expand Down Expand Up @@ -71,16 +71,16 @@ def transform(
pw = int(frame_width - new_width)
ph = int(frame_height - new_height)

pw += max_padding
ph += max_padding
pw += abs(max_padding)
ph += abs(max_padding)

padding = [max(0, pw + x), max(0, ph + y), max(0, pw - x), max(0, ph - y)]

constant_color = hex_to_rgb(constant_color)
log.debug(f"Fill Tuple: {constant_color}")

for img in tensor2pil(image):
img = F.pad(
img = TF.pad(
img, # transformed_frame,
padding=padding,
padding_mode=border_handling,
Expand All @@ -89,7 +89,7 @@ def transform(

img = cast(
Image.Image,
F.affine(img, angle=angle, scale=zoom, translate=[x, y], shear=shear),
TF.affine(img, angle=angle, scale=zoom, translate=[x, y], shear=shear),
)

left = abs(padding[0])
Expand Down
8 changes: 6 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@

# region MISC Utilities
def hex_to_rgb(hex_color):
hex_color = hex_color.lstrip("#")
return tuple(int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
try:
hex_color = hex_color.lstrip("#")
return tuple(int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
except ValueError:
log.error(f"Invalid hex color: {hex_color}")
return (0, 0, 0)


def add_path(path, prepend=False):
Expand Down

0 comments on commit ea5d73d

Please sign in to comment.