Minor updates
This commit is contained in:
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"[python]": {
|
||||||
|
"editor.defaultFormatter": "ms-python.autopep8"
|
||||||
|
},
|
||||||
|
"python.formatting.provider": "none"
|
||||||
|
}
|
||||||
@@ -32,9 +32,9 @@ git clone https://github.com/bradsec/ComfyUI_ResolutionSelector.git
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Usage after install
|
### Usage after install
|
||||||
`Add Node > utils > Resolution Selector (w x h)`
|
`Add Node > utils > Resolution Selector`
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### SDXL hookup example
|
#### SDXL hookup example
|
||||||

|

|
||||||
|
|||||||
Regular → Executable
+18
-16
@@ -1,6 +1,4 @@
|
|||||||
|
# Resolution presets
|
||||||
# Define resolution presets
|
|
||||||
# Resolution list based off what is currently being used in the Fooocus SDXL Web UI (https://github.com/lllyasviel/Fooocus)
|
|
||||||
BASE_RESOLUTIONS = [
|
BASE_RESOLUTIONS = [
|
||||||
(1024, 1024),
|
(1024, 1024),
|
||||||
(704, 1408),
|
(704, 1408),
|
||||||
@@ -30,26 +28,29 @@ BASE_RESOLUTIONS = [
|
|||||||
(1728, 576)
|
(1728, 576)
|
||||||
]
|
]
|
||||||
|
|
||||||
# Create a list of resolution strings for the drop-down menu
|
|
||||||
resolution_strings = [f"{width}x{height}" for width, height in BASE_RESOLUTIONS]
|
|
||||||
|
|
||||||
# Create the custom node class
|
|
||||||
class ResolutionSelector:
|
class ResolutionSelector:
|
||||||
"""
|
"""
|
||||||
A node to provide a drop-down list of resolutions and returns two int values (width and height).
|
A node to provide a drop-down list of resolutions and returns two int values (width and height).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(cls):
|
||||||
"""
|
"""
|
||||||
Return a dictionary which contains config for all input fields.
|
Return a dictionary which contains config for all input fields.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Create a list of resolution strings for the drop-down menu
|
||||||
|
resolution_strings = [
|
||||||
|
f"{width} x {height}" for width, height in BASE_RESOLUTIONS]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"base_resolution": (resolution_strings,),
|
"base_resolution": (resolution_strings,),
|
||||||
"base_adjustment": (["SDXL (None)", "SD21 (75%)", "SD15 (50%)"],)
|
"base_adjustment": (["SDXL (None)", "SD21 (75%)", "SD15 (50%)"],),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,24 +59,24 @@ class ResolutionSelector:
|
|||||||
FUNCTION = "select_resolution"
|
FUNCTION = "select_resolution"
|
||||||
CATEGORY = 'utils'
|
CATEGORY = 'utils'
|
||||||
|
|
||||||
@staticmethod
|
def select_resolution(self, base_resolution, base_adjustment):
|
||||||
def select_resolution(base_resolution, base_adjustment):
|
|
||||||
"""
|
"""
|
||||||
Returns the width and height based on the selected resolution and adjustment.
|
Returns the width and height based on the selected resolution and adjustment.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
base_resolution (str): Selected resolution in the format "widthxheight".
|
base_resolution (str): Selected resolution in the format "width x height".
|
||||||
base_adjustment (str): Selected adjustment (resolution values reduction) based on Stable Diffusion version.
|
base_adjustment (str): Selected adjustment (resolution value reduction) based on SD version.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Tuple[int, int]: Adjusted width and height.
|
Tuple[int, int]: Adjusted width and height.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
width, height = map(int, base_resolution.split('x'))
|
width, height = map(int, base_resolution.split(' x '))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValueError("Invalid base_resolution format.")
|
raise ValueError("Invalid base_resolution format.")
|
||||||
|
|
||||||
adjustment_factors = {"SDXL (None)": 1, "SD21 (75%)": 0.75, "SD15 (50%)": 0.5}
|
adjustment_factors = {
|
||||||
|
"SDXL (None)": 1, "SD21 (75%)": 0.75, "SD15 (50%)": 0.5}
|
||||||
factor = adjustment_factors.get(base_adjustment)
|
factor = adjustment_factors.get(base_adjustment)
|
||||||
|
|
||||||
if factor is None:
|
if factor is None:
|
||||||
@@ -86,10 +87,11 @@ class ResolutionSelector:
|
|||||||
|
|
||||||
return width, height
|
return width, height
|
||||||
|
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"ResolutionSelector": ResolutionSelector,
|
"ResolutionSelector": ResolutionSelector,
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"ResolutionSelector": "Resolution Selector (w x h)",
|
"ResolutionSelector": "Resolution Selector",
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 77 KiB |
Executable → Regular
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 152 KiB |
Executable → Regular
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 383 KiB After Width: | Height: | Size: 257 KiB |
Reference in New Issue
Block a user