Depth Map 3D Photo Maker
Operator: Abdulla Al Fahad. How tools are built and checked
A depth map is a second picture, the same size as the photo, in which every pixel stores how near that point is. With one, a flat photograph can be re-drawn from a camera that has moved a few centimetres sideways, so nearby things slide past distant ones: the effect behind "3D photo" posts.
No stereo pair is needed, because the page asks a neural network, Depth Anything V2 Small, to estimate the depth from the single picture. You can then correct the estimate, pick a camera move, watch it live, and save the depth map, a looping video, a GIF, or the photo-and-depth pair that 3D photo viewers read.
The estimate is relative, not metric: it says which areas are nearer than others, not how many metres away they are.
Key features
- Depth Anything V2 Small, the Apache-2.0 size of the model, run through Transformers.js on WebGPU when the browser has it and on WebAssembly otherwise
- Depth look controls: invert, gamma from 0.4 to 2.5, and edge smoothing from 0 to 8 px
- Three camera moves, horizontal swing, circle and dolly zoom, with amount, depth strength, focus plane and loop length from 2 to 10 s, shown in a live WebGL preview with pause and a scrub slider
- Depth export as an 8-bit PNG or a 16-bit greyscale PNG at the photo's own size
- Looping WebM or MP4 video recorded in real time (a long side of 1152 or 1728 px for photos wider than 1.3:1, 864 or 1296 px for squarer ones), and a GIF at 480 px on the long side, 15 frames per second and up to 6 seconds
Depth estimation, the displacement mesh and the export formats
The photo is scaled to at most 2048 px on its long side. A copy at most 1024 px on its long side goes to the network, and the depth it returns is resampled to the photo's size, then stretched so the 1st and 99th percentile values become 0 and 1. Near areas are bright, as Depth Anything and Facebook 3D photos do; some 3D software expects the opposite, and Invert depth flips it.
A 16-bit export stores 65,536 levels instead of 256, which avoids the terraces that show up when a displacement shader or a 3D sculpting program turns an 8-bit map into relief. The 16-bit file is many times larger than the 8-bit one for the same photo, which is why the web-upload advice below points to the 8-bit file. The photo-and-depth ZIP holds name.jpg and name_depth.png (or .jpg), the pairing that tutorials for Facebook 3D photos describe and several viewers accept.
How it works
The photo becomes a texture on a grid of about 40,000 cells over the photo whose vertices are pushed toward the camera by the depth value, and the virtual camera moves along the chosen path. Where the depth jumps between neighbouring vertices, such as a head against a wall, the triangles between them stretch, which fills the gap that opens as the view changes with smeared edge pixels. The grid is also extended 35% past every edge of the photo with the border pixels repeated, so the frame never shows black as the camera sways.
Typical uses
- A wedding portrait for Instagram: a swing of 40% with the focus plane on the couple gives a 4-second loop in which the church behind them drifts slowly.
- A 3D artist who needs a quick displacement map from a brick-wall photo exports the 16-bit PNG and brings it into a shader as height.
Building one
- Drop one photo and press Estimate depth; the first run downloads the model.
- Judge the preview: invert the depth if near and far are reversed, and smooth the edges if the foreground tears.
- Set the focus plane on the subject so it stays still, and choose a motion and an amount.
- Export the depth PNG, the pair, a GIF, or record the video, which takes as long as one loop.
Example
A 3000 × 2000 photo of a market stall (illustrative), horizontal swing, 4 s loop, About 720p
market.jpg: press Estimate depth, then Depth PNG (16-bit), Make GIF and Record videoFiles saved, with sizes worked out from the page's rules
market_depth-16bit.png, 2048 × 1365 (the working size: the photo is scaled to 2048 px on its long side)
market-3d-swing.gif, 480 × 320, 60 frames at 15 fps (4 s)
market-3d-swing.webm, 1152 × 768, 4 s
The first run downloads about 99 MB of model from Hugging Face; the runtime is served by this siteThings to check before you rely on it
The network guesses depth from visual cues, so glass, mirrors, reflections and thin objects get wrong depths, and a flat poster of a landscape is read as a landscape.
Stretching hides what was behind a foreground edge but cannot invent it, so large camera moves show smeared halos. The clip stays convincing only for small moves.
A 16-bit PNG of a large photo is big and many web uploaders reject it; use the 8-bit file for the web and the 16-bit one for 3D work.
Browsers vary in what MediaRecorder can encode: Chromium writes WebM while other browsers may produce MP4, and the page names the file after what the browser produced.
- A dolly zoom with a focus plane on the subject's eyes makes the background swell or shrink behind them; keep the amount under 40% or the nearest pixels tear.
- If a fence or wire in the foreground shreds, raise the depth smoothing to 3 to 4 px, which trades a softer foreground edge for fewer tears.
Common errors and how to fix them
- Estimate depth stalls on the progress bar
- The 99 MB Depth Anything V2 Small download comes from huggingface.co, so an offline network or a blocker on that host stops it. Allow it and press Estimate depth again; files already fetched are cached.
- The estimate fails with a memory error
- Close other tabs. Untick Use WebGPU to run on the CPU, which draws on system memory instead of GPU memory. A smaller photo rarely helps, because the network input is already limited to 1024 px.
- "This browser cannot record video from a canvas"
- Recording needs the browser to encode a canvas stream, which this one cannot. The GIF export, the photo-and-depth pair and both depth PNGs do not depend on it.
- "This browser could not start WebGL 2"
- The preview and the video need WebGL 2. The depth PNG exports still work without it.
Frequently asked questions
Is Depth Anything V2 Small allowed to be used commercially?
The Small checkpoint is released under the Apache-2.0 licence, which permits commercial use. The larger Base and Large checkpoints use a non-commercial licence, which is why this page offers only Small.
Why is the depth map blurry at object edges?
The network works at 1024 px and the result is enlarged to the photo's size, so edges are softer than the photo's. The smoothing slider adds more softness on purpose, because a hard depth step makes the foreground tear when the camera moves.