An implementation of 2D latent generative anamorphoses using Stable Diffusion 3.5, 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 accelerateNavigate 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/einstein_marilyn/" \
--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 |
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},
}
















