add Smart Profile Switch, fix folder picker, README overhaul, v1.0.2
- rename Smart Category Config → Smart Profile Switch 🧩 (code, JS, locales, demo workflow)
- add banner.svg and embed it at the top of README
- replace fragile OpenFileDialog folder-browse hack with native IFileDialog/FOS_PICKFOLDERS picker — fixes wrong-folder bug on single-click select
- flip Smart Resize's upscale_if_smaller default to true — node now resizes to target by default, as the name implies
- add width/height source tooltip to Smart Resolution Multiplier's image input
- fix stale widgets_values in smart_batch_resize_demo.json (10 fields → 13 after prefix/counter fields were added)
- full README rewrite: correct inputs/defaults/outputs for all 5 nodes, new Smart Profile Switch section, Example workflows section, expanded "Why these nodes?"
- add new example workflow (seedvr2_smartresize_demo.json), updated screenshots
- add assets/*.ai to .gitignore
- bump version to 1.0.2
@@ -2,6 +2,9 @@
|
||||
project-craftkit.md
|
||||
how-to-publish-comfyui-node.md
|
||||
|
||||
# Local design source files
|
||||
assets/*.ai
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[codz]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<img src="assets/banner.svg" width="100%" alt="ComfyUI-CraftKit">
|
||||
|
||||
# ComfyUI-CraftKit
|
||||
|
||||
Custom nodes for ComfyUI - image resizing, dataset prep & prompt automation for LoRA training workflows.
|
||||
@@ -9,7 +11,7 @@ All nodes appear under the **CraftKit** category in the node menu.
|
||||
## Nodes
|
||||
|
||||
### 📋 Smart Prompt Controller
|
||||
Cycle through up to 4 prompt lists using a single incrementing counter. Counts lines automatically, selects the right prompt, and outputs which list is active - ideal for driving Switch nodes that control aspect ratio, latent size, or other per-category settings.
|
||||
Cycle through up to 4 prompt lists using a single incrementing index. Counts lines automatically, selects the right prompt, and outputs which list is active - ideal for driving Switch nodes that control aspect ratio, latent size, or other per-category settings.
|
||||
|
||||
**Typical usecases:**
|
||||
- LoRA dataset generation with multiple pose categories (headshots, halfbody, fullbody, tall portrait), each with their own prompt list and aspect ratio
|
||||
@@ -17,13 +19,13 @@ Cycle through up to 4 prompt lists using a single incrementing counter. Counts l
|
||||
|
||||
| Input | Type | Description |
|
||||
|---|---|---|
|
||||
| counter | INT | Auto-incrementing counter (1-indexed) |
|
||||
| prompt_list_1 | STRING | First prompt list - one prompt per line (forceInput) |
|
||||
| prompt_list_2 | STRING | Second prompt list (optional, forceInput) |
|
||||
| prompt_list_3 | STRING | Third prompt list (optional, forceInput) |
|
||||
| prompt_list_4 | STRING | Fourth prompt list (optional, forceInput) |
|
||||
| Index | INT | Current position across all lists (1-indexed). Set "control after generate" to `increment` to auto-advance every run |
|
||||
| Prompt list 1 | STRING | First prompt list, one prompt per line |
|
||||
| Prompt list 2 | STRING | Second prompt list (optional) |
|
||||
| Prompt list 3 | STRING | Third prompt list (optional) |
|
||||
| Prompt list 4 | STRING | Fourth prompt list (optional) |
|
||||
|
||||
**Outputs:** `prompt` (selected line as STRING), `list_index` (active list number as INT → feed to Switch nodes)
|
||||
**Outputs:** Prompt (selected line as STRING), Active list (active list number as INT → feed to Smart Profile Switch or Switch nodes)
|
||||
|
||||
The node displays a status label showing the current position: `List 1 — 4/5 | total: 8`
|
||||
|
||||
@@ -31,51 +33,77 @@ The node displays a status label showing the current position: `List 1 — 4/5 |
|
||||
|
||||
---
|
||||
|
||||
### 🧩 Smart Profile Switch
|
||||
Maps an active index (1–4) to a label, width, and height. Pairs directly with Smart Prompt Controller's `active_list` output to switch resolution and filename label per category in one node — no separate Aspect Ratio + Primitive + Switch combo needed.
|
||||
|
||||
**Typical usecases:**
|
||||
- Driving `EmptyLatentImage` / `EmptySD3LatentImage` width/height per prompt category
|
||||
- Feeding a filename suffix into `SaveImageExtended` or similar so each category's output is labeled automatically
|
||||
- Replacing a CR Aspect Ratio + 4× Primitive + LatentSwitch chain with a single node
|
||||
|
||||
| Input | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| Index | INT | 1 | Active profile (1–4). Connect to Active list from Smart Prompt Controller |
|
||||
| Label 1 … Label 4 | STRING | Headshots / Halfbody / Fullbody / Tall | Label for each profile, used as filename suffix |
|
||||
| Width 1 … Width 4 | INT | 1024 / 832 / 768 / 640 | Width for each profile |
|
||||
| Height 1 … Height 4 | INT | 1024 / 1216 / 1344 / 1536 | Height for each profile |
|
||||
|
||||
**Outputs:** Label (STRING), Width (INT), Height (INT)
|
||||
|
||||
The node displays a status label showing the active slot: `Slot 2: Halfbody | 832 × 1216`
|
||||
|
||||
<img src="assets/screenshot-smart-profile-switch.png" width="700">
|
||||
|
||||
---
|
||||
|
||||
### 📐 Smart Resize
|
||||
Resize any image (or batch) so the **longest side** equals `longest_side`, with aspect ratio preserved.
|
||||
|
||||
Use this as a **pipeline node** — IMAGE in, IMAGE out. No files are saved to disk.
|
||||
|
||||
**Typical usecases:**
|
||||
- Downscale a SeedVR (or other upscaler) result back to your target training size — the upscaler adds fine detail, Smart Resize brings it to the right dimensions for LoRA training
|
||||
- Downscale a SeedVR2 (or other upscaler) result back to your target training size — the upscaler adds fine detail, Smart Resize brings it to the right dimensions for LoRA training
|
||||
- Any workflow step that needs a clean resize before the next node
|
||||
- Normalize mixed-resolution batches to a consistent size
|
||||
|
||||
| Input | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| image | IMAGE | — | Single image or batch |
|
||||
| longest_side | INT | 1536 | Target size for longest side (quick presets: 512 / 768 / 1024 / 1536) |
|
||||
| multiple_of | INT | 8 | Snap dimensions to this multiple (8 = SD/Flux compatible) |
|
||||
| interpolation | ENUM | lanczos | lanczos / bicubic / bilinear / nearest |
|
||||
| upscale_if_smaller | BOOLEAN | false | Also upscale images already smaller than longest_side |
|
||||
| Image | IMAGE | — | Single image or batch |
|
||||
| Longest side (px) | INT | 1536 | Target size for longest side (quick presets: 512 / 768 / 1024 / 1536) |
|
||||
| Round to multiple of | INT | 8 | Snap dimensions to this multiple (8 = SD/Flux compatible) |
|
||||
| Interpolation method | ENUM | lanczos | lanczos / bicubic / bilinear / nearest |
|
||||
| Upscale if smaller | BOOLEAN | true | Upscale images smaller than longest_side. Turn off to only ever downscale, never upscale |
|
||||
|
||||
**Outputs:** `image`, `width`, `height`
|
||||
**Outputs:** Image, Width, Height
|
||||
|
||||
<img src="assets/screenshot-smart-resize.png" width="700">
|
||||
|
||||
---
|
||||
|
||||
### 📁 Smart Batch Resize
|
||||
Load **all images from a folder**, resize each one by longest side, and save into a subfolder. Original filenames are always preserved — the node adds an optional suffix and/or resolution to the filename.
|
||||
Load **all images from a folder**, resize each one by longest side, and save into a subfolder. Build clean dataset filenames from a prefix, the original name, and/or a sequential counter — combined with an optional resolution suffix.
|
||||
|
||||
Use this for **bulk preprocessing** — e.g. preparing a LoRA dataset from a folder of high-res images.
|
||||
Use this for **bulk preprocessing** — e.g. preparing a LoRA dataset from a folder of high-res images. The node always writes resized images to disk inside the input folder; connecting the outputs is optional.
|
||||
|
||||
Includes a **Browse folder** button to pick the input folder directly from the node, and quick presets (512 / 768 / 1024 / 1536) for the longest side.
|
||||
|
||||
| Input | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| input_folder | STRING | — | Source folder path (use Browse button or paste manually) |
|
||||
| longest_side | INT | 1024 | Target size for longest side |
|
||||
| multiple_of | INT | 8 | Snap dimensions to this multiple |
|
||||
| interpolation | ENUM | lanczos | lanczos / bicubic / bilinear / nearest |
|
||||
| suffix_resolution | BOOLEAN | true | Append resolution to filename — e.g. `photo_1024.png` |
|
||||
| suffix_custom | STRING | — | Custom text added after filename — e.g. `photo_headshot.png` |
|
||||
| folder_resolution | BOOLEAN | false | Append resolution to subfolder name — e.g. `resized_1024` |
|
||||
| folder_custom | STRING | resized | Subfolder name inside the input folder |
|
||||
| skip_if_exists | BOOLEAN | true | Skip files that already exist in the output folder |
|
||||
| delimiter | STRING | _ | Separator between filename parts |
|
||||
| Input folder | STRING | — | Source folder path (use Browse button or paste manually) |
|
||||
| Longest side (px) | INT | 1024 | Target size for longest side |
|
||||
| Round to multiple of | INT | 8 | Snap dimensions to this multiple |
|
||||
| Interpolation method | ENUM | lanczos | lanczos / bicubic / bilinear / nearest |
|
||||
| Filename prefix | STRING | — | Label prepended to filename — e.g. `headshot` → `headshot_photo_001_1024.jpg` |
|
||||
| Keep original filename | BOOLEAN | true | Include the original filename in the output name |
|
||||
| Add counter | BOOLEAN | false | Add a sequential 3-digit counter to each filename (001, 002, ...) |
|
||||
| Counter start | INT | 1 | Starting number for the counter |
|
||||
| Add resolution to filename | BOOLEAN | true | Append resolution to filename — e.g. `photo_1024.png` |
|
||||
| Create resolution subfolder | BOOLEAN | false | Append resolution to subfolder name — e.g. `resized_1024` |
|
||||
| Custom output subfolder | STRING | resized | Subfolder name inside the input folder |
|
||||
| Skip existing files | BOOLEAN | true | Skip files that already exist in the output folder |
|
||||
| Filename delimiter | STRING | _ | Separator between filename parts |
|
||||
|
||||
**Outputs:** `images` (list), `count`
|
||||
**Outputs:** Images (list), Count
|
||||
|
||||
<img src="assets/screenshot-smart-batch-resize.png" width="700">
|
||||
|
||||
@@ -84,29 +112,41 @@ Includes a **Browse folder** button to pick the input folder directly from the n
|
||||
### 📏 Smart Resolution Multiplier
|
||||
Multiply image dimensions by a factor and output the results as integers.
|
||||
|
||||
SeedVR takes a single `resolution` INT (the longest side) — not a width and height separately. Standard math nodes give you a FLOAT or require multiple steps to get there. This node does it cleanly in one step: give it your image and a multiplier, and it outputs `width`, `height`, and `resolution` (longest side) ready to connect directly to SeedVR's `max_resolution` input.
|
||||
SeedVR2 takes a single `resolution` INT (the longest side) — not a width and height separately. Standard math nodes give you a FLOAT or require multiple steps to get there. This node does it cleanly in one step: give it your image and a multiplier, and it outputs `width`, `height`, and `resolution` (longest side) ready to connect directly to SeedVR2's `resolution` input.
|
||||
|
||||
Also useful for LoRA dataset prep — using mixed resolutions in your training set generally produces better results than training on a single fixed size. Smart Resolution Multiplier makes it easy to dynamically calculate the right target size per image rather than hardcoding a value.
|
||||
|
||||
| Input | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| image | IMAGE | — | Source image |
|
||||
| multiplier | FLOAT | 2.0 | Multiply width and height by this factor |
|
||||
| multiple_of | INT | 8 | Snap dimensions to this multiple |
|
||||
| Image | IMAGE | — | Source image — its current width/height are read directly, no separate Get Image Size node needed |
|
||||
| Multiplier | FLOAT | 2.0 | Multiply width and height by this factor |
|
||||
| Round to multiple of | INT | 8 | Snap dimensions to this multiple |
|
||||
|
||||
**Outputs:** `width`, `height`, `resolution` (longest side as INT → directly into SeedVR)
|
||||
**Outputs:** Width, Height, Resolution (longest side as INT → directly into SeedVR2)
|
||||
|
||||
<img src="assets/screenshot-smart-resolution-multiplier.png" width="700">
|
||||
|
||||
---
|
||||
|
||||
## Example workflows
|
||||
|
||||
Ready-to-load workflows are included in [`example_workflows/`](example_workflows):
|
||||
|
||||
- **`smart_prompt_controller_demo.json`** — Smart Prompt Controller + Smart Profile Switch driving 4 prompt categories with auto-switching resolution and filename label
|
||||
- **`seedvr2_smartresize_demo.json`** — Smart Resolution Multiplier → SeedVR2 upscale → Smart Resize, a clean pattern for upscaling without hardcoding target resolution
|
||||
- **`smart_batch_resize_demo.json`** — minimal Smart Batch Resize setup with a Note explaining outputs and settings
|
||||
|
||||
---
|
||||
|
||||
## Why these nodes?
|
||||
|
||||
- ComfyUI's built-in `Resize Images by Longer Edge` [BETA] has no Lanczos and no `multiple_of` snapping
|
||||
- `JWImageResizeByLongerSide` (comfyui-various) has no Lanczos in the official release
|
||||
- No existing node combines batch folder loading + longest-side resize + original filename preservation
|
||||
- No existing node outputs a ready-to-use `resolution` INT for SeedVR
|
||||
- No existing node cycles through multiple prompt lists with automatic list switching and counter
|
||||
- No existing node outputs a ready-to-use `resolution` INT for SeedVR2
|
||||
- No existing node cycles through multiple prompt lists with automatic list switching and an index
|
||||
- No existing node switches label + width + height together per category in one place
|
||||
- Smart Prompt Controller + Smart Profile Switch handle **uneven category sizes automatically** — 5 headshot prompts and 10 fullbody prompts cycle correctly without padding lists to match or manually tracking where one category ends and the next begins
|
||||
|
||||
---
|
||||
|
||||
@@ -122,6 +162,7 @@ git clone https://github.com/CraftopiaStudio/ComfyUI-CraftKit
|
||||
Restart ComfyUI. All nodes appear under **CraftKit** in the node menu:
|
||||
|
||||
- `CraftKit` → **Smart Prompt Controller 📋**
|
||||
- `CraftKit` → **Smart Profile Switch 🧩**
|
||||
- `CraftKit` → **Smart Resize 📐**
|
||||
- `CraftKit` → **Smart Batch Resize 📁**
|
||||
- `CraftKit` → **Smart Resolution Multiplier 📏**
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
WEB_DIRECTORY = "./js"
|
||||
|
||||
from .smart_resize import NODE_CLASS_MAPPINGS as A, NODE_DISPLAY_NAME_MAPPINGS as A_NAMES
|
||||
from .smart_batch_resize import NODE_CLASS_MAPPINGS as B, NODE_DISPLAY_NAME_MAPPINGS as B_NAMES
|
||||
from .smart_resolution_multiplier import NODE_CLASS_MAPPINGS as C, NODE_DISPLAY_NAME_MAPPINGS as C_NAMES
|
||||
from .smart_prompt_controller import NODE_CLASS_MAPPINGS as D, NODE_DISPLAY_NAME_MAPPINGS as D_NAMES
|
||||
from .smart_prompt_controller import NODE_CLASS_MAPPINGS as A, NODE_DISPLAY_NAME_MAPPINGS as A_NAMES
|
||||
from .smart_profile_switch import NODE_CLASS_MAPPINGS as B, NODE_DISPLAY_NAME_MAPPINGS as B_NAMES
|
||||
from .smart_resize import NODE_CLASS_MAPPINGS as C, NODE_DISPLAY_NAME_MAPPINGS as C_NAMES
|
||||
from .smart_batch_resize import NODE_CLASS_MAPPINGS as D, NODE_DISPLAY_NAME_MAPPINGS as D_NAMES
|
||||
from .smart_resolution_multiplier import NODE_CLASS_MAPPINGS as E, NODE_DISPLAY_NAME_MAPPINGS as E_NAMES
|
||||
|
||||
NODE_CLASS_MAPPINGS = {**A, **B, **C, **D}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {**A_NAMES, **B_NAMES, **C_NAMES, **D_NAMES}
|
||||
NODE_CLASS_MAPPINGS = {**A, **B, **C, **D, **E}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {**A_NAMES, **B_NAMES, **C_NAMES, **D_NAMES, **E_NAMES}
|
||||
|
||||
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
|
||||
|
||||
@@ -22,24 +23,90 @@ async def browse_folder(request):
|
||||
def _open_dialog():
|
||||
if sys.platform != "win32":
|
||||
return ""
|
||||
ps = (
|
||||
"Add-Type -AssemblyName System.Windows.Forms;"
|
||||
"$r='';"
|
||||
"$o=New-Object System.Windows.Forms.Form;"
|
||||
"$o.TopMost=$true;$o.ShowInTaskbar=$false;$o.FormBorderStyle='None';"
|
||||
"$o.Width=1;$o.Height=1;$o.Opacity=0;$o.StartPosition='CenterScreen';"
|
||||
"$o.Add_Shown({"
|
||||
"$o.Activate();"
|
||||
"$d=New-Object System.Windows.Forms.OpenFileDialog;"
|
||||
"$d.Title='Select input folder';"
|
||||
"$d.ValidateNames=$false;$d.CheckFileExists=$false;$d.CheckPathExists=$true;"
|
||||
"$d.FileName='Folder Selection.';"
|
||||
"$d.Filter='Folders|*.none';"
|
||||
"if($d.ShowDialog($o) -eq 'OK'){$r=[System.IO.Path]::GetDirectoryName($d.FileName)};"
|
||||
"$o.Close()});"
|
||||
"$o.ShowDialog()|Out-Null;"
|
||||
"$r"
|
||||
)
|
||||
ps = r"""
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type @"
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public static class CraftKitFolderPicker
|
||||
{
|
||||
[ComImport, Guid("DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7")]
|
||||
private class FileOpenDialogRCW { }
|
||||
|
||||
[ComImport, Guid("42f85136-db7e-439c-85f1-e4075d135fc8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IFileDialog
|
||||
{
|
||||
[PreserveSig] int Show(IntPtr parent);
|
||||
void SetFileTypes(uint cFileTypes, IntPtr rgFilterSpec);
|
||||
void SetFileTypeIndex(uint iFileType);
|
||||
void GetFileTypeIndex(out uint piFileType);
|
||||
void Advise(IntPtr pfde, out uint pdwCookie);
|
||||
void Unadvise(uint dwCookie);
|
||||
void SetOptions(uint fos);
|
||||
void GetOptions(out uint fos);
|
||||
void SetDefaultFolder(IntPtr psi);
|
||||
void SetFolder(IntPtr psi);
|
||||
void GetFolder(out IntPtr ppsi);
|
||||
void GetCurrentSelection(out IntPtr ppsi);
|
||||
void SetFileName(string pszName);
|
||||
void GetFileName(out IntPtr pszName);
|
||||
void SetTitle(string pszTitle);
|
||||
void SetOkButtonLabel(string pszText);
|
||||
void SetFileNameLabel(string pszLabel);
|
||||
void GetResult(out IShellItemLocal ppsi);
|
||||
void AddPlace(IntPtr psi, uint fdap);
|
||||
void SetDefaultExtension(string pszDefaultExtension);
|
||||
void Close(int hr);
|
||||
void SetClientGuid(ref Guid guid);
|
||||
void ClearClientData();
|
||||
void SetFilter(IntPtr pFilter);
|
||||
}
|
||||
|
||||
[ComImport, Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IShellItemLocal
|
||||
{
|
||||
void BindToHandler(IntPtr pbc, ref Guid bhid, ref Guid riid, out IntPtr ppv);
|
||||
void GetParent(out IShellItemLocal ppsi);
|
||||
void GetDisplayName(uint sigdnName, out IntPtr ppszName);
|
||||
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
|
||||
void Compare(IShellItemLocal psi, uint hint, out int piOrder);
|
||||
}
|
||||
|
||||
public static string ShowDialog(IntPtr owner, string title)
|
||||
{
|
||||
var dialog = (IFileDialog)new FileOpenDialogRCW();
|
||||
dialog.SetOptions(0x20u | 0x40u); // FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM
|
||||
if (!string.IsNullOrEmpty(title)) dialog.SetTitle(title);
|
||||
int hr = dialog.Show(owner);
|
||||
if (hr != 0) return null;
|
||||
IShellItemLocal item;
|
||||
dialog.GetResult(out item);
|
||||
IntPtr pszPath;
|
||||
item.GetDisplayName(0x80058000u, out pszPath); // SIGDN_FILESYSPATH
|
||||
string path = Marshal.PtrToStringAuto(pszPath);
|
||||
Marshal.FreeCoTaskMem(pszPath);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
"@
|
||||
|
||||
$r = ''
|
||||
$o = New-Object System.Windows.Forms.Form
|
||||
$o.TopMost = $true
|
||||
$o.ShowInTaskbar = $false
|
||||
$o.FormBorderStyle = 'None'
|
||||
$o.Width = 1; $o.Height = 1; $o.Opacity = 0
|
||||
$o.StartPosition = 'CenterScreen'
|
||||
$o.Add_Shown({
|
||||
$o.Activate()
|
||||
$path = [CraftKitFolderPicker]::ShowDialog($o.Handle, 'Select input folder')
|
||||
if ($path) { $script:r = $path }
|
||||
$o.Close()
|
||||
})
|
||||
$o.ShowDialog() | Out-Null
|
||||
$r
|
||||
"""
|
||||
result = subprocess.run(
|
||||
["powershell", "-NoProfile", "-Command", ps],
|
||||
capture_output=True, text=True
|
||||
|
||||
|
After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 218 KiB |
|
After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 206 KiB |
|
Before Width: | Height: | Size: 751 KiB After Width: | Height: | Size: 231 KiB |
|
Before Width: | Height: | Size: 665 KiB After Width: | Height: | Size: 134 KiB |
@@ -0,0 +1,228 @@
|
||||
{
|
||||
"last_node_id": 9,
|
||||
"last_link_id": 7,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "Note",
|
||||
"pos": [0, -240],
|
||||
"size": {"0": 1840, "1": 190},
|
||||
"flags": {},
|
||||
"order": 7,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"properties": {},
|
||||
"widgets_values": ["CraftKit × SeedVR2 — Smart Upscale\n\nPattern:\n1. SmartResolutionMultiplier calculates the 2× target resolution from the input image automatically\n2. ImageScaleBy pre-downscales the input (0.75×) so SeedVR2 has room to work\n3. SeedVR2 upscales to the computed target resolution (connected from SmartResolutionMultiplier → resolution)\n4. SmartResize normalizes the output to a consistent longest side\n\nChange multiplier on SmartResolutionMultiplier to control the upscale factor. Change longest_side on SmartResize to control output size."],
|
||||
"color": "#2a3a2a",
|
||||
"bgcolor": "#1a2a1a"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "LoadImage",
|
||||
"pos": [0, -10],
|
||||
"size": {"0": 280, "1": 320},
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "image", "type": "COMBO", "widget": {"name": "image"}, "link": null},
|
||||
{"name": "upload", "type": "IMAGEUPLOAD", "widget": {"name": "upload"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "IMAGE", "type": "IMAGE", "links": [1, 2], "slot_index": 0},
|
||||
{"name": "MASK", "type": "MASK", "links": null, "slot_index": 1}
|
||||
],
|
||||
"properties": {"cnr_id": "comfy-core", "Node name for S&R": "LoadImage"},
|
||||
"widgets_values": ["example.png", "image"]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "SmartResolutionMultiplier",
|
||||
"pos": [320, -10],
|
||||
"size": {"0": 320, "1": 150},
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "image", "type": "IMAGE", "link": 1}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "width", "type": "INT", "links": null, "slot_index": 0},
|
||||
{"name": "height", "type": "INT", "links": null, "slot_index": 1},
|
||||
{"name": "resolution", "type": "INT", "links": [3], "slot_index": 2}
|
||||
],
|
||||
"properties": {"cnr_id": "comfyui-craftkit", "Node name for S&R": "SmartResolutionMultiplier"},
|
||||
"widgets_values": [2.0, 8]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "ImageScaleBy",
|
||||
"pos": [320, 180],
|
||||
"size": {"0": 270, "1": 130},
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "image", "type": "IMAGE", "link": 2}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "IMAGE", "type": "IMAGE", "links": [4], "slot_index": 0}
|
||||
],
|
||||
"title": "Pre-downscale (0.75×)",
|
||||
"properties": {"cnr_id": "comfy-core", "Node name for S&R": "ImageScaleBy"},
|
||||
"widgets_values": ["lanczos", 0.75]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "SeedVR2LoadDiTModel",
|
||||
"pos": [680, -10],
|
||||
"size": {"0": 380, "1": 260},
|
||||
"flags": {},
|
||||
"order": 3,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "torch_compile_args", "shape": 7, "type": "TORCH_COMPILE_ARGS", "link": null},
|
||||
{"name": "model", "type": "COMBO", "widget": {"name": "model"}, "link": null},
|
||||
{"name": "device", "type": "COMBO", "widget": {"name": "device"}, "link": null},
|
||||
{"name": "blocks_to_swap", "shape": 7, "type": "INT", "widget": {"name": "blocks_to_swap"}, "link": null},
|
||||
{"name": "swap_io_components", "shape": 7, "type": "BOOLEAN", "widget": {"name": "swap_io_components"}, "link": null},
|
||||
{"name": "offload_device", "shape": 7, "type": "COMBO", "widget": {"name": "offload_device"}, "link": null},
|
||||
{"name": "cache_model", "shape": 7, "type": "BOOLEAN", "widget": {"name": "cache_model"}, "link": null},
|
||||
{"name": "attention_mode", "shape": 7, "type": "COMBO", "widget": {"name": "attention_mode"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "SEEDVR2_DIT", "type": "SEEDVR2_DIT", "links": [5], "slot_index": 0}
|
||||
],
|
||||
"properties": {"cnr_id": "seedvr2_videoupscaler", "Node name for S&R": "SeedVR2LoadDiTModel"},
|
||||
"widgets_values": ["seedvr2_ema_3b_fp8_e4m3fn.safetensors", "cuda:0", 0, false, "none", false, "sdpa"]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "SeedVR2LoadVAEModel",
|
||||
"pos": [680, 300],
|
||||
"size": {"0": 380, "1": 300},
|
||||
"flags": {},
|
||||
"order": 4,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "torch_compile_args", "shape": 7, "type": "TORCH_COMPILE_ARGS", "link": null},
|
||||
{"name": "model", "type": "COMBO", "widget": {"name": "model"}, "link": null},
|
||||
{"name": "device", "type": "COMBO", "widget": {"name": "device"}, "link": null},
|
||||
{"name": "encode_tiled", "shape": 7, "type": "BOOLEAN", "widget": {"name": "encode_tiled"}, "link": null},
|
||||
{"name": "encode_tile_size", "shape": 7, "type": "INT", "widget": {"name": "encode_tile_size"}, "link": null},
|
||||
{"name": "encode_tile_overlap", "shape": 7, "type": "INT", "widget": {"name": "encode_tile_overlap"}, "link": null},
|
||||
{"name": "decode_tiled", "shape": 7, "type": "BOOLEAN", "widget": {"name": "decode_tiled"}, "link": null},
|
||||
{"name": "decode_tile_size", "shape": 7, "type": "INT", "widget": {"name": "decode_tile_size"}, "link": null},
|
||||
{"name": "decode_tile_overlap", "shape": 7, "type": "INT", "widget": {"name": "decode_tile_overlap"}, "link": null},
|
||||
{"name": "tile_debug", "shape": 7, "type": "COMBO", "widget": {"name": "tile_debug"}, "link": null},
|
||||
{"name": "offload_device", "shape": 7, "type": "COMBO", "widget": {"name": "offload_device"}, "link": null},
|
||||
{"name": "cache_model", "shape": 7, "type": "BOOLEAN", "widget": {"name": "cache_model"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "SEEDVR2_VAE", "type": "SEEDVR2_VAE", "links": [6], "slot_index": 0}
|
||||
],
|
||||
"properties": {"cnr_id": "seedvr2_videoupscaler", "Node name for S&R": "SeedVR2LoadVAEModel"},
|
||||
"widgets_values": ["ema_vae_fp16.safetensors", "cuda:0", true, 1024, 128, true, 1024, 128, "false", "cpu", false]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"type": "SeedVR2VideoUpscaler",
|
||||
"pos": [1100, -10],
|
||||
"size": {"0": 380, "1": 560},
|
||||
"flags": {},
|
||||
"order": 5,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "image", "type": "IMAGE", "link": 4},
|
||||
{"name": "dit", "type": "SEEDVR2_DIT", "link": 5},
|
||||
{"name": "vae", "type": "SEEDVR2_VAE", "link": 6},
|
||||
{"name": "seed", "type": "INT", "widget": {"name": "seed"}, "link": null},
|
||||
{"name": "resolution", "type": "INT", "widget": {"name": "resolution"}, "link": 3},
|
||||
{"name": "max_resolution", "type": "INT", "widget": {"name": "max_resolution"}, "link": null},
|
||||
{"name": "batch_size", "type": "INT", "widget": {"name": "batch_size"}, "link": null},
|
||||
{"name": "uniform_batch_size", "type": "BOOLEAN", "widget": {"name": "uniform_batch_size"}, "link": null},
|
||||
{"name": "color_correction", "type": "COMBO", "widget": {"name": "color_correction"}, "link": null},
|
||||
{"name": "temporal_overlap", "shape": 7, "type": "INT", "widget": {"name": "temporal_overlap"}, "link": null},
|
||||
{"name": "prepend_frames", "shape": 7, "type": "INT", "widget": {"name": "prepend_frames"}, "link": null},
|
||||
{"name": "input_noise_scale", "shape": 7, "type": "FLOAT", "widget": {"name": "input_noise_scale"}, "link": null},
|
||||
{"name": "latent_noise_scale", "shape": 7, "type": "FLOAT", "widget": {"name": "latent_noise_scale"}, "link": null},
|
||||
{"name": "offload_device", "shape": 7, "type": "COMBO", "widget": {"name": "offload_device"}, "link": null},
|
||||
{"name": "enable_debug", "shape": 7, "type": "BOOLEAN", "widget": {"name": "enable_debug"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "IMAGE", "type": "IMAGE", "links": [7], "slot_index": 0}
|
||||
],
|
||||
"properties": {"cnr_id": "seedvr2_videoupscaler", "Node name for S&R": "SeedVR2VideoUpscaler"},
|
||||
"widgets_values": [42, "fixed", 0, 1, false, "lab", 0, 0, 0.0, 0.0, "cpu", false]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"type": "SmartResize",
|
||||
"pos": [1520, -10],
|
||||
"size": {"0": 320, "1": 240},
|
||||
"flags": {},
|
||||
"order": 6,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "image", "type": "IMAGE", "link": 7}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "image", "type": "IMAGE", "links": [], "slot_index": 0},
|
||||
{"name": "width", "type": "INT", "links": [], "slot_index": 1},
|
||||
{"name": "height", "type": "INT", "links": [], "slot_index": 2}
|
||||
],
|
||||
"properties": {"cnr_id": "comfyui-craftkit", "Node name for S&R": "SmartResize"},
|
||||
"widgets_values": [1024, 8, "lanczos", false]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"type": "Note",
|
||||
"pos": [1520, 260],
|
||||
"size": {"0": 320, "1": 310},
|
||||
"flags": {},
|
||||
"order": 8,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"properties": {},
|
||||
"widgets_values": ["Outputs:\n\n→ image (SmartResize)\n connect to PreviewImage or SaveImage\n\nTweak:\n• multiplier on SmartResolutionMultiplier\n 2.0 = double, 1.5 = 50% bigger\n• scale_by on Pre-downscale\n lower = more room for SeedVR2 to\n reconstruct detail\n• longest_side on SmartResize\n target output size after upscale\n\nModel options:\n• 3b fp8 — fast, less VRAM\n• 7b fp16 — best quality, high VRAM"],
|
||||
"color": "#2a3a2a",
|
||||
"bgcolor": "#1a2a1a"
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[1, 2, 0, 3, 0, "IMAGE"],
|
||||
[2, 2, 0, 4, 0, "IMAGE"],
|
||||
[3, 3, 2, 7, 4, "INT"],
|
||||
[4, 4, 0, 7, 0, "IMAGE"],
|
||||
[5, 5, 0, 7, 1, "SEEDVR2_DIT"],
|
||||
[6, 6, 0, 7, 2, "SEEDVR2_VAE"],
|
||||
[7, 7, 0, 8, 0, "IMAGE"]
|
||||
],
|
||||
"groups": [
|
||||
{
|
||||
"title": "Input",
|
||||
"bounding": [-20, -30, 640, 390],
|
||||
"color": "#4a2d5a",
|
||||
"font_size": 24
|
||||
},
|
||||
{
|
||||
"title": "SeedVR2 Models",
|
||||
"bounding": [660, -30, 420, 640],
|
||||
"color": "#1e3d5a",
|
||||
"font_size": 24
|
||||
},
|
||||
{
|
||||
"title": "Upscale + Output",
|
||||
"bounding": [1080, -30, 800, 630],
|
||||
"color": "#1e4a4a",
|
||||
"font_size": 24
|
||||
}
|
||||
],
|
||||
"config": {},
|
||||
"extra": {
|
||||
"ds": {"scale": 0.6, "offset": [-20, 230]}
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
@@ -33,8 +33,11 @@
|
||||
1024,
|
||||
8,
|
||||
"lanczos",
|
||||
true,
|
||||
"",
|
||||
true,
|
||||
false,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"resized",
|
||||
true,
|
||||
@@ -66,18 +69,20 @@
|
||||
"id": 3,
|
||||
"type": "Note",
|
||||
"pos": [460, 390],
|
||||
"size": [320, 220],
|
||||
"size": [340, 400],
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"properties": {
|
||||
"text": "Smart Batch Resize — outputs uitleg:\n\n📷 images → PreviewImage of verder bewerken\n📝 filenames → bestandsnamen (zonder pad)\n📁 output_paths → volledige paden op schijf\n🔢 count → aantal verwerkte afbeeldingen\n\nDe node schrijft sowieso naar schijf.\nDe outputs zijn optioneel aan te sluiten."
|
||||
"text": "Smart Batch Resize — how it works\n\nThe node ALWAYS writes resized images to disk — connecting the outputs is optional.\n\nOutputs:\n📷 images → batch tensor, feed into PreviewImage or any IMAGE input\n🔢 count → number of images actually processed\n\nKey settings:\n📁 Input folder — pick with Browse folder, or paste a path\n📐 Longest side — target size, aspect ratio is always preserved\n🔢 Round to multiple of — snap dimensions (use 8 for SD/Flux)\n🏷️ Filename prefix / Keep original filename / Add counter — build the output filename\n📂 Create resolution subfolder / Custom output subfolder — where resized files land (default: input_folder/resized/)\n⏭️ Skip existing files — don't reprocess files already in the output folder\n\n▶️ Run Batch = same as the regular Run button — it just runs this node. No separate output folder needed: results are saved inside the input folder itself (in the resized/ subfolder).\n\nTip: leave the prefix empty and 'Keep original filename' on to preserve names, or turn it off and use a prefix + counter for a clean renumbered batch."
|
||||
},
|
||||
"widgets_values": [
|
||||
"Smart Batch Resize — outputs uitleg:\n\n📷 images → PreviewImage of verder bewerken\n📝 filenames → bestandsnamen (zonder pad)\n📁 output_paths → volledige paden op schijf\n🔢 count → aantal verwerkte afbeeldingen\n\nDe node schrijft sowieso naar schijf.\nDe outputs zijn optioneel aan te sluiten."
|
||||
]
|
||||
"Smart Batch Resize — how it works\n\nThe node ALWAYS writes resized images to disk — connecting the outputs is optional.\n\nOutputs:\n📷 images → batch tensor, feed into PreviewImage or any IMAGE input\n🔢 count → number of images actually processed\n\nKey settings:\n📁 Input folder — pick with Browse folder, or paste a path\n📐 Longest side — target size, aspect ratio is always preserved\n🔢 Round to multiple of — snap dimensions (use 8 for SD/Flux)\n🏷️ Filename prefix / Keep original filename / Add counter — build the output filename\n📂 Create resolution subfolder / Custom output subfolder — where resized files land (default: input_folder/resized/)\n⏭️ Skip existing files — don't reprocess files already in the output folder\n\n▶️ Run Batch = same as the regular Run button — it just runs this node. No separate output folder needed: results are saved inside the input folder itself (in the resized/ subfolder).\n\nTip: leave the prefix empty and 'Keep original filename' on to preserve names, or turn it off and use a prefix + counter for a clean renumbered batch."
|
||||
],
|
||||
"color": "#2a3a2a",
|
||||
"bgcolor": "#1a2a1a"
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
{
|
||||
"last_node_id": 10,
|
||||
"last_link_id": 7,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "Note",
|
||||
"pos": [0, -240],
|
||||
"size": {"0": 1090, "1": 180},
|
||||
"flags": {},
|
||||
"order": 6,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"properties": {},
|
||||
"widgets_values": ["CraftKit — Smart Prompt Controller + Smart Profile Switch\n\nSet index to 1 and control_after_generate to 'increment' — cycles through all 16 prompts automatically, one per generation.\n\nSmartPromptController picks the right prompt line and tells SmartProfileSwitch which profile is active (1–4).\nSmartProfileSwitch switches the resolution and label to match. Connect the outputs on the right to your sampler pipeline."],
|
||||
"color": "#2a3a2a",
|
||||
"bgcolor": "#1a2a1a"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "PrimitiveStringMultiline",
|
||||
"pos": [0, -20],
|
||||
"size": {"0": 340, "1": 210},
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "value", "type": "STRING", "widget": {"name": "value"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "STRING", "type": "STRING", "links": [1], "slot_index": 0}
|
||||
],
|
||||
"title": "Headshot Prompts",
|
||||
"properties": {"cnr_id": "comfy-core", "ver": "0.17.0", "Node name for S&R": "PrimitiveStringMultiline"},
|
||||
"widgets_values": ["01 headshot portrait, face and neck only, neutral expression, soft studio lighting, clean background\n02 headshot portrait, slight smile, diffused window light, plain white background\n03 headshot portrait, professional look, direct gaze, high-key studio lighting\n04 headshot portrait, relaxed expression, warm natural daylight, simple neutral background"],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "PrimitiveStringMultiline",
|
||||
"pos": [360, -20],
|
||||
"size": {"0": 340, "1": 210},
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "value", "type": "STRING", "widget": {"name": "value"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "STRING", "type": "STRING", "links": [2], "slot_index": 0}
|
||||
],
|
||||
"title": "Halfbody Prompts",
|
||||
"properties": {"cnr_id": "comfy-core", "ver": "0.17.0", "Node name for S&R": "PrimitiveStringMultiline"},
|
||||
"widgets_values": ["05 half-body portrait, shoulders and chest visible, neutral expression, studio lighting, grey background\n06 half-body portrait, slight smile, arms relaxed at sides, soft window light from left\n07 half-body portrait, confident pose, looking slightly to the side, clean background\n08 half-body portrait, arms crossed, composed expression, even studio lighting"],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "PrimitiveStringMultiline",
|
||||
"pos": [0, 210],
|
||||
"size": {"0": 340, "1": 210},
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "value", "type": "STRING", "widget": {"name": "value"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "STRING", "type": "STRING", "links": [3], "slot_index": 0}
|
||||
],
|
||||
"title": "Fullbody Prompts",
|
||||
"properties": {"cnr_id": "comfy-core", "ver": "0.17.0", "Node name for S&R": "PrimitiveStringMultiline"},
|
||||
"widgets_values": ["09 full-body portrait, standing straight, neutral pose, studio lighting, clean background\n10 full-body portrait, casual relaxed pose, hands in pockets, soft outdoor light\n11 full-body portrait, mid-stride walking pose, urban setting, natural daylight\n12 full-body portrait, dynamic confident pose, weight on one leg, plain backdrop"],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "PrimitiveStringMultiline",
|
||||
"pos": [360, 210],
|
||||
"size": {"0": 340, "1": 210},
|
||||
"flags": {},
|
||||
"order": 3,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "value", "type": "STRING", "widget": {"name": "value"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "STRING", "type": "STRING", "links": [4], "slot_index": 0}
|
||||
],
|
||||
"title": "Tall Portrait Prompts",
|
||||
"properties": {"cnr_id": "comfy-core", "ver": "0.17.0", "Node name for S&R": "PrimitiveStringMultiline"},
|
||||
"widgets_values": ["13 tall portrait, full figure head to toe, neutral standing pose, studio lighting, clean background\n14 tall portrait, elegant standing pose, one hand on hip, soft diffused light\n15 tall portrait, outdoor setting, warm golden hour rim light, natural relaxed pose\n16 tall portrait, indoor setting, leaning against wall, soft directional light"],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"type": "SmartPromptController",
|
||||
"pos": [740, -20],
|
||||
"size": {"0": 300, "1": 290},
|
||||
"flags": {},
|
||||
"order": 4,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "prompt_list_1", "type": "STRING", "link": 1},
|
||||
{"name": "prompt_list_2", "type": "STRING", "link": 2},
|
||||
{"name": "prompt_list_3", "type": "STRING", "link": 3},
|
||||
{"name": "prompt_list_4", "type": "STRING", "link": 4},
|
||||
{"name": "index", "type": "INT", "widget": {"name": "index"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "prompt", "type": "STRING", "links": [], "slot_index": 0},
|
||||
{"name": "active_list", "type": "INT", "links": [7], "slot_index": 1}
|
||||
],
|
||||
"properties": {"cnr_id": "comfyui-craftkit", "Node name for S&R": "SmartPromptController"},
|
||||
"widgets_values": [1, "increment"],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"type": "SmartProfileSwitch",
|
||||
"pos": [740, 310],
|
||||
"size": {"0": 300, "1": 530},
|
||||
"flags": {},
|
||||
"order": 5,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{"name": "index", "type": "INT", "widget": {"name": "index"}, "link": 7},
|
||||
{"name": "label_1", "type": "STRING", "widget": {"name": "label_1"}, "link": null},
|
||||
{"name": "width_1", "type": "INT", "widget": {"name": "width_1"}, "link": null},
|
||||
{"name": "height_1", "type": "INT", "widget": {"name": "height_1"}, "link": null},
|
||||
{"name": "label_2", "type": "STRING", "widget": {"name": "label_2"}, "link": null},
|
||||
{"name": "width_2", "type": "INT", "widget": {"name": "width_2"}, "link": null},
|
||||
{"name": "height_2", "type": "INT", "widget": {"name": "height_2"}, "link": null},
|
||||
{"name": "label_3", "type": "STRING", "widget": {"name": "label_3"}, "link": null},
|
||||
{"name": "width_3", "type": "INT", "widget": {"name": "width_3"}, "link": null},
|
||||
{"name": "height_3", "type": "INT", "widget": {"name": "height_3"}, "link": null},
|
||||
{"name": "label_4", "type": "STRING", "widget": {"name": "label_4"}, "link": null},
|
||||
{"name": "width_4", "type": "INT", "widget": {"name": "width_4"}, "link": null},
|
||||
{"name": "height_4", "type": "INT", "widget": {"name": "height_4"}, "link": null}
|
||||
],
|
||||
"outputs": [
|
||||
{"name": "label", "type": "STRING", "links": [], "slot_index": 0},
|
||||
{"name": "width", "type": "INT", "links": [], "slot_index": 1},
|
||||
{"name": "height", "type": "INT", "links": [], "slot_index": 2}
|
||||
],
|
||||
"properties": {"cnr_id": "comfyui-craftkit", "Node name for S&R": "SmartProfileSwitch"},
|
||||
"widgets_values": [1, "Headshots", 1024, 1024, "Halfbody", 832, 1216, "Fullbody", 768, 1344, "Tall Portrait", 640, 1536],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"type": "Note",
|
||||
"pos": [1080, -20],
|
||||
"size": {"0": 300, "1": 380},
|
||||
"flags": {},
|
||||
"order": 7,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"properties": {},
|
||||
"widgets_values": ["Connect to your pipeline:\n\n→ prompt (SmartPromptController)\n positive CLIP text encoder\n\n→ label (SmartProfileSwitch)\n filename prefix or suffix\n e.g. SaveImageExtended filename_keys\n\n→ width / height (SmartProfileSwitch)\n EmptyLatentImage or EmptySD3LatentImage\n\n─────────────────\n\nTip: label auto-switches per category every generation — no manual filename changes needed."],
|
||||
"color": "#2a3a2a",
|
||||
"bgcolor": "#1a2a1a"
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[1, 3, 0, 7, 0, "STRING"],
|
||||
[2, 4, 0, 7, 1, "STRING"],
|
||||
[3, 5, 0, 7, 2, "STRING"],
|
||||
[4, 6, 0, 7, 3, "STRING"],
|
||||
[7, 7, 1, 8, 0, "INT"]
|
||||
],
|
||||
"groups": [
|
||||
{
|
||||
"title": "Prompt Lists",
|
||||
"bounding": [-20, -40, 720, 470],
|
||||
"color": "#2d5a3a",
|
||||
"font_size": 24
|
||||
},
|
||||
{
|
||||
"title": "CraftKit Control",
|
||||
"bounding": [720, -40, 340, 880],
|
||||
"color": "#1e3d5a",
|
||||
"font_size": 24
|
||||
},
|
||||
{
|
||||
"title": "Connect to Your Pipeline",
|
||||
"bounding": [1060, -40, 350, 440],
|
||||
"color": "#1e4a4a",
|
||||
"font_size": 24
|
||||
}
|
||||
],
|
||||
"config": {},
|
||||
"extra": {
|
||||
"ds": {"scale": 0.7, "offset": [-30, 230]}
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
@@ -22,9 +22,6 @@ app.registerExtension({
|
||||
}
|
||||
}, { serialize: false });
|
||||
|
||||
// Fully exclude from serialization (both save AND load skip it) so it never
|
||||
// shifts the index of the real widgets. serializeValue=()=>undefined did NOT
|
||||
// do this — it left a placeholder on save but was skipped on load → drift.
|
||||
btn.serialize = false;
|
||||
|
||||
// Move Browse button to right after input_folder (index 1)
|
||||
@@ -81,7 +78,7 @@ app.registerExtension({
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
const x = margin + i * (cellW + gap);
|
||||
const active = current === PRESETS[i];
|
||||
const active = Number(current) === PRESETS[i];
|
||||
|
||||
ctx.beginPath();
|
||||
if (ctx.roundRect) ctx.roundRect(x, top, cellW, h, 4);
|
||||
@@ -108,5 +105,99 @@ app.registerExtension({
|
||||
node.widgets.splice(lsIdx + 1, 0, presetWidget);
|
||||
}
|
||||
}
|
||||
|
||||
// Override serialize so non-serializable JS widgets (Browse, presets, status,
|
||||
// run batch) are excluded from widgets_values in the saved workflow JSON.
|
||||
// Without this, LiteGraph saves null slots for these widgets which then shift
|
||||
// all Python widget values on load (configure runs before nodeCreated).
|
||||
// Invariant: Python widgets must stay in their original relative order in
|
||||
// this.widgets — JS widgets may be spliced in between, but never reorder
|
||||
// the Python ones, or the positional value assignment on load will silently
|
||||
// misalign.
|
||||
const origSerialize = node.serialize;
|
||||
node.serialize = function () {
|
||||
const data = origSerialize.call(this);
|
||||
if (data.widgets_values) {
|
||||
data.widgets_values = this.widgets
|
||||
.filter(w => w.serialize !== false && w.options?.serialize !== false)
|
||||
.map(w => w.value);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
// Canvas-drawn status display
|
||||
const statusWidget = node.addWidget("button", "_sbr_status", null, () => {}, { serialize: false });
|
||||
statusWidget.serialize = false;
|
||||
statusWidget._text = "";
|
||||
|
||||
statusWidget.draw = function (ctx, node, widgetWidth, y, height) {
|
||||
const margin = 14;
|
||||
const innerW = widgetWidth - margin * 2;
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
if (ctx.roundRect) ctx.roundRect(margin, y + 2, innerW, height - 4, 4);
|
||||
else ctx.rect(margin, y + 2, innerW, height - 4);
|
||||
ctx.fillStyle = "#111";
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = this._text ? "#3a3a3a" : "#222";
|
||||
ctx.lineWidth = 1;
|
||||
ctx.stroke();
|
||||
ctx.font = "11px sans-serif";
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.fillStyle = this._text ? "#f28f41" : "#666";
|
||||
ctx.fillText(this._text || "— RUN TO PROCESS —", widgetWidth / 2, y + height / 2);
|
||||
ctx.restore();
|
||||
};
|
||||
|
||||
// Run Batch button
|
||||
const runBtn = node.addWidget("button", "▶ Run Batch", null, () => {
|
||||
app.queuePrompt(0, 1).catch(e => console.error("[SmartBatchResize] Queue failed:", e));
|
||||
}, { serialize: false });
|
||||
runBtn.serialize = false;
|
||||
|
||||
// Show/hide counter_start based on use_counter toggle
|
||||
const useCounterWidget = node.widgets?.find(w => w.name === "use_counter");
|
||||
const counterStartWidget = node.widgets?.find(w => w.name === "counter_start");
|
||||
if (useCounterWidget && counterStartWidget) {
|
||||
const defaultComputeSize = counterStartWidget.computeSize;
|
||||
const updateCounterVisibility = () => {
|
||||
counterStartWidget.computeSize = useCounterWidget.value
|
||||
? defaultComputeSize
|
||||
: () => [0, -4];
|
||||
node.setDirtyCanvas(true);
|
||||
};
|
||||
const origCallback = useCounterWidget.callback;
|
||||
useCounterWidget.callback = function (...args) {
|
||||
origCallback?.call(this, ...args);
|
||||
updateCounterVisibility();
|
||||
};
|
||||
const origOnConfigure = node.onConfigure;
|
||||
node.onConfigure = function (...args) {
|
||||
origOnConfigure?.call(this, ...args);
|
||||
updateCounterVisibility();
|
||||
};
|
||||
updateCounterVisibility();
|
||||
}
|
||||
|
||||
// Hide any customtext widget already present (e.g. from a previously run workflow)
|
||||
const hideCustomText = () => {
|
||||
for (const w of node.widgets) {
|
||||
if (w.type === "customtext") w.computeSize = () => [0, -4];
|
||||
}
|
||||
};
|
||||
hideCustomText();
|
||||
|
||||
// Intercept onExecuted to update status and hide the default customtext output
|
||||
const origOnExecuted = node.onExecuted;
|
||||
node.onExecuted = function (output) {
|
||||
origOnExecuted?.call(this, output);
|
||||
if (output?.text?.[0]) {
|
||||
statusWidget._text = output.text[0];
|
||||
hideCustomText();
|
||||
}
|
||||
node.setDirtyCanvas(true);
|
||||
};
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "Craftopia.SmartProfileSwitch",
|
||||
|
||||
async nodeCreated(node) {
|
||||
if (node.comfyClass !== "SmartProfileSwitch") return;
|
||||
|
||||
// Slot header dividers — visual only, not serialized
|
||||
const dividers = [];
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
const div = node.addWidget("button", `_div_${i}`, null, () => {}, { serialize: false });
|
||||
div.serialize = false;
|
||||
const num = i;
|
||||
div.draw = function (ctx, node, widgetWidth, y, height) {
|
||||
const lx = 14;
|
||||
const label = `SLOT ${num}`;
|
||||
ctx.save();
|
||||
ctx.font = "bold 10px sans-serif";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.textAlign = "left";
|
||||
ctx.fillStyle = "#888";
|
||||
ctx.fillText(label, lx, y + height / 2);
|
||||
const lineX = lx + ctx.measureText(label).width + 8;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(lineX, y + height / 2);
|
||||
ctx.lineTo(widgetWidth - 14, y + height / 2);
|
||||
ctx.strokeStyle = "#333";
|
||||
ctx.lineWidth = 1;
|
||||
ctx.stroke();
|
||||
ctx.restore();
|
||||
};
|
||||
dividers.push(div);
|
||||
}
|
||||
|
||||
// Status widget — shows active slot after execution
|
||||
const statusWidget = node.addWidget("button", "_sps_status", null, () => {}, { serialize: false });
|
||||
statusWidget.serialize = false;
|
||||
statusWidget._text = "";
|
||||
|
||||
statusWidget.draw = function (ctx, node, widgetWidth, y, height) {
|
||||
const margin = 14;
|
||||
const innerW = widgetWidth - margin * 2;
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
if (ctx.roundRect) ctx.roundRect(margin, y + 2, innerW, height - 4, 4);
|
||||
else ctx.rect(margin, y + 2, innerW, height - 4);
|
||||
ctx.fillStyle = "#111";
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = this._text ? "#3a3a3a" : "#222";
|
||||
ctx.lineWidth = 1;
|
||||
ctx.stroke();
|
||||
ctx.font = "11px sans-serif";
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.fillStyle = this._text ? "#f28f41" : "#666";
|
||||
ctx.fillText(
|
||||
this._text || "— RUN TO SEE RESULT —",
|
||||
widgetWidth / 2,
|
||||
y + height / 2
|
||||
);
|
||||
ctx.restore();
|
||||
};
|
||||
|
||||
// Reorder: index, [div1, label_1, w_1, h_1], ..., [div4, label_4, w_4, h_4], status
|
||||
const indexWidget = node.widgets.find(w => w.name === "index");
|
||||
const slotWidgets = [];
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
slotWidgets.push(
|
||||
dividers[i - 1],
|
||||
node.widgets.find(w => w.name === `label_${i}`),
|
||||
node.widgets.find(w => w.name === `width_${i}`),
|
||||
node.widgets.find(w => w.name === `height_${i}`),
|
||||
);
|
||||
}
|
||||
node.widgets = [indexWidget, ...slotWidgets, statusWidget];
|
||||
|
||||
// Serialize override — keeps non-serializable widgets out of widgets_values
|
||||
const origSerialize = node.serialize;
|
||||
node.serialize = function () {
|
||||
const data = origSerialize.call(this);
|
||||
if (data.widgets_values) {
|
||||
data.widgets_values = this.widgets
|
||||
.filter(w => w.serialize !== false && w.options?.serialize !== false)
|
||||
.map(w => w.value);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
// onExecuted — update status, hide default customtext textarea
|
||||
const origOnExecuted = node.onExecuted;
|
||||
node.onExecuted = function (output) {
|
||||
origOnExecuted?.call(this, output);
|
||||
if (output?.text?.[0]) {
|
||||
statusWidget._text = output.text[0];
|
||||
for (const w of node.widgets) {
|
||||
if (w !== statusWidget && w.type === "customtext") {
|
||||
w.computeSize = () => [0, -4];
|
||||
}
|
||||
}
|
||||
}
|
||||
node.setDirtyCanvas(true);
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -31,7 +31,7 @@ app.registerExtension({
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.fillStyle = this._text ? "#f28f41" : "#666";
|
||||
ctx.fillText(
|
||||
this._text || "— run to see result —",
|
||||
this._text || "— RUN TO SEE RESULT —",
|
||||
widgetWidth / 2,
|
||||
y + height / 2
|
||||
);
|
||||
|
||||
@@ -46,7 +46,7 @@ app.registerExtension({
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
const x = margin + i * (cellW + gap);
|
||||
const active = current === PRESETS[i];
|
||||
const active = Number(current) === PRESETS[i];
|
||||
|
||||
ctx.beginPath();
|
||||
if (ctx.roundRect) ctx.roundRect(x, top, cellW, h, 4);
|
||||
@@ -65,6 +65,19 @@ app.registerExtension({
|
||||
ctx.restore();
|
||||
};
|
||||
|
||||
// Override serialize to exclude the non-serializable preset widget from
|
||||
// widgets_values — same drift fix as SmartBatchResize (see that file for details).
|
||||
const origSerialize = node.serialize;
|
||||
node.serialize = function () {
|
||||
const data = origSerialize.call(this);
|
||||
if (data.widgets_values) {
|
||||
data.widgets_values = this.widgets
|
||||
.filter(w => w.serialize !== false && w.options?.serialize !== false)
|
||||
.map(w => w.value);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
// Move preset row to right after longest_side
|
||||
const lsIdx = node.widgets.indexOf(longestSideWidget);
|
||||
const pwIdx = node.widgets.indexOf(presetWidget);
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
"longest_side": { "name": "Longest side (px)" },
|
||||
"multiple_of": { "name": "Round to multiple of" },
|
||||
"interpolation": { "name": "Interpolation method" },
|
||||
"prefix": { "name": "Filename prefix" },
|
||||
"use_original_name": { "name": "Keep original filename" },
|
||||
"use_counter": { "name": "Add counter" },
|
||||
"counter_start": { "name": "Counter start" },
|
||||
"suffix_resolution": { "name": "Add resolution to filename" },
|
||||
"suffix_custom": { "name": "Custom filename suffix" },
|
||||
"folder_resolution": { "name": "Create resolution subfolder" },
|
||||
"folder_custom": { "name": "Custom output subfolder" },
|
||||
"skip_if_exists": { "name": "Skip existing files" },
|
||||
@@ -46,10 +49,33 @@
|
||||
"2": { "name": "Resolution" }
|
||||
}
|
||||
},
|
||||
"SmartProfileSwitch": {
|
||||
"display_name": "Smart Profile Switch 🧩",
|
||||
"inputs": {
|
||||
"index": { "name": "Index" },
|
||||
"label_1": { "name": "Label 1" },
|
||||
"width_1": { "name": "Width 1" },
|
||||
"height_1": { "name": "Height 1" },
|
||||
"label_2": { "name": "Label 2" },
|
||||
"width_2": { "name": "Width 2" },
|
||||
"height_2": { "name": "Height 2" },
|
||||
"label_3": { "name": "Label 3" },
|
||||
"width_3": { "name": "Width 3" },
|
||||
"height_3": { "name": "Height 3" },
|
||||
"label_4": { "name": "Label 4" },
|
||||
"width_4": { "name": "Width 4" },
|
||||
"height_4": { "name": "Height 4" }
|
||||
},
|
||||
"outputs": {
|
||||
"0": { "name": "Label" },
|
||||
"1": { "name": "Width" },
|
||||
"2": { "name": "Height" }
|
||||
}
|
||||
},
|
||||
"SmartPromptController": {
|
||||
"display_name": "Smart Prompt Controller 📋",
|
||||
"inputs": {
|
||||
"counter": { "name": "counter" },
|
||||
"index": { "name": "Index" },
|
||||
"prompt_list_1": { "name": "Prompt list 1" },
|
||||
"prompt_list_2": { "name": "Prompt list 2" },
|
||||
"prompt_list_3": { "name": "Prompt list 3" },
|
||||
@@ -57,7 +83,7 @@
|
||||
},
|
||||
"outputs": {
|
||||
"0": { "name": "Prompt" },
|
||||
"1": { "name": "List index" }
|
||||
"1": { "name": "Active list" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-craftkit"
|
||||
description = "Smart resize, batch resize, resolution multiplier and prompt controller nodes for ComfyUI"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
license = { file = "LICENSE" }
|
||||
dependencies = []
|
||||
|
||||
|
||||
@@ -29,6 +29,28 @@ def _calc_new_size(w, h, longest_side, multiple_of):
|
||||
return new_w, new_h
|
||||
|
||||
|
||||
def _build_stem(original_stem, prefix, use_original_name, use_counter, counter_index, counter_start, suffix_resolution, longest_side, delimiter):
|
||||
parts = []
|
||||
|
||||
if prefix:
|
||||
parts.append(prefix)
|
||||
|
||||
if use_original_name:
|
||||
parts.append(original_stem)
|
||||
|
||||
if use_counter:
|
||||
number = counter_start + counter_index
|
||||
parts.append(f"{number:03d}")
|
||||
|
||||
if suffix_resolution:
|
||||
parts.append(str(longest_side))
|
||||
|
||||
if not parts:
|
||||
parts.append(original_stem)
|
||||
|
||||
return delimiter.join(parts)
|
||||
|
||||
|
||||
class SmartBatchResize:
|
||||
|
||||
@classmethod
|
||||
@@ -57,14 +79,26 @@ class SmartBatchResize:
|
||||
}),
|
||||
|
||||
# OUTPUT NAMING
|
||||
"suffix_resolution": ("BOOLEAN", {
|
||||
"default": True,
|
||||
"tooltip": "Append resolution to filename. E.g. image_1024.png"
|
||||
}),
|
||||
"suffix_custom": ("STRING", {
|
||||
"prefix": ("STRING", {
|
||||
"default": "",
|
||||
"multiline": False,
|
||||
"tooltip": "Text added after the filename. E.g. photo → photo_headshot."
|
||||
"tooltip": "Label prepended to filename. E.g. 'headshot' → headshot_photo_001_1024.jpg"
|
||||
}),
|
||||
"use_original_name": ("BOOLEAN", {
|
||||
"default": True,
|
||||
"tooltip": "Include the original filename in the output name."
|
||||
}),
|
||||
"use_counter": ("BOOLEAN", {
|
||||
"default": False,
|
||||
"tooltip": "Add a sequential 3-digit counter to each filename (001, 002, ...)."
|
||||
}),
|
||||
"counter_start": ("INT", {
|
||||
"default": 1, "min": 0, "max": 99999, "step": 1,
|
||||
"tooltip": "Starting number for the counter. Useful when processing multiple batches."
|
||||
}),
|
||||
"suffix_resolution": ("BOOLEAN", {
|
||||
"default": True,
|
||||
"tooltip": "Append resolution to filename. E.g. photo_1024.png"
|
||||
}),
|
||||
|
||||
# OUTPUT LOCATION
|
||||
@@ -86,7 +120,7 @@ class SmartBatchResize:
|
||||
"delimiter": ("STRING", {
|
||||
"default": "_",
|
||||
"multiline": False,
|
||||
"tooltip": "Separator between filename and folder parts. E.g. _ or -"
|
||||
"tooltip": "Separator between filename parts. E.g. _ or -"
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -99,35 +133,16 @@ class SmartBatchResize:
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def run(self, input_folder, longest_side, multiple_of, interpolation,
|
||||
suffix_resolution, suffix_custom,
|
||||
prefix, use_original_name, use_counter, counter_start, suffix_resolution,
|
||||
folder_resolution, folder_custom,
|
||||
skip_if_exists, delimiter):
|
||||
|
||||
# Resolve filename suffix
|
||||
suffix_raw = suffix_custom.strip()
|
||||
if suffix_resolution:
|
||||
if suffix_raw == "":
|
||||
suffix_raw = f"{delimiter}{longest_side}"
|
||||
else:
|
||||
suffix_raw = f"{suffix_raw}{delimiter}{longest_side}"
|
||||
|
||||
# Ensure delimiter is prepended if there's a suffix
|
||||
if suffix_raw != "" and not suffix_raw.startswith(delimiter):
|
||||
filename_suffix = f"{delimiter}{suffix_raw}"
|
||||
else:
|
||||
filename_suffix = suffix_raw
|
||||
|
||||
# Resolve output subfolder
|
||||
subfolder = folder_custom.strip()
|
||||
|
||||
if subfolder == "":
|
||||
if folder_resolution:
|
||||
subfolder = str(longest_side) # Only resolution
|
||||
else:
|
||||
subfolder = "resized" # Fallback
|
||||
else:
|
||||
if folder_resolution:
|
||||
subfolder = f"{subfolder}{delimiter}{longest_side}"
|
||||
subfolder = str(longest_side) if folder_resolution else "resized"
|
||||
elif folder_resolution:
|
||||
subfolder = f"{subfolder}{delimiter}{longest_side}"
|
||||
|
||||
input_folder = input_folder.strip()
|
||||
if not input_folder:
|
||||
@@ -148,13 +163,26 @@ class SmartBatchResize:
|
||||
|
||||
interp = INTERP_MAP[interpolation]
|
||||
images_out = []
|
||||
counter_index = 0
|
||||
|
||||
for f in files:
|
||||
out_name = f"{f.stem}{filename_suffix}{f.suffix.lower()}"
|
||||
stem = _build_stem(
|
||||
original_stem=f.stem,
|
||||
prefix=prefix.strip(),
|
||||
use_original_name=use_original_name,
|
||||
use_counter=use_counter,
|
||||
counter_index=counter_index,
|
||||
counter_start=counter_start,
|
||||
suffix_resolution=suffix_resolution,
|
||||
longest_side=longest_side,
|
||||
delimiter=delimiter,
|
||||
)
|
||||
out_name = f"{stem}{f.suffix.lower()}"
|
||||
out_path = out_dir / out_name
|
||||
|
||||
if skip_if_exists and out_path.exists():
|
||||
print(f"[SmartBatchResize] Skipped (exists): {out_name}")
|
||||
counter_index += 1
|
||||
continue
|
||||
|
||||
img = PILImage.open(f).convert("RGB")
|
||||
@@ -170,11 +198,13 @@ class SmartBatchResize:
|
||||
|
||||
arr = np.array(img_resized).astype("float32") / 255.0
|
||||
images_out.append(torch.from_numpy(arr).unsqueeze(0))
|
||||
counter_index += 1
|
||||
|
||||
if not images_out:
|
||||
raise ValueError("[SmartBatchResize] No images processed.")
|
||||
|
||||
return (images_out, len(images_out))
|
||||
summary = f"✓ {len(images_out)} images saved → {subfolder}/"
|
||||
return {"ui": {"text": [summary]}, "result": (images_out, len(images_out))}
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {"SmartBatchResize": SmartBatchResize}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
class SmartProfileSwitch:
|
||||
"""
|
||||
CraftKit — Smart Profile Switch 🧩
|
||||
Maps an active index (1–4) to a label, width, and height.
|
||||
Designed to pair with Smart Prompt Controller's active_list output.
|
||||
"""
|
||||
|
||||
_DEFAULTS = [
|
||||
("Headshots", 1024, 1024),
|
||||
("Halfbody", 832, 1216),
|
||||
("Fullbody", 768, 1344),
|
||||
("Tall", 640, 1536),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
required = {
|
||||
"index": ("INT", {
|
||||
"default": 1,
|
||||
"min": 1,
|
||||
"max": 4,
|
||||
"step": 1,
|
||||
"display": "number",
|
||||
"tooltip": "Active profile (1–4). Connect to active_list from Smart Prompt Controller.",
|
||||
}),
|
||||
}
|
||||
for i, (label, w, h) in enumerate(cls._DEFAULTS, 1):
|
||||
required[f"label_{i}"] = ("STRING", {
|
||||
"default": label,
|
||||
"tooltip": f"Label for profile {i}, used as filename suffix.",
|
||||
})
|
||||
required[f"width_{i}"] = ("INT", {"default": w, "min": 64, "max": 8192, "step": 8})
|
||||
required[f"height_{i}"] = ("INT", {"default": h, "min": 64, "max": 8192, "step": 8})
|
||||
return {"required": required}
|
||||
|
||||
RETURN_TYPES = ("STRING", "INT", "INT")
|
||||
RETURN_NAMES = ("label", "width", "height")
|
||||
FUNCTION = "route"
|
||||
CATEGORY = "CraftKit"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def route(self, index,
|
||||
label_1, width_1, height_1,
|
||||
label_2, width_2, height_2,
|
||||
label_3, width_3, height_3,
|
||||
label_4, width_4, height_4):
|
||||
slots = [
|
||||
(label_1, width_1, height_1),
|
||||
(label_2, width_2, height_2),
|
||||
(label_3, width_3, height_3),
|
||||
(label_4, width_4, height_4),
|
||||
]
|
||||
idx = max(1, min(4, index)) - 1
|
||||
label, width, height = slots[idx]
|
||||
status = f"Slot {idx + 1}: {label} | {width} × {height}"
|
||||
return {"ui": {"text": [status]}, "result": (label, width, height)}
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"SmartProfileSwitch": SmartProfileSwitch,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"SmartProfileSwitch": "Smart Profile Switch \U0001f9e9",
|
||||
}
|
||||
@@ -9,14 +9,14 @@ class SmartPromptController:
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"counter": ("INT", {
|
||||
"index": ("INT", {
|
||||
"default": 1,
|
||||
"min": 1,
|
||||
"max": 99999,
|
||||
"step": 1,
|
||||
"display": "number",
|
||||
"control_after_generate": "increment",
|
||||
"tooltip": "Current position across all lists. Increments each run.",
|
||||
"tooltip": "Current position across all lists.",
|
||||
}),
|
||||
},
|
||||
"optional": {
|
||||
@@ -28,7 +28,7 @@ class SmartPromptController:
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING", "INT")
|
||||
RETURN_NAMES = ("prompt", "list_index")
|
||||
RETURN_NAMES = ("prompt", "active_list")
|
||||
FUNCTION = "control"
|
||||
CATEGORY = "CraftKit"
|
||||
OUTPUT_NODE = True
|
||||
@@ -41,7 +41,7 @@ class SmartPromptController:
|
||||
text = text[0] if text else ""
|
||||
return [l for l in str(text).splitlines() if l.strip()]
|
||||
|
||||
def control(self, counter, prompt_list_1="", prompt_list_2="",
|
||||
def control(self, index, prompt_list_1="", prompt_list_2="",
|
||||
prompt_list_3="", prompt_list_4=""):
|
||||
raw = [prompt_list_1, prompt_list_2, prompt_list_3, prompt_list_4]
|
||||
|
||||
@@ -59,7 +59,7 @@ class SmartPromptController:
|
||||
"result": ("", 0)}
|
||||
|
||||
# Map counter position to list + line
|
||||
position = (counter - 1) % total_all
|
||||
idx = (index - 1) % total_all
|
||||
|
||||
cumulative = 0
|
||||
selected_list_index = 0
|
||||
@@ -67,9 +67,9 @@ class SmartPromptController:
|
||||
selected_prompt = ""
|
||||
|
||||
for list_idx, lines in active:
|
||||
if position < cumulative + len(lines):
|
||||
if idx < cumulative + len(lines):
|
||||
selected_list_index = list_idx
|
||||
selected_line_index = position - cumulative
|
||||
selected_line_index = idx - cumulative
|
||||
selected_prompt = lines[selected_line_index]
|
||||
break
|
||||
cumulative += len(lines)
|
||||
|
||||
@@ -48,8 +48,8 @@ class SmartResize:
|
||||
"tooltip": "Resampling method. Lanczos is sharpest for downscaling."
|
||||
}),
|
||||
"upscale_if_smaller": ("BOOLEAN", {
|
||||
"default": False,
|
||||
"tooltip": "Also upscale images that are already smaller than the target longest side."
|
||||
"default": True,
|
||||
"tooltip": "Upscale images that are smaller than the target longest side. Turn off to only ever downscale, never upscale."
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ class SmartResolutionMultiplier:
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"image": ("IMAGE", {
|
||||
"tooltip": "Source image. Its current width/height are read directly — no separate Get Image Size node needed."
|
||||
}),
|
||||
"multiplier": ("FLOAT", {
|
||||
"default": 2.0,
|
||||
"min": 0.1,
|
||||
|
||||