Update model card for defm 1.1.0 and the benchmarks
#3
by manthanhp - opened
README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
pipeline_tag: image-feature-extraction
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# DeFM: Learning Foundation Representations from Depth for Robotics
|
|
@@ -28,25 +32,39 @@ TL;DR - A DINO-style encoder, but for depth image inputs.
|
|
| 28 |
|
| 29 |
## 🚀 Usage
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
### 1. Loading the Model
|
| 32 |
Load via **TorchHub** for easy integration:
|
| 33 |
|
| 34 |
```python
|
| 35 |
import torch
|
| 36 |
|
| 37 |
-
# Load the
|
| 38 |
model = torch.hub.load('leggedrobotics/defm:main', 'defm_vit_l14', pretrained=True)
|
| 39 |
model.eval().to("cuda")
|
| 40 |
```
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
### 2. Preprocessing
|
| 43 |
DeFM requires depth maps to be processed into our metric-aware 3-channel format.
|
| 44 |
|
| 45 |
```python
|
| 46 |
from defm import preprocess_depth_image
|
| 47 |
|
| 48 |
-
# Depth
|
| 49 |
-
normalized_depth = preprocess_depth_image(metric_depth, target_size=518, patch_size=14)
|
| 50 |
```
|
| 51 |
|
| 52 |
### 3. Inference
|
|
@@ -59,26 +77,59 @@ spatial_tokens = output[0][0] # (B, C, H', W')
|
|
| 59 |
class_token = output[0][1] # (B, C)
|
| 60 |
```
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
For more details, visit our [GitHub repository](https://github.com/leggedrobotics/defm).
|
| 63 |
|
| 64 |
## 📊 Model Zoo
|
| 65 |
|
| 66 |
The following table provides a comprehensive overview of the DeFM model family, including architectural parameters, inference latency across training and deployment hardware (224x224), and performance on the ImageNet-1k-Depth benchmark.
|
| 67 |
|
| 68 |
-
| Model | Params (M) | RTX 4090 (ms) | Jetson Orin (ms) | Top-5 KNN (%) | Linear Prob (%) | Checkpoint |
|
| 69 |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 70 |
-
| **DeFM ViT-L/14** |
|
| 71 |
-
| **DeFM ViT-S/14** |
|
| 72 |
-
| **DeFM ResNet-50** | 26.2 | 69.39 | 17.79 |
|
| 73 |
-
| **DeFM ResNet-34** |
|
| 74 |
-
| **DeFM ResNet-18** | 11.7 | 21.06 | 8.67 |
|
| 75 |
-
| **DeFM EfficientNet-B6** | 28.98 | 150.98 | 54.11 |
|
| 76 |
-
| **DeFM EfficientNet-B4** | 14.16 | 86.51 | 39.67 |
|
| 77 |
-
| **DeFM EfficientNet-B2** | 4.95 | 46.12 | 28.37 |
|
| 78 |
-
| **DeFM EfficientNet-B0** | 3.01 | 29.39 | 21.04 |
|
| 79 |
-
| **DeFM RegNetY-1.6GF** | 12.4 | 44.25 | 41.82 |
|
| 80 |
-
| **DeFM RegNetY-800MF** | 6.3 | 25.21 | 24.16 |
|
| 81 |
-
| **DeFM RegNetY-400MF** | 4.1 | 17.27 | 25.17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
---
|
| 83 |
|
| 84 |
## 📖 Citation
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
pipeline_tag: image-feature-extraction
|
| 4 |
+
datasets:
|
| 5 |
+
- leggedrobotics/defm-bench-imagenet-depth
|
| 6 |
+
- leggedrobotics/defm-bench-tartanground
|
| 7 |
+
- leggedrobotics/defm-bench-graspnet
|
| 8 |
---
|
| 9 |
|
| 10 |
# DeFM: Learning Foundation Representations from Depth for Robotics
|
|
|
|
| 32 |
|
| 33 |
## 🚀 Usage
|
| 34 |
|
| 35 |
+
Install the package from PyPI:
|
| 36 |
+
```bash
|
| 37 |
+
pip install defm
|
| 38 |
+
```
|
| 39 |
+
Loading through TorchHub only needs `torch torchvision numpy huggingface_hub omegaconf`.
|
| 40 |
+
|
| 41 |
### 1. Loading the Model
|
| 42 |
Load via **TorchHub** for easy integration:
|
| 43 |
|
| 44 |
```python
|
| 45 |
import torch
|
| 46 |
|
| 47 |
+
# Load the 304M-parameter foundation model
|
| 48 |
model = torch.hub.load('leggedrobotics/defm:main', 'defm_vit_l14', pretrained=True)
|
| 49 |
model.eval().to("cuda")
|
| 50 |
```
|
| 51 |
|
| 52 |
+
or, with the `defm` package installed:
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from defm.model_factory import create_defm_model
|
| 56 |
+
|
| 57 |
+
model = create_defm_model("defm_vit_l14", pretrained=True) # weights from the Hugging Face Hub
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
### 2. Preprocessing
|
| 61 |
DeFM requires depth maps to be processed into our metric-aware 3-channel format.
|
| 62 |
|
| 63 |
```python
|
| 64 |
from defm import preprocess_depth_image
|
| 65 |
|
| 66 |
+
# Depth in meters: (H, W) numpy array, tensor or PIL image. target_size is an int (square) or (H, W).
|
| 67 |
+
normalized_depth = preprocess_depth_image(metric_depth, target_size=518, patch_size=14).to("cuda")
|
| 68 |
```
|
| 69 |
|
| 70 |
### 3. Inference
|
|
|
|
| 77 |
class_token = output[0][1] # (B, C)
|
| 78 |
```
|
| 79 |
|
| 80 |
+
The CNN models (`defm_resnet50`, `defm_efficientnet_b0`, ...) return a dict instead, and their input height and width
|
| 81 |
+
must be multiples of 32:
|
| 82 |
+
|
| 83 |
+
```python
|
| 84 |
+
model = torch.hub.load('leggedrobotics/defm:main', 'defm_resnet50', pretrained=True).eval().to("cuda")
|
| 85 |
+
normalized_depth = preprocess_depth_image(metric_depth, target_size=(224, 320)).to("cuda")
|
| 86 |
+
|
| 87 |
+
with torch.no_grad():
|
| 88 |
+
output = model(normalized_depth)
|
| 89 |
+
|
| 90 |
+
class_token = output["global_backbone"] # (B, C)
|
| 91 |
+
spatial_tokens = output["dense_bifpn"]["P4"] # (B, C, H/16, W/16), the features distilled from the ViT
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
For more details, visit our [GitHub repository](https://github.com/leggedrobotics/defm).
|
| 95 |
|
| 96 |
## 📊 Model Zoo
|
| 97 |
|
| 98 |
The following table provides a comprehensive overview of the DeFM model family, including architectural parameters, inference latency across training and deployment hardware (224x224), and performance on the ImageNet-1k-Depth benchmark.
|
| 99 |
|
| 100 |
+
| Model | Params (M) | RTX 4090 BS-128 (ms) | Jetson Orin (ms) | Top-5 KNN (%) | Linear Prob (%) | Checkpoint |
|
| 101 |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 102 |
+
| **DeFM ViT-L/14** | 303.7 | 624.91 | 72.82 | 85.42 | 72.76 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_vit_l14.pth) |
|
| 103 |
+
| **DeFM ViT-S/14** | 21.6 | 63.76 | 11.92 | 79.37 | 62.74 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_vit_s14.pth) |
|
| 104 |
+
| **DeFM ResNet-50** | 26.2 | 69.39 | 17.79 | 78.93 | 62.56 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_resnet50.pth) |
|
| 105 |
+
| **DeFM ResNet-34** | 23.3 | 33.08 | 13.54 | 73.84 | 54.78 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_resnet34.pth) |
|
| 106 |
+
| **DeFM ResNet-18** | 11.7 | 21.06 | 8.67 | 70.93 | 51.57 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_resnet18.pth) |
|
| 107 |
+
| **DeFM EfficientNet-B6** | 28.98 | 150.98 | 54.11 | 79.30 | 60.70 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_efficientnet_b6.pth) |
|
| 108 |
+
| **DeFM EfficientNet-B4** | 14.16 | 86.51 | 39.67 | 76.45 | 56.24 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_efficientnet_b4.pth) |
|
| 109 |
+
| **DeFM EfficientNet-B2** | 4.95 | 46.12 | 28.37 | 72.89 | 51.64 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_efficientnet_b2.pth) |
|
| 110 |
+
| **DeFM EfficientNet-B0** | 3.01 | 29.39 | 21.04 | 69.54 | 47.17 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_efficientnet_b0.pth) |
|
| 111 |
+
| **DeFM RegNetY-1.6GF** | 12.4 | 44.25 | 41.82 | 77.96 | 58.88 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_regnet_y_1_6gf.pth) |
|
| 112 |
+
| **DeFM RegNetY-800MF** | 6.3 | 25.21 | 24.16 | 76.43 | 58.62 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_regnet_y_800mf.pth) |
|
| 113 |
+
| **DeFM RegNetY-400MF** | 4.1 | 17.27 | 25.17 | 74.43 | 51.80 | [Download](https://huggingface.co/leggedrobotics/defm/resolve/main/defm_regnet_y_400mf.pth) |
|
| 114 |
+
---
|
| 115 |
+
|
| 116 |
+
## 📏 Benchmarks
|
| 117 |
+
|
| 118 |
+
[`benchmarks/`](https://github.com/leggedrobotics/defm/blob/main/benchmarks/README.md) reproduces the linear-probe evaluations of the paper for DeFM and all image
|
| 119 |
+
baselines (DINOv2, DINOv3, Depth Anything V2, C-RADIOv3, Theia), loading every model from its official
|
| 120 |
+
Hugging Face weights:
|
| 121 |
+
|
| 122 |
+
```bash
|
| 123 |
+
git clone https://github.com/leggedrobotics/defm && cd defm
|
| 124 |
+
pip install -e ".[benchmarks]"
|
| 125 |
+
python -m benchmarks.segmentation --encoder defm_vit_l14 --dataset tartanground # ScanNet, SUN RGB-D, OFFSED, TartanGround, GraspNet
|
| 126 |
+
python -m benchmarks.classification --encoder defm_vit_s14 --eval knn linear # ImageNet-1k-Depth
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
[TartanGround](https://huggingface.co/datasets/leggedrobotics/defm-bench-tartanground), [GraspNet-1Billion](https://huggingface.co/datasets/leggedrobotics/defm-bench-graspnet) and [ImageNet-1k-Depth](https://huggingface.co/datasets/leggedrobotics/defm-bench-imagenet-depth) are downloaded from the Hub; ScanNet, SUN RGB-D and OFFSED
|
| 130 |
+
are built from their official releases with the scripts in `scripts/datasets/`. See the
|
| 131 |
+
[benchmark README](https://github.com/leggedrobotics/defm/blob/main/benchmarks/README.md) for datasets, protocol and results.
|
| 132 |
+
|
| 133 |
---
|
| 134 |
|
| 135 |
## 📖 Citation
|