2 Commits
Author SHA1 Message Date
Tropfchen b08c2b609a add fractional node 2024-11-03 22:31:23 +01:00
Tropfchen a897eacbe8 correct id 2024-05-24 21:59:35 +02:00
5 changed files with 90 additions and 6 deletions
+3 -2
View File
@@ -1,10 +1,11 @@
from .nodes import YARS, YARSAdv
from .nodes import YARS, YARSAdv, YARSAdvFrack
NODE_CLASS_MAPPINGS = {"YARS": YARS, "YARSAdv": YARSAdv}
NODE_CLASS_MAPPINGS = {"YARS": YARS, "YARSAdv": YARSAdv, "YARSAdvFrack": YARSAdvFrack}
NODE_DISPLAY_NAME_MAPPINGS = {
"YARS": "yaResolution Selector",
"YARSAdv": "yaResolution Selector (Advanced)",
"YARSAdvFrack": "yaResolution Selector (Fractional)",
}
+6 -1
View File
@@ -141,7 +141,11 @@ app.registerExtension({
name: "trop.YARS",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
// add resolution printout
if (nodeData.name === "YARSAdv" || nodeData.name === "YARS") {
if (
nodeData.name === "YARSAdvFrack" ||
nodeData.name === "YARSAdv" ||
nodeData.name === "YARS"
) {
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
const r = onExecuted?.apply?.(this, arguments);
@@ -181,6 +185,7 @@ app.registerExtension({
const entries = [
{ name: "yaResolution Selector", value: "YARS" },
{ name: "Advanced yaResolution Selector", value: "YARSAdv" },
{ name: "Fractional yaResolution Selector", value: "YARSAdvFrack" },
];
for (const entry of entries) {
options.unshift({
BIN
View File
Binary file not shown.
+78
View File
@@ -212,6 +212,84 @@ class YARSAdv:
}
class YARSAdvFrack:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(self):
return {
"required": {
"base_resolution": (
"INT",
{
"default": 512,
"min": 512,
"max": 8192,
"step": 128,
},
),
"width_ratio": (
"FLOAT",
{
"default": 1,
"min": 0.1,
"max": 24,
"step": 0.01,
},
),
"height_ratio": (
"FLOAT",
{
"default": 1,
"min": 0.1,
"max": 24,
"step": 0.01,
},
),
"overextend": (
"BOOLEAN",
{"default": False, "label_on": "yes ", "label_off": "no "},
),
"constant_resolution": (
"BOOLEAN",
{"default": False, "label_on": "yes ", "label_off": "no "},
),
},
}
RETURN_TYPES = ("INT", "INT")
RETURN_NAMES = ("width", "height")
FUNCTION = "calculate"
OUTPUT_NODE = False
CATEGORY = "utils"
def calculate(
self,
base_resolution: int,
width_ratio: float,
height_ratio: float,
overextend: bool,
constant_resolution: bool,
):
ratio: float = height_ratio / width_ratio
if constant_resolution:
d = calculate_constant_constant_resolution(base_resolution, ratio)
else:
d = calculate_aspect_ratio(base_resolution, ratio, overextend)
# return as dict with `ui` key to trigger onExecuted
return {
"ui": {
"width": [d.width],
"height": [d.height],
"ratio": [width_ratio / height_ratio],
},
"result": (d.width, d.height),
}
if __name__ == "__main__":
import unittest
+3 -3
View File
@@ -1,8 +1,8 @@
[project]
name = "ComfyUI-yaResolutionSelector"
name = "comfyui-yaresolutionselector"
description = "Freely adjust resolution and aspect ratio, maintain pixel count of StableDiffusion model, or hook it up to upscaling nodes to get that 5k 16:10 wallpaper in just few clicks."
version = "1.2.0"
license = "LICENSE"
version = "1.3.0"
license = {text = "GPL License"}
[project.urls]
Repository = "https://github.com/Tropfchen/ComfyUI-yaResolutionSelector"