Nodes/ComfyUI-QwenEdit-Urbanism-by-UGA/Random Image Selector 🎲
ComfyUI Node

Random Image Selector 🎲

Random Image Selector 🎲 β€” let the dice pick your next base image

By perezjoanΒ·Created 10 months agoΒ·Updated 9 months agoΒ· 2
Random Image Selector 🎲
  • image1
  • image2
  • image3
  • image4
  • image5
  • image6
  • selected_image
  • index

The Random Image Selector is a six-slot image roulette. You wire up to six reference images into it, hit Queue, and it hands exactly one of them - a different one each run - to the rest of your workflow. No rewiring, no dragging a new image in by hand between runs. It exists because the boring part of an image-edit pipeline is the human: you edit one street view, decide to try another, and swap inputs by hand. This node turns "try the next one" into a button.

It ships in the Urban Geo Analytics pack that wraps Qwen-Image-Edit (GGUF) for offline, local image editing - no API, no cloud. Qwen-Edit is the model that took the jobs masks and adapters used to do: you hand it a picture and a sentence ("replace this facade with brick," "remove that parked car") and the whole frame comes back edited. When you're exploring variations across a pile of reference shots, a random picker in front of the model is a genuinely nice way to get unforced variety. That's the whole pitch: stochastic rendering for urban design work, plus a useful trick for batch workflows.

How it works

Under the hood it's about fifteen lines. It collects only the inputs you actually connected (empty slots are skipped, not errors), seeds Python's random with the current time, and picks an index in range. Two outputs come out: the chosen image and the 0-based index.

The load-bearing part is in IS_CHANGED, which returns float(time.time()). That's the detail that makes a "random" node actually random in ComfyUI. Without it, ComfyUI caches node outputs between runs, so your random pick would come back the same every time. The author forces a re-run on every queue, which means each execution is a fresh roll. Worth knowing, because it's the exact thing most homebrew random nodes get wrong.

Inputs and outputs that matter

All six inputs are optional IMAGE - image1 through image6 - so you can start with two and add more later. The two outputs are:

  • selected_image (IMAGE) - the winner. Wire this into your Qwen-Edit / img2img image input and that's the whole point.
  • index (INT) - which slot won, 0-based. Handy if you want to log the pick or use it to drive a conditional elsewhere in the graph.

Installing it

Install once for the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/perezjoan/ComfyUI-QwenEdit-Urbanism-by-UGA

Restart ComfyUI and it shows up under image/random (ComfyUI Manager finds it if you search "ComfyUI-QwenEdit-Urbanism-by-UGA"). Two honest caveats. First, the README tells you to drop a "QwenUrbanismNodes folder" into custom_nodes, but the repo's real layout is just __init__.py plus the node files at the root - cloning the repo directly is what works. Second, the pack itself has no requirements.txt; it's pure Python stdlib, so there's nothing to pip-install. The heavy stuff - the Qwen-Image-Edit GGUF checkpoint, VAE, and CLIP - comes from the pack's tutorials and lives in ComfyUI/models. That download is the real install cost, and it's in the gigabytes.

Troubleshooting

The one trap: as of the current commit, the pack's __init__.py imports a debug_print module that isn't actually in the repository. If you install and nothing appears under image/random, check your ComfyUI console - a failed pack import kills all its nodes at once. It's a tiny, fixable issue, but it's the first thing to look for.

Also: the pick is uniform, so if you want to force a specific image, disconnect the others rather than hoping. And one queue = one roll - if you want a run of different picks, keep pressing Queue (or use batch mode). Tiny node, small job, and it does it honestly.

Categoryimage/random

Inputs (6)

NameTypeDefaultDescription
image1optIMAGEβ€”
image2optIMAGEβ€”
image3optIMAGEβ€”
image4optIMAGEβ€”
image5optIMAGEβ€”
image6optIMAGEβ€”

Outputs (2)

NameTypeDescription
selected_imageIMAGEβ€”
indexINTβ€”