Skip to content

Instantly share code, notes, and snippets.

@ThomasHambach
Created May 11, 2026 07:01
Show Gist options
  • Select an option

  • Save ThomasHambach/6c1cd557cba8588a92f1b199488ac1c9 to your computer and use it in GitHub Desktop.

Select an option

Save ThomasHambach/6c1cd557cba8588a92f1b199488ac1c9 to your computer and use it in GitHub Desktop.
InvokeAI 6 Dataset Triplet Sync Node
from .string_splitter import SplitDatasetStringInvocation

A utility node for InvokeAI 6 designed for LoRA dataset creation. It takes a master collection of strings (formatted as WidthxHeight|Path) and breaks them into three synchronized collections: Widths (Int), Heights (Int), and Paths/Prompts (String). This allows for automated batch processing of images with varying aspect ratios without manual configuration for each shot.

  1. Create a folder called split or something else in your invokeai nodes folder. Place the files in there. Make sure to restart your invoke.
  2. Create a collection of strings. Enter your values such as 512x512|D:\Documents\myprompts.txt
  3. Connect to iterator
  4. Connect to Split Dataset String
  5. Connect the output of width/height to where you need it. Connect File Path to Prompts from file
from invokeai.app.invocations.baseinvocation import (
BaseInvocation,
BaseInvocationOutput,
InvocationContext,
invocation,
invocation_output,
)
from invokeai.app.invocations.fields import InputField, OutputField
@invocation_output("split_dataset_string_output")
class SplitDatasetStringOutput(BaseInvocationOutput):
"""Outputs for the Dataset String Splitter"""
width: int = OutputField(description="The extracted width")
height: int = OutputField(description="The extracted height")
file_path: str = OutputField(description="The extracted file path or prompt")
@invocation(
"split_dataset_string",
title="Split Dataset String",
tags=["dataset", "string", "size"],
category="util",
version="1.0.2",
)
class SplitDatasetStringInvocation(BaseInvocation):
"""Splits a string like '832x1216|C:/path' into separate sockets"""
input_string: str = InputField(default="832x1216|C:/path/to/file.txt", description="Format: WidthxHeight|Path")
def invoke(self, context: InvocationContext) -> SplitDatasetStringOutput:
try:
# 1. Split the path from the resolution
parts = self.input_string.split('|')
res_part = parts[0].strip()
file_path = parts[1].strip() if len(parts) > 1 else ""
# 2. Split width and height
dimensions = res_part.lower().split('x')
width = int(dimensions[0].strip())
height = int(dimensions[1].strip())
return SplitDatasetStringOutput(
width=width,
height=height,
file_path=file_path
)
except Exception:
# Fallback if the string is mangled to prevent workflow crash
return SplitDatasetStringOutput(width=512, height=512, file_path=self.input_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment