Skip to content

[ICML'26] PointDiT: Pixel-Space Diffusion for Monocular Geometry Estimation

Python

clean

haofeixuf6c1731a8306
diff --git a/README.md b/README.md
index 90e8717..515e412 100644
--- a/README.md
+++ b/README.md
@@ -54,11 +54,7 @@ pip install -r requirements.txt
git clone https://github.com/facebookresearch/dinov3.git third_party/dinov3
```
-All commands are run from the repository root, and the launch scripts in [scripts/](scripts). To check the installation:
-
-```bash
-bash run.sh # CPU-only smoke test: no GPU, checkpoint or dataset needed
-```
+All commands are run from the repository root, and the launch scripts in [scripts/](scripts).
The DINOv3 weights are gated and cannot be redistributed, so they are not part of the released
checkpoints. Request access on the
diff --git a/run.sh b/run.sh
deleted file mode 100644
index a760f09..0000000
--- a/run.sh
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/bash
-
-# Copyright 2026 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-#
-# Minimal end-to-end smoke test for PointDiT: CPU-only, no GPU, no dataset
-# download and no pre-trained checkpoint. It trains a randomly initialised model
-# for two steps on synthetic data, then samples from the resulting checkpoint.
-#
-# Run it from the repository root:
-#
-# bash run.sh
-#
-# The virtualenv it builds is deleted again on exit, so a full run leaves nothing
-# behind. Set POINTDIT_SKIP_VENV=1 to reuse the active interpreter instead of
-# building one (much faster when iterating locally, since the wheels below are
-# reinstalled from scratch every time otherwise).
-#
-set -e
-set -x
-
-cd "$(dirname "$0")"
-
-# Everything this script creates is torn down here, on failure as well as on
-# success. Both paths are guarded so the trap can be installed up front, before
-# either exists, and a single handler keeps one trap from replacing the other.
-SMOKE_DIR=""
-CLEAN_VENV=""
-cleanup() {
- if [ -n "${SMOKE_DIR}" ]; then rm -rf "${SMOKE_DIR}"; fi
- if [ -n "${CLEAN_VENV}" ]; then rm -rf "${CLEAN_VENV}"; fi
-}
-trap cleanup EXIT
-
-if [ -z "${POINTDIT_SKIP_VENV}" ]; then
- # Only remove a virtualenv we built ourselves: a pointdit_env that was already
- # there belongs to the user, and is theirs to keep.
- if [ ! -d pointdit_env ]; then
- CLEAN_VENV="${PWD}/pointdit_env"
- fi
- python3 -m venv pointdit_env
- source ./pointdit_env/bin/activate
- # CPU wheels keep this test small; see README.md for CUDA builds.
- pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
- pip install -r requirements.txt
-fi
-
-# The DINOv3 encoder code is not vendored: torch.hub builds it from a local
-# checkout. Only the architecture is needed here, not the gated weights.
-if [ ! -d third_party/dinov3 ]; then
- git clone --depth 1 https://github.com/facebookresearch/dinov3.git third_party/dinov3
-fi
-
-# Keep the test single-machine and CPU-only regardless of the host.
-export CUDA_VISIBLE_DEVICES=""
-export OMP_NUM_THREADS=2
-export MKL_NUM_THREADS=2
-
-SMOKE_DIR=$(mktemp -d)
-
-# Self-tests of the evaluation metrics (random tensors, CPU, no data needed).
-python -m metrics.compute_metrics
-python -m metrics.masked_resize
-
-# A few synthetic frames in the layout the Hypersim loader expects.
-python tools/make_smoke_data.py --out "${SMOKE_DIR}"
-
-# Stage 1: two training steps from scratch, at a tiny resolution.
-# --warmup_epochs 0 is required, else the LR schedule yields 0 for step 0-1.
-python main.py \
- --model PointDiT-B/16 --feature_embedding_type dinov3_vits16 --proj_dropout 0.0 \
- --device cpu --img_size 64 --batch_size 2 --num_workers 0 --no_pin_mem \
- --dataset_name hypersim --data_path "${SMOKE_DIR}/data" \
- --depth_intrinsics_resize_height 64 \
- --epochs 1 --warmup_epochs 0 --lr 1e-4 --debug_train_steps 2 \
- --output_dir "${SMOKE_DIR}/out"
-
-# Stage 2: sample from the checkpoint Stage 1 just wrote, on the wild-image path
-# (no ground truth and no intrinsics required).
-python main.py \
- --model PointDiT-B/16 --feature_embedding_type dinov3_vits16 --proj_dropout 0.0 \
- --device cpu --img_size 64 --num_sampling_steps 2 --gen_bsz 1 \
- --num_workers 0 --no_pin_mem \
- --evaluate_gen --eval_wild_images \
- --eval_wild_images_dir "${SMOKE_DIR}/wild" \
- --pretrained "${SMOKE_DIR}/out/checkpoint-last.pth" \
- --gen_output_root "${SMOKE_DIR}/generation" \
- --output_dir "${SMOKE_DIR}/out"
-
-# The run is only a success if it actually wrote predictions.
-OUT_DIR="${SMOKE_DIR}/generation"
-test -n "$(find "${OUT_DIR}" -name '*_depth.png' -print -quit)"
-test -n "$(find "${OUT_DIR}" -name '*_pointcloud.ply' -print -quit)"
-# Wild-image outputs are named after the input, with no index prefix, no doubled extension,
-# and no sky-mask panels.
-test -n "$(find "${OUT_DIR}" -name 'wild_01_depth.png' -print -quit)"
-test -n "$(find "${OUT_DIR}" -name 'wild_01_pointcloud.ply' -print -quit)"
-test -z "$(find "${OUT_DIR}" -name '*skymask*' -print -quit)"
-
-# We won't land here if there are errors due to set -e.
-echo "*** Success!"
diff --git a/tools/make_smoke_data.py b/tools/make_smoke_data.py
deleted file mode 100644
index 6ca9b01..0000000
--- a/tools/make_smoke_data.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# Copyright 2026 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Generate a tiny synthetic dataset so run.sh can exercise PointDiT offline.
-
-This writes a handful of frames in the on-disk layout the Hypersim loader
-expects (see ImageDepthIntrinsicsDataset._find_and_split_data_hypersim), plus a
-couple of loose images for the wild-image inference path:
-
- <out>/data/<scene>/<subscene>/<frame:06d>_rgb.png uint8 RGB
- /<frame:06d>_depth.npy float32 z-depth, metres
- /<frame:06d>_cam.npz key 'intrinsics', [3, 3]
- <out>/wild/<name>.png uint8 RGB
-
-The content is a smooth synthetic scene (a tilted ground plane with a box),
-not random noise, so the depth is geometrically plausible and the point-map
-conversion produces something meaningful to look at. Nothing here is training
-data -- it exists purely so the smoke test needs no download.
-
-Usage (from the repository root):
- python tools/make_smoke_data.py --out /tmp/pointdit_smoke
-"""
-
-import argparse
-import os
-
-import numpy as np
-from PIL import Image
-
-
-def _scene(height, width, seed):
- """Return (rgb uint8 [H, W, 3], depth float32 [H, W]) for one frame."""
- rng = np.random.RandomState(seed)
- yy, xx = np.meshgrid(np.arange(height), np.arange(width), indexing='ij')
- v = yy / max(height - 1, 1)
- u = xx / max(width - 1, 1)
-
- # A ground plane receding from the camera: depth grows towards the horizon.
- depth = 2.0 + 6.0 * (1.0 - v)
- # A nearer box occupying a rectangle in the middle of the frame.
- box = (v > 0.45) & (v < 0.8) & (u > 0.3) & (u < 0.7)
- depth[box] = 1.5 + 0.4 * u[box]
- # Mild per-frame variation so frames are not identical.
- depth = depth * (1.0 + 0.05 * rng.randn())
- depth = depth.astype(np.float32)
-
- # Shade the image from the depth so RGB and geometry are correlated.
- shade = (depth - depth.min()) / max(float(np.ptp(depth)), 1e-6)
- rgb = np.stack([1.0 - shade, 0.35 + 0.4 * u, shade], axis=-1)
- rgb = (np.clip(rgb, 0.0, 1.0) * 255).astype(np.uint8)
- return rgb, depth
-
-
-def _intrinsics(height, width):
- """A plausible pinhole K for a ~60 degree horizontal field of view."""
- focal = 0.5 * width / np.tan(np.deg2rad(60.0) / 2.0)
- return np.array([
- [focal, 0.0, width / 2.0],
- [0.0, focal, height / 2.0],
- [0.0, 0.0, 1.0],
- ], dtype=np.float32)
-
-
-def main():
- parser = argparse.ArgumentParser(
- description='Write a tiny synthetic dataset for the PointDiT smoke test')
- parser.add_argument('--out', required=True, help='Output directory')
- parser.add_argument('--size', type=int, default=96,
- help='Square image side in pixels')
- parser.add_argument('--scenes', type=int, default=2)
- parser.add_argument('--frames', type=int, default=2,
- help='Frames per scene')
- parser.add_argument('--wild', type=int, default=2,
- help='Loose images for the --eval_wild_images path')
- args = parser.parse_args()
-
- size = args.size
- K = _intrinsics(size, size)
-
- seed = 0
- for scene in range(args.scenes):
- subscene_dir = os.path.join(
- args.out, 'data', f'ai_{scene:03d}_001', 'cam_00')
- os.makedirs(subscene_dir, exist_ok=True)
- for frame in range(args.frames):
- rgb, depth = _scene(size, size, seed)
- seed += 1
- stem = os.path.join(subscene_dir, f'{frame:06d}')
- Image.fromarray(rgb).save(f'{stem}_rgb.png')
- np.save(f'{stem}_depth.npy', depth)
- np.savez(f'{stem}_cam.npz', intrinsics=K)
-
- wild_dir = os.path.join(args.out, 'wild')
- os.makedirs(wild_dir, exist_ok=True)
- for i in range(args.wild):
- rgb, _ = _scene(size, size, 1000 + i)
- Image.fromarray(rgb).save(os.path.join(wild_dir, f'wild_{i:02d}.png'))
-
- n_train = args.scenes * args.frames
- print(f'Wrote {n_train} training frame(s) under {args.out}/data '
- f'and {args.wild} image(s) under {args.out}/wild '
- f'({size}x{size}).')
-
-
-if __name__ == '__main__':
- main()