Stage 1: Feature Alignment and Structure Learning
This repository contains the official implementation for the First Stage (Feature Alignment) of ApDepth. In this stage, we establish a robust semantic foundation by explicitly aligning the intermediate features of the denoising U-Net with high-quality semantic representations from a pre-trained external encoder (DINOv2) using a spatial-preserving Conv Adapter and a Cosine Similarity loss.
Please refer to installation.md for environment setup and dependencies.
Modify the data directory in the training script scripts/train_s1.sh:
BASE_DATA_DIR=YOUR_DATA_DIR # directory of training dataPrepare the Hypersim and Virtual KITTI 2 datasets and save them into ${BASE_DATA_DIR} following the data structure protocol of Marigold.
Modify the checkpoint directory in scripts/train_s1.sh:
BASE_CKPT_DIR=YOUR_CHECKPOINT_DIR # directory of pretrained checkpoint- Diffusion Backbone: Download the Stable Diffusion v2 checkpoint into
${BASE_CKPT_DIR}. - External Semantic Encoder: Download the checkpoint of DINOv2 into the
checkpoints/directory (This provides the patch-level semantic priors for feature alignment).
Once the datasets and checkpoints are properly set up, you can start the first-stage training (Feature Alignment) by running the following script:
bash scripts/train_s1.shNote: The first stage is trained for 20,000 iterations purely in the feature space to prevent the network from prematurely overfitting to low-level texture details.
Our code is built upon the foundational work of Marigold and DepthMaster. We also profoundly thank the developers of DINOv2 for providing the exceptional pre-trained vision foundation models.
This work is licensed under the Apache License, Version 2.0 (as defined in the LICENSE).
