chore(*): small code improvment
Changes: - just improve code style - decrease position round to 0.001
This commit is contained in:
+20
-5
@@ -1,3 +1,6 @@
|
||||
from numpy import ndarray
|
||||
from typing import Union
|
||||
|
||||
from .util import get_sizes
|
||||
|
||||
|
||||
@@ -17,7 +20,7 @@ class OFOImageFit:
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01,
|
||||
"round": 0.01,
|
||||
"round": 0.001,
|
||||
"display": "number",
|
||||
"lazy": True,
|
||||
},
|
||||
@@ -29,7 +32,7 @@ class OFOImageFit:
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01,
|
||||
"round": 0.01,
|
||||
"round": 0.001,
|
||||
"display": "number",
|
||||
"lazy": True,
|
||||
},
|
||||
@@ -57,13 +60,25 @@ class OFOImageFit:
|
||||
"INT",
|
||||
"INT",
|
||||
)
|
||||
RETURN_NAMES = ("IMAGE_WIDTH", "IMAGE_HEIGHT", "PAD_TOP", "PAD_RIGHT", "PAD_BOTTOM", "PAD_LEFT")
|
||||
RETURN_NAMES = (
|
||||
"IMAGE_WIDTH",
|
||||
"IMAGE_HEIGHT",
|
||||
"PAD_TOP",
|
||||
"PAD_RIGHT",
|
||||
"PAD_BOTTOM",
|
||||
"PAD_LEFT",
|
||||
)
|
||||
|
||||
FUNCTION = "calculate"
|
||||
CATEGORY = "OneForOne"
|
||||
|
||||
def calculate(
|
||||
self, latent, image, width_position=0.5, height_position=0.5, scale=1.0
|
||||
self,
|
||||
latent: Union[dict, ndarray],
|
||||
image: ndarray,
|
||||
width_position: float = 0.5,
|
||||
height_position: float = 0.5,
|
||||
scale: float = 1.0,
|
||||
):
|
||||
"""
|
||||
Calculate new dimensions and paddings for image, based on latent and given parameters.
|
||||
@@ -77,7 +92,7 @@ class OFOImageFit:
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing six integers representing the new width, height, top, right, bottom, and left padding values.
|
||||
"""
|
||||
"""
|
||||
# get sizes
|
||||
latent_height, latent_width = get_sizes(latent)
|
||||
image_height, image_width = get_sizes(image)
|
||||
|
||||
+5
-9
@@ -1,18 +1,14 @@
|
||||
from numpy import ndarray
|
||||
from typing import Union, Tuple
|
||||
|
||||
scale = 8
|
||||
# latent to pixel scale factor
|
||||
SCALE = 8
|
||||
|
||||
|
||||
def get_sizes(target: Union[dict, ndarray]) -> Tuple[int, int]:
|
||||
if isinstance(target, dict) and "samples" in target:
|
||||
# Latent height, width
|
||||
return (
|
||||
target["samples"].shape[2] * scale,
|
||||
target["samples"].shape[3] * scale
|
||||
)
|
||||
return (target["samples"].shape[2] * SCALE, target["samples"].shape[3] * SCALE)
|
||||
else:
|
||||
# Image height, width
|
||||
return (
|
||||
target.shape[1],
|
||||
target.shape[2]
|
||||
)
|
||||
return (target.shape[1], target.shape[2])
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-oneforone"
|
||||
description = "Node:Image Fit Calculator"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = ["numpy"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user