Skip to content

Image understanding, generation, and 3D reconstruction · Neural rendering and 3D reconstruction · VIS021 · Model

DUSt3R

DUSt3R predicts dense 3D pointmaps from image pairs, supporting reconstruction without requiring known camera calibration as an input to the pairwise model.

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

DUSt3R predicts dense 3D pointmaps from image pairs, supporting reconstruction without requiring known camera calibration as an input to the pairwise model. Pairwise predictions and global alignment can recover a consistent scene; absolute metric scale and global accuracy still require appropriate constraints.

Question / hypotheses

Can image-pair pointmaps recover coherent geometry when calibration is not supplied to the pairwise model? This is a modeling/evaluation question, not a formal null-hypothesis test.

Architecture / computational structure

A shared transformer encoder processes both images, and interacting decoder branches produce dense 3D pointmaps with confidence. Points for both images are expressed in a common coordinate frame. A subsequent optimization aligns pairwise outputs across larger image collections.

Assumptions

Training geometry and coordinate conventions matter. Pairwise confidence is not a statistical uncertainty guarantee. Repeated texture, weak overlap, unfamiliar intrinsics, moving objects and disconnected pair graphs can impair reconstruction; normalized losses do not establish metric scale.

Formula / computational definition

L=∑v,i[Cvi∥Xvi/z−Xˉvi/zˉ∥2−αlog⁡Cvi]L=\sum_{v,i}[C_{vi}\|X_{vi}/z-\bar X_{vi}/\bar z\|_2-\alpha\log C_{vi}], schematically, with valid-pixel masks and common scale normalizers z,zˉz,\bar z. XX and Xˉ\bar X denote predicted/target pointmaps; confidence C>0C>0 trades residual weighting against a log penalty.

Parameters and notation

Notation: Here v indexes the two views and i a valid pixel; predicted X and target X-bar share a chosen coordinate frame. z and z-bar normalize joint pointmap scale, C is learned confidence and alpha a fixed confidence penalty. A single-map simplification is labeled in the code.

Learned or estimated: Image encoder, cross-view decoder, pointmap and confidence-head weights; global alignment additionally estimates scene/camera/scale variables from predicted pairs.

Hyperparameters and effects: Checkpoint/input resolution, image-pair graph, valid-pixel/confidence thresholds, confidence-loss weight and alignment iterations. Pair coverage controls global consistency; confidence thresholds trade coverage against potentially unreliable points.

Fitting, fine-tuning, and adaptation

Start with a fixed checkpoint and validate on independent scenes. For domain adaptation, train pointmap/confidence heads or decoder blocks with a frozen image encoder, then use smaller encoder rates if justified. Use geometry-supervised losses and preserve common-frame/scale conventions. Monitor source-scene performance and confidence calibration; per-scene global alignment is an inference optimization distinct from neural fine-tuning.

How to use and calibrate

Split by complete scenes/captures and keep image pairs from one scene together; report calibration assumptions and alignment freedoms. Evaluate relative pose, point/depth error under explicit alignment, reconstruction completeness and failure by overlap. Report pair selection and global alignment costs. Separate confidence-ranked accuracy from coverage and avoid treating aligned scale-free accuracy as metric depth.

Example application

Reconstruct geometry from a small set of overlapping photographs with unknown calibration. This is a proposed use case, not a claim of validated performance on supplied real data.

Interpretation / pitfalls

Watch out

A scale-aligned reconstruction or reciprocal correspondence is not automatically metrically correct. Report alignment, coverage and correspondence filtering explicitly. A correct component calculation does not validate the full architecture, checkpoint or deployment pipeline.

Python and R code examples

Scope: Scale-normalized pointmap regression and confidence weighting on one small pointmap; real DUSt3R uses valid masks and paired-view coordinate/normalization conventions. Use the shared setup. Dependencies: NumPy / base R. Validation: Python executed; R unexecuted.

Full-model route: Python: official DUSt3R. R: labeled bridge for the pretrained transformer, or custom native torch. The examples isolate scale-normalized confidence-weighted pointmap loss; they do not perform image-to-3D reconstruction.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — Scale-normalized pointmap regression and confidence weighting on one small pointmap; real DUSt3R uses valid masks and paired-view coordinate/normalization conventions. Use the shared setup.

Shared setup for this chapter
import numpy as np
from itertools import permutations
def softmax(x):
    x=np.asarray(x,dtype=float)
    e=np.exp(x-x.max(axis=-1,keepdims=True))
    return e/e.sum(axis=-1,keepdims=True)
def bilinear(a,y,x):
    y=float(np.clip(y,0,a.shape[0]-1)); x=float(np.clip(x,0,a.shape[1]-1))
    y0=int(np.floor(y)); x0=int(np.floor(x))
    y1=min(y0+1,a.shape[0]-1); x1=min(x0+1,a.shape[1]-1)
    dy=y-y0; dx=x-x0
    return (1-dy)*((1-dx)*a[y0,x0]+dx*a[y0,x1])+dy*((1-dx)*a[y1,x0]+dx*a[y1,x1])
target=np.array([[1.,0.,2.],[0.,1.,2.],[-1.,0.,3.]])
pred=2*target+np.array([[.1,0,0],[0,.1,0],[0,0,-.1]])
def normalize(x): return x/np.linalg.norm(x,axis=1).mean()
residual=np.linalg.norm(normalize(pred)-normalize(target),axis=1)
confidence=np.array([2.,3.,1.5]); alpha=.1
loss=np.mean(confidence*residual-alpha*np.log(confidence))
assert np.allclose(normalize(pred),normalize(5*pred)) and np.all(confidence>=1)
print('normalized residual:',residual,'confidence loss:',loss)
R

Component demo, not a trained model — Scale-normalized pointmap regression and confidence weighting on one small pointmap; real DUSt3R uses valid masks and paired-view coordinate/normalization conventions. Use the shared setup.

Shared setup for this chapter
softmax <- function(x) {
  if(is.null(dim(x))) {e<-exp(x-max(x)); return(e/sum(e))}
  t(apply(x,1,function(v) {e<-exp(v-max(v)); e/sum(e)}))
}
bilinear <- function(a,y,x) {
  y<-min(max(y,0),nrow(a)-1); x<-min(max(x,0),ncol(a)-1)
  y0<-floor(y); x0<-floor(x); y1<-min(y0+1,nrow(a)-1); x1<-min(x0+1,ncol(a)-1)
  dy<-y-y0; dx<-x-x0
  (1-dy)*((1-dx)*a[y0+1,x0+1]+dx*a[y0+1,x1+1])+dy*((1-dx)*a[y1+1,x0+1]+dx*a[y1+1,x1+1])
}
target<-matrix(c(1,0,2,0,1,2,-1,0,3),3,byrow=TRUE)
pred<-2*target+matrix(c(.1,0,0,0,.1,0,0,0,-.1),3,byrow=TRUE)
normalize<-function(x) x/mean(sqrt(rowSums(x^2)))
residual<-sqrt(rowSums((normalize(pred)-normalize(target))^2))
confidence<-c(2,3,1.5); alpha<-.1
loss<-mean(confidence*residual-alpha*log(confidence))
stopifnot(max(abs(normalize(pred)-normalize(5*pred)))<1e-12,all(confidence>=1))
print(list(normalized_residual=residual,confidence_loss=loss))

Sources

From the CodeSplash reference, entry VIS021.