+ upscale_in_type

This commit is contained in:
Lex Darlog (DRL)
2025-07-17 12:35:37 +05:00
parent 4ee98d062c
commit 2e1f7d5f1f
3 changed files with 23 additions and 13 deletions
+9 -6
View File
@@ -20,7 +20,10 @@ from ._funcs import (
simple_result_from_approx_wh as _simple_result_from_approx_wh
)
from . import _meta
from .slot_types import *
from .slot_types import (
type_dict_res as _type_dict_res,
type_dict_step_init as _type_dict_step_init
)
# ----------------------------------------------------------
@@ -32,9 +35,9 @@ _return_names_simple = ('width', 'height')
# A tiny optimization by reusing the same immutable dict:
_input_types_simple = _deepfreeze({
'required': {
'width': (_IO.INT, dict(type_dict_res, **{'tooltip': "Approximate width"})),
'height': (_IO.INT, dict(type_dict_res, **{'tooltip': "Approximate height"})),
'step': (_IO.INT, dict(type_dict_step_init, **{'tooltip': (
'width': (_IO.INT, dict(_type_dict_res, **{'tooltip': "Approximate width"})),
'height': (_IO.INT, dict(_type_dict_res, **{'tooltip': "Approximate height"})),
'step': (_IO.INT, dict(_type_dict_step_init, **{'tooltip': (
"Both width and height will be divisible by this value - by rounding them "
"to the closest appropriate resolution.\n\n"
"The default 48 is (8 * 3 * 2), so it's a safe choice because:\n"
@@ -98,7 +101,7 @@ _tooltip_aspect = (
_input_types_orient = _deepfreeze({
'required': {
'size': (_IO.INT, dict(type_dict_res, **{'tooltip': (
'size': (_IO.INT, dict(_type_dict_res, **{'tooltip': (
"Approximate size of one of the image sides.\nWhich one - see the 'size_is_big' and 'landscape' toggles."
)})),
'step': _input_types_simple['required']['step'],
@@ -178,7 +181,7 @@ class BestResolutionFromAspectRatio:
_input_types_area = _deepfreeze({
'required': {
'square_size': (_IO.INT, dict(type_dict_res, **{'tooltip': (
'square_size': (_IO.INT, dict(_type_dict_res, **{'tooltip': (
"The total resolution of the image would be the same as of a square with this side.\n"
"The width and height would be such to respect aspect ratio, but also be as close as possible to the "
"total number of pixels as in this square image.\n\n"
+6 -6
View File
@@ -20,9 +20,12 @@ from ._funcs import (
)
from . import _meta
from .enums import *
from .slot_types import *
from .nodes_simple import _input_types_area
from .nodes_prims import _res_priority_in_type, _res_priority_verify
from .slot_types import (
type_dict_step_upscale1 as _type_dict_step_upscale1,
upscale_in_type as _upscale_in_type
)
# ----------------------------------------------------------
@@ -47,11 +50,8 @@ _return_ttips_upscale = _frozendict({
__extra_inputs_for_upscale_only = {
'priority': _res_priority_in_type,
'upscale': (_IO.FLOAT, {
'default': 1.5, 'min': 1.0, 'max': _sys.float_info.max, 'step': 0.25, 'round': 0.001,
# 'tooltip': "", # TODO
}),
'up_step': (_IO.INT, dict(type_dict_step_upscale1, **{
'upscale': _upscale_in_type,
'up_step': (_IO.INT, dict(_type_dict_step_upscale1, **{
'tooltip': "Same as the main `step`, but for the upscaled resolution.",
})),
}
+8 -1
View File
@@ -7,6 +7,8 @@ import typing as _t
import sys as _sys
from comfy.comfy_types.node_typing import IO as _IO
def number_type_dict(default: int = 512, min: int = 1, max: int = _sys.maxsize, step: int = 1) -> _t.Dict[str, int]:
"""Prepare type-dict for an input int/float parameter."""
@@ -20,6 +22,11 @@ def number_type_dict(default: int = 512, min: int = 1, max: int = _sys.maxsize,
}
type_dict_res = number_type_dict(1024)
type_dict_step_init = number_type_dict(48)
type_dict_step_upscale1 = number_type_dict(128)
type_dict_res = number_type_dict(1024)
upscale_in_type = (_IO.FLOAT, {
'default': 1.5, 'min': 1.0, 'max': _sys.float_info.max, 'step': 0.25, 'round': 0.001,
# 'tooltip': "", # TODO
})