VisualAnagramsSample
DeepFloyd optical illusions in ComfyUI
- image
VisualAnagramsSample is a ComfyUI port of the MIT "Visual Anagrams" paper (Geng et al., arXiv 2311.17919) - the one that made the rounds in late 2023 with images that turn into a completely different picture when you flip or rotate them. You type two prompts separated by a |, pick a transform, and out comes a single square image that reads as prompt one right-side up and as prompt two under that transform. Zero training, zero LoRA, zero ControlNet - it's pure sampling trickery running on top of DeepFloyd IF.
Let's be honest: this is a party-trick node. Nobody needs a poster that becomes a skull when you spin it 180 degrees, but it's a great "how does this even work" demo.
How it works
DeepFloyd IF is a two-stage model: IF-I renders a 64×64 image, then IF-II upscales it to 256×256. Both stages run the same trick here. During denoising, at every step the noisy latent is transformed - flipped, rotated, jigsaw-scrambled, whatever you picked - once per prompt. The UNet predicts the noise for each (transformed latent, prompt) pair, then every prediction gets inverse-transformed back to the original orientation and averaged. Denoise one step, repeat.
The elegant part: one set of pixels has to simultaneously look like prompt A to the model and like prompt B after the transform, so the model settles on an image that genuinely is both. The paper's theory says this works for transforms that are orthogonal (permutations), which is why flips and rotations behave cleanly - but so do jigsaw and patch shuffles.
Inputs and outputs
The input that matters is prompts. Split two prompts with |, like a grizzly bear | a field of sunflowers. The first prompt gets the identity view; everything after the pipe gets the transform. Three or more prompts technically parse, but you only get one view at a time, so extras just pile onto the same transformed latent - keep it to two.
viewpicks the illusion:flip,rotate_cw,rotate_180,negate,skew,patch_permute(scrambles 8×8 blocks),pixel_permute(finer scramble),jigsaw,inner_circle. Rotations and flips read the most cleanly; the permute options drift toward abstract.steps(default 30) andguidance_scale(default 10.0) behave like any sampler - more steps, tighter adherence, slower. Both stages run the same step count, so you're paying 30+30 denoise passes, not 30.seeddoes what you think.
Output: a single image tensor - one 256×256 frame - which you wire straight into a Save Image or Preview node. Want both orientations side by side? Flip a copy with ImageTransform and concatenate; the node doesn't do it for you.
Installing
The README's documented path is the boring one:
cd ComfyUI/custom_nodes
git clone https://github.com/zcfrank1st/comfyui_visual_anagrams.git
Restart ComfyUI and the node shows up under the visial_anagrams category (yes, that typo is in the source). ComfyUI Manager may list it too, but git clone is the guaranteed route.
Here's what the README undersells: first run downloads DeepFloyd IF-I and IF-II from Hugging Face - a multi-gigabyte pull, the bulk being IF-I's T5-XXL text encoder plus an ~8.6 GB stage-1 UNet (fp16) - into your HF cache, not ComfyUI's model folders. And both repos are gated: from_pretrained dies with a GatedRepoError until you've run huggingface-cli login and accepted the DeepFloyd license on each model page. Do that before your first queue, or the run fails instantly.
The pain points
VRAM. DeepFloyd IF at fp16 is hungry - budget ~16 GB+ to run this comfortably. Worse, the node loads IF-I and IF-II into VRAM at the same time (both hardcoded .to("cuda")), then throws them away when the run finishes, so every single generation reloads both models from disk. Slow starts, no caching, and no CPU or MPS path: NVIDIA GPU or nothing.
And whatever you do, don't pip install -r requirements.txt from the repo - it's a pinned pip freeze dump of somebody's entire environment (torch 2.1.1+cu118) that will fight ComfyUI's own torch install. The node only needs diffusers, which you almost certainly already have.
It's also a thin wrapper: one node, one output, no resolution or model-switching options, and a display-name typo so ComfyUI shows the raw class name. The author's TODO even lists an animation node that never shipped. Set expectations accordingly - but for a 30-second party trick that still drops jaws in 2026, it's hard to beat.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| prompts | STRING | use | to split two prompts | — |
| view | COMBO | 9 options: flip, rotate_cw, rotate_180, negate, skew, patch_permute, +3 | |
| steps | INT | 30 | — |
| guidance_scale | FLOAT | 10.00 | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |