Depth Anything 3 tutorial: turning a single photo into a moving 3D video
on this page
TL;DR
- We used Depth Anything 3 (DA3) to estimate the depth of a single photo, then used it to create a parallax video that looks like the camera is moving.
- On a gcube RTX 5060 8 GB, depth estimation took 0.07–0.23 seconds per photo, with 0.3–3.0 GB of peak PyTorch memory.
DA3MONO-LARGEgave the best quality. Building edges are sharp, and it correctly places the sky as the farthest point.- When the camera moves, about 3% of the frame is revealed as empty space. Filling it with OpenCV inpaint removes the black gaps along the edges.
- All the models we used are Apache 2.0, so commercial use is allowed, and you can download them without a separate agreement step.
Introduction
A photo is flat, but if you know how far each pixel is from the camera, you can create a sense of depth. Move near objects a lot and far objects a little, and you get a parallax effect, as if the camera were gliding sideways.
In this post, we estimate a photo’s depth with Depth Anything 3 (DA3), released by ByteDance Seed in November 2025, and build a parallax video with OpenCV. Everything runs on a single gcube RTX 5060 8 GB.
Choosing a model: check the license first
DA3’s license differs from model to model. The general-purpose models with LARGE or GIANT in their names are non-commercial (CC BY-NC 4.0), so in this post we used only Apache 2.0 models. All three can be downloaded from Hugging Face without a separate agreement step.
| Model | Parameters | License | Use |
|---|---|---|---|
| DA3-SMALL | 0.08B | Apache 2.0 | The lightest. Also supports multi-image input and camera estimation |
| DA3-BASE | 0.12B | Apache 2.0 | A middle ground between speed and quality |
| DA3MONO-LARGE | 0.35B | Apache 2.0 | Dedicated to single-image depth estimation, plus sky segmentation |
The test photos are three shots of Seoul from Unsplash. We chose scenes with clear differences in distance between foreground and background: Cheonggyecheon Stream (Zequn Gui), a hanok alley in Bukchon (Elliot Gouy) and a street full of signs (Markus Winkler).
1. Setup: create a gcube workload
In the gcube console, select the RTX 5060 8 GB and enter the values below.
| Item | Value |
|---|---|
| Container Image | pytorch/pytorch:2.9.1-cuda12.8-cudnn9-runtime |
| Container Port | 8888 |
| Container Environment Variables | HF_HOME=/workspace/hf_cache |
Container Command
bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git wget ffmpeg libgl1 libglib2.0-0 && pip install jupyterlab && jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --ServerApp.token='' --ServerApp.password=''"
- git: DA3 isn’t a PyPI package; you install it by cloning the GitHub repository.
- libgl1, libglib2.0-0: Needed by OpenCV, which DA3 uses to read images.
- ffmpeg: Used to save the parallax video as MP4 (H.264).
- HF_HOME: Keeps the model weights (about 2 GB for all three) in
/workspace. If you mount personal storage, you won’t have to download them again after a restart.
Once the workload is running, add /lab to the end of the service URL to open JupyterLab, then upload the test photos to a photos/ folder as cheonggyecheon.jpg, bukchon.jpg and street.jpg.
2. Installation
In a new notebook (Python 3), clone and install the official repository. Installation took about 20 seconds.
!cd /workspace && git clone -q https://github.com/ByteDance-Seed/Depth-Anything-3.git
!cd /workspace/Depth-Anything-3 && pip install -q -e . addict
- addict: It’s missing from the repository’s install list, and without it you’ll get
ModuleNotFoundError: No module named 'addict'. Install it alongside. - torch stays as is: The xformers 0.0.33 installed alongside is built for torch 2.9, so the image’s torch 2.9.1+cu128 isn’t changed. It worked fine on the RTX 5060 (sm_120). numpy is downgraded to 1.26.4.
After installing, restart the kernel and then check.
import torch, numpy
from depth_anything_3.api import DepthAnything3
print(torch.__version__, numpy.__version__, torch.cuda.get_device_name(0))
You’re ready when you see 2.9.1+cu128 1.26.4 NVIDIA GeForce RTX 5060. A warning that gsplat is required is for 3D Gaussian rendering, so you can ignore it for this post.
3. Creating depth maps and comparing models
Load the model and pass a photo path to inference(), and you get a depth map. The code below saves the depth values as .npy and also creates a preview image where closer areas are brighter.
import os, time, torch, numpy as np, cv2
from depth_anything_3.api import DepthAnything3
os.makedirs("depth", exist_ok=True)
model = DepthAnything3.from_pretrained("depth-anything/DA3MONO-LARGE").to("cuda").eval()
for name in ["cheonggyecheon", "bukchon", "street"]:
t = time.time()
pred = model.inference([f"photos/{name}.jpg"], process_res=1008)
d = pred.depth[0] # (H, W) float32, larger values are farther
np.save(f"depth/{name}.npy", d)
inv = 1.0 / np.clip(d, 1e-6, None) # convert so closer pixels get larger values
v = (inv - inv.min()) / (inv.max() - inv.min())
cv2.imwrite(f"depth/{name}.png", cv2.applyColorMap((v * 255).astype("uint8"), cv2.COLORMAP_INFERNO))
print(name, d.shape, f"{time.time() - t:.2f}s")
- process_res: The resolution (long side) used to compute depth. The default is 504; for the parallax video we used 1008 for sharper edges.
- On the first run, the weights download from Hugging Face (about 1.3 GB for DA3MONO-LARGE).
Speed and memory by model (RTX 5060 8 GB, average of three 1920px photos)
| Model | process_res | Time per photo | PyTorch peak memory |
|---|---|---|---|
| DA3-SMALL | 504 | 0.065 s | 0.32 GB |
| DA3-BASE | 504 | 0.071 s | 0.91 GB |
| DA3MONO-LARGE | 504 | 0.103 s | 2.11 GB |
| DA3MONO-LARGE | 1008 | 0.229 s | 2.98 GB |
These were measured after warming up each model once. Total GPU usage seen in nvidia-smi peaked at about 6.3 GB, which includes about 1.4 GB already in use before the experiment. It runs comfortably within 8 GB.
Quality comparison
- DA3-SMALL: Fast, but the edges of buildings and trees get smeared.
- DA3-BASE: Edges get a bit crisper, but it renders the sky blotchily, following the shape of the clouds.
- DA3MONO-LARGE: Edges stay sharp even on small objects like eaves and signs, and it cleanly places the sky at the farthest point (black). This is what prevents the sky from popping forward in the parallax video.
4. Making the parallax video
How it works
- Convert the depth map into “closeness” (0–1) and split the photo into 24 layers.
- For each frame, set the camera movement, and shift and scale closer layers more.
- Draw from the farthest layer first so closer layers cover them.
- Fill the empty areas revealed as foreground objects move using OpenCV inpaint, which uses the surrounding pixels.
- Pipe the frames straight to ffmpeg and save them as MP4 (H.264).
Code
Save the following as parallax.py.
"""Photo + depth map -> parallax (2.5D) video.
usage: python parallax.py photo.jpg depth.npy out.mp4 [--no-inpaint]"""
import sys, time, subprocess, numpy as np, cv2
photo, depth_path, out = sys.argv[1:4]
inpaint = "--no-inpaint" not in sys.argv
W = 1280; FPS = 30; SEC = 4; LAYERS = 24
AMP_X, AMP_Y, ZOOM = 0.035, 0.012, 0.06 # movement range (fraction of frame), zoom ratio
img = cv2.imread(photo)
H = round(img.shape[0] * W / img.shape[1] / 2) * 2
img = cv2.resize(img, (W, H), interpolation=cv2.INTER_AREA)
d = np.load(depth_path).astype(np.float32)
disp = 1.0 / np.clip(d, 1e-6, None) # closer pixels get larger values
disp = cv2.resize(disp, (W, H), interpolation=cv2.INTER_LINEAR)
lo, hi = np.percentile(disp, 2), np.percentile(disp, 98)
disp = np.clip((disp - lo) / (hi - lo + 1e-9), 0, 1)
disp = cv2.medianBlur((disp * 255).astype(np.uint8), 5).astype(np.float32) / 255
edges = np.linspace(0, 1, LAYERS + 1)
layer_id = np.clip(np.digitize(disp, edges) - 1, 0, LAYERS - 1)
cx, cy = W / 2, H / 2
ff = subprocess.Popen(["ffmpeg","-y","-loglevel","error","-f","rawvideo","-pix_fmt","bgr24","-s",f"{W}x{H}","-r",str(FPS),"-i","-",
"-c:v","libx264","-preset","veryfast","-crf","20","-pix_fmt","yuv420p","-movflags","+faststart",out], stdin=subprocess.PIPE)
t0 = time.time(); hole_ratio = []
for f in range(FPS * SEC):
ph = 2 * np.pi * f / (FPS * SEC)
dx, dy, z = AMP_X * W * np.sin(ph), AMP_Y * H * np.sin(2 * ph), ZOOM * (0.5 - 0.5 * np.cos(ph))
canvas = np.zeros_like(img); filled = np.zeros((H, W), np.uint8)
for k in range(LAYERS): # draw far layers first so near layers cover them
m = (layer_id == k).astype(np.uint8)
if not m.any(): continue
dk = (edges[k] + edges[k + 1]) / 2
s = 1 + z * dk
M = np.float32([[s, 0, (1 - s) * cx + dx * dk], [0, s, (1 - s) * cy + dy * dk]])
wi = cv2.warpAffine(img, M, (W, H), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT)
wm = cv2.warpAffine(m, M, (W, H), flags=cv2.INTER_NEAREST)
canvas[wm > 0] = wi[wm > 0]; filled |= wm
holes = (filled == 0).astype(np.uint8)
hole_ratio.append(holes.mean())
if inpaint and holes.any():
canvas = cv2.inpaint(canvas, cv2.dilate(holes, np.ones((3, 3), np.uint8)), 3, cv2.INPAINT_TELEA)
ff.stdin.write(canvas.tobytes())
ff.stdin.close(); ff.wait()
print(f"frames={FPS*SEC} size={W}x{H} render={time.time()-t0:.1f}s holes_avg={100*np.mean(hole_ratio):.2f}% holes_max={100*np.max(hole_ratio):.2f}%")
Run
!python parallax.py photos/bukchon.jpg depth/bukchon.npy bukchon_parallax.mp4
!python parallax.py photos/bukchon.jpg depth/bukchon.npy bukchon_noinpaint.mp4 --no-inpaint
- Adjusting the motion: Increasing
AMP_X(horizontal),AMP_Y(vertical) andZOOM(zoom) strengthens the 3D effect, but also reveals more empty space. - Number of layers: Increasing
LAYERSreduces stair-stepping between layers but makes rendering slower.
5. Results
Finished videos
Bukchon hanok alley
Cheonggyecheon Stream
Street of signs
Before and after filling the gaps
When the camera moves, areas that were hidden behind foreground objects come into view. The photo has no information about those areas, so they remain empty. With these settings, an average of 3.1% of the frame (up to 4.2%) was empty.
Without filling, black gaps appear along the edges of the houses and around the flower pots. Filling them with OpenCV inpaint removes the noticeable gaps.
Processing time and throughput
| Stage | Device | Time | Throughput per hour (estimated) |
|---|---|---|---|
| Depth estimation (MONO-LARGE, 504) | GPU | 0.103 s/photo | About 35,000 photos |
| Depth estimation (MONO-LARGE, 1008) | GPU | 0.229 s/photo | About 15,700 photos |
| Parallax rendering (1280px, 4 s, 120 frames) | CPU | 16.2 s/video | About 220 videos (1 process) |
- Rendering is the bottleneck: Depth estimation finishes in 0.2 seconds on the GPU, and most of the time goes to CPU rendering (per-layer shifting and inpainting).
- Going faster: You can increase throughput by rendering in parallel across multiple processes on the workload’s 12 CPU cores.
6. FAQ
Q. Can I use this commercially?
DA3-SMALL, DA3-BASE and DA3MONO-LARGE, which we used in this post, are Apache 2.0, so commercial use is allowed. However, the DA3-LARGE, DA3-GIANT and DA3NESTED models are non-commercial (CC BY-NC 4.0), so be sure to check the model name.
Q. Does it work on GPUs smaller than 8 GB?
DA3-SMALL used only 0.32 GB of PyTorch memory. If you run short on memory, switch to a smaller model or lower process_res.
Q. I get a No module named 'addict' error.
It’s a package missing from the repository’s install list. Install it with pip install addict.
Q. I want a stronger 3D effect in the video.
Increase AMP_X and ZOOM. But the empty areas grow too, so inpainting marks may become visible; adjust a little at a time. The effect works best on photos with clear differences in distance, such as alleys, roads and mountains.
Wrapping up
We estimated depth from a single photo and used it to create a moving 3D video. Depth estimation itself takes 0.1–0.2 seconds per photo on an RTX 5060 8 GB. You can apply this to workloads that process photos in bulk, such as adding motion to product shots, short-form videos for social media, and 3D previews of travel or real estate photos.
On gcube, you can rent as many GPUs as you need, from the RTX 5060 up to the RTX 5090, and try experiments like this right away.
References
- Depth Anything 3 official repository (ByteDance-Seed)
- DA3MONO-LARGE (Hugging Face)
- DA3-BASE (Hugging Face)
- Photos: Unsplash — Zequn Gui (Cheonggyecheon), Elliot Gouy (Bukchon), Markus Winkler (street of signs)