An implementation of 2D latent generative anamorphoses using Stable Diffusion 3.5 medium (and optionally Flux2.dev), inspired by the LookingGlass paper, Chang et. al. [CVPR 2025].
This project generates anamorphic images — single images that reveal different content when viewed from different perspectives or transformations. For example, an image that looks like Einstein when viewed normally, but reveals Marilyn Monroe when rotated or rearranged.
Note: This implementation includes the basic 2D transformations suggested in the LookingGlass paper, such as circular rotations (90°, 135°, 180°), vertical/horizontal flipping, and the jigsaw permutation from Geng et al. The full 3D anamorphosis features from the original paper are not included.
| Jigsaw Puzzle : View 1 (Cat) | Jigsaw Puzzle : View 2 (Puppy) |
|---|---|
![]() |
![]() |
# Clone the repository
git clone https://github.com/your-repo/LatentGenerativeAnamorphoses.git
cd LatentGenerativeAnamorphoses
# Install dependencies
pip install -e diffusers/
pip install torch transformers accelerateWe tested SD3.5 on an RTX 4090. The Flux scripts are less well tested than the SD3.5 version. flux1_dev.py requires about 37GB of VRAM and flux2_dev.py requires about 68GB of VRAM (all at 1024x1024 resolution). We tested the Flux scripts on an RTX Pro 6000 GPU.
For SD3.5 make sure to accept the license request here and login in your terminal with hf auth login.
Navigate to the diffusers/ directory and run:
cd diffusers
python sd3.5.py \
--style-prompt "a pop art of" \
--prompt1 "a cat" \
--prompt2 "a puppy" \
--transform jigsaw \
--output-dir "outputs/cat_puppy/" \
--seed 1For Flux1.dev make sure to accept the license request here and login in your terminal with hf auth login.
We note that the original paper and our reimplementation is based on SD3.5 medium, so Flux inference is less well tested.
For optional Flux1.dev inference run:
cd diffusers
python flux1_dev.py \
--style-prompt "a pop art of" \
--prompt1 "a cat" \
--prompt2 "a puppy" \
--transform jigsaw \
--output-dir "outputs_flux1/cat_puppy/" \
--seed 1For Flux2.dev make sure to accept the license request here and login in your terminal with hf auth login.
For optional Flux2.dev inference run:
cd diffusers
python flux2_dev.py \
--style-prompt "a pop art of" \
--prompt1 "a cat" \
--prompt2 "a puppy" \
--transform jigsaw \
--output-dir "outputs_flux2/cat_puppy/" \
--seed 1| Argument | Default | Description |
|---|---|---|
--style-prompt |
"a pop art of " |
Style prefix applied to both prompts |
--prompt1 |
"albert einstein" |
First subject/view prompt |
--prompt2 |
"marilyn monroe" |
Second subject/view prompt (revealed after transform) |
--transform |
"jigsaw" |
Anamorphosis transform type (see below) |
--output-dir |
"." |
Directory to save generated images |
--seed |
1 |
Random seed for reproducibility |
| Transform | Description |
|---|---|
vertical |
Vertical flip — image reveals second prompt when flipped upside-down |
horizontal |
Horizontal flip — image reveals second prompt when mirrored left-right |
90flip |
90 degree flip — image reveals second prompt when image is flipped by 90 degree |
90rot |
90° circular rotation in center region |
135rot |
135° circular rotation in center region |
180rot |
180° circular rotation in center region |
jigsaw |
Jigsaw puzzle permutation (from Geng et al.) — rearranging tiles reveals second image |
- Style-Prompt : "a pop art of"
- Prompt1 : "albert einstein"
- Prompt2 : "marilyn monroe"
| View 1 (Einstein) | View 2 (Marilyn) |
|---|---|
![]() |
![]() |
- Style-Prompt : "an oil painting of"
- Prompt1 : "a bowl of fruits"
- Prompt2 : "a gorilla"
| View 1 (Fruit) | View 2 (Gorilla) |
|---|---|
![]() |
![]() |
- Style-Prompt : "a painting of"
- Prompt1 : "a village"
- Prompt2 : "a horse"
| View 1 (Village) | View 2 (Horse) |
|---|---|
![]() |
![]() |
- Style-Prompt : "a water color painting of"
- Prompt1 : "a puppy"
- Prompt2 : "a cat"
| View 1 (Puppy) | View 2 (Cat) |
|---|---|
![]() |
![]() |
- Style-Prompt : "an oil painting of"
- Prompt1 : "a ship"
- Prompt2 : "a village in the mountains"
| View 1 (Ship) | View 2 (Village) |
|---|---|
![]() |
![]() |
- Style-Prompt : "a water color painting of"
- Prompt1 : "flowers"
- Prompt2 : "a bird"
| View 1 (Flowers) | View 2 (Bird) |
|---|---|
![]() |
![]() |
- Style-Prompt : "a rendering of"
- Prompt1 : "an icy cave"
- Prompt2 : "a parrot"
| View 1 (Cave) | View 2 (Parrot) |
|---|---|
![]() |
![]() |
- Style-Prompt : "an oil painting of"
- Prompt1 : "people at a camp fire"
- Prompt2 : "a man"
| View 1 (Man) | View 2 (Camp Fire) |
|---|---|
![]() |
![]() |
For more details please see the explanation here and refer to the original paper
If you use this code, please cite the original papers. We thank the authors for their work:
LookingGlass (Laplacian Pyramid Warping method):
@misc{chang2025lookingglassgenerativeanamorphoseslaplacian,
title={LookingGlass: Generative Anamorphoses via Laplacian Pyramid Warping},
author={Pascal Chang and Sergio Sancho and Jingwei Tang and Markus Gross and Vinicius C. Azevedo},
year={2025},
eprint={2504.08902},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2504.08902},
}Visual Anagrams (Jigsaw transform):
@inproceedings{geng2024visualanagrams,
title={Visual Anagrams: Generating Multi-View Optical Illusions with Diffusion Models},
author={Daniel Geng and Inbum Park and Andrew Owens},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2024},
eprint={2311.17919},
archivePrefix={arXiv},
url={https://arxiv.org/abs/2311.17919},
}
















