Image Random Transform
Flip, jitter, distort, repeat
- image
- IMAGE
If you're training a LoRA, an embedding, or any dataset pipeline in ComfyUI, your single input image is never enough - you want a dozen slightly varied copies so the trainer sees the same subject from different angles, lighting, and crops. XJImageRandomTransform is that augmentation stage: take one image, add random rotation, perspective distortion, color jitter, flips, and scale, and get a whole batch of variations out.
It's from the ComfyUI-XJNodes pack, and it's a genuinely useful tool for the dataset side of training. It's the kind of node that saves you from a separate Python augmentation script when you just need a quick, seedable batch of variations.
How it works
The node uses torchvision.transforms.v2 under the hood - ComfyUI's own torch stack, no extra installs. It starts by repeating your image repeat times, and then applies a randomized transform chain to every copy except the first, which is kept as-is. That's a deliberate, smart default: your batch always contains the original, plus repeat - 1 augmented versions, so a training loop can always see the ground truth.
Each parameter is a knob on the randomness, not a fixed value:
distortion(0–1) - perspective warp strength.rotation(0–180°) - max random rotation (with expand).brightness,contrast,saturation,hue- color jitter ranges.scale(0–1) - random-resized-crop range, so the effective zoom varies.horizon_flip(0–1) - probability of a horizontal flip.
The seed input makes the whole thing reproducible: same seed, same sequence of transformations. So a failed training run can be re-run with identical augmentations, which is huge for debugging.
Output is a single IMAGE batch of repeat frames, all matching the original's dimensions (the transforms finish with a resize-crop back to the source size).
The inputs that matter
image- the source image.seed- reproducibility.repeat(1–256) - total frames out.- The range knobs above; leave color ones at 0 if you want shape-only augmentation.
Installing it
Part of ComfyUI-XJNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
then restart ComfyUI (or ComfyUI Manager → ComfyUI-XJNodes). No model downloads - though note it leans on torchvision, which ships with ComfyUI's standard install.
Common issues
Aggressive settings can produce garbage - a scale near 1 with high rotation can crop out the subject entirely, so validate one batch visually before training on it. And remember the "first copy is untouched" rule: if you expected repeat fully-randomized copies, you're getting one pristine original in there by design. If augmentations look different between runs, check that you're actually feeding a seed (or re-using the same one). Small pack, no community to lean on - but the knobs are well-named and the source is a single readable file.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| seed | INT | 00–18446744073709550000 | — |
| repeat | INT | 11–256 | — |
| distortion | FLOAT | 0.200–1 | — |
| rotation | FLOAT | 50–180 | — |
| brightness | FLOAT | 0.00-1–1 | — |
| contrast | FLOAT | 0.00-1–1 | — |
| saturation | FLOAT | 0.00-1–1 | — |
| hue | FLOAT | 0.200–1 | — |
| scale | FLOAT | 0.500–1 | — |
| horizon_flip | FLOAT | 0.500–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |