fix: 🚀 pending fixes

should be ready to go
This commit is contained in:
melMass
2023-08-12 23:53:53 +02:00
parent 30d6cfe812
commit ea5d73d48c
3 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ class ImageRemoveBackgroundRembg:
),
"bgcolor": (
"COLOR",
{"default": "black"},
{"default": "#000000"},
),
},
}
+6 -6
View File
@@ -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
@@ -30,7 +30,7 @@ class TransformImage:
["edge", "constant", "reflect", "symmetric"],
{"default": "edge"},
),
"constant_color": ("COLOR", {"default": "black"}),
"constant_color": ("COLOR", {"default": "#000000"}),
},
}
@@ -71,8 +71,8 @@ class TransformImage:
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)]
@@ -80,7 +80,7 @@ class TransformImage:
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,
@@ -89,7 +89,7 @@ class TransformImage:
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])
+6 -2
View File
@@ -28,8 +28,12 @@ except ImportError:
# 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):