File size: 3,945 Bytes
f6696e9
 
 
 
 
 
aeba0bb
f6696e9
 
 
 
 
 
 
 
 
 
aeba0bb
f6696e9
 
 
 
 
 
c20e0ae
f6696e9
aeba0bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6696e9
 
 
 
 
 
 
 
 
 
aeba0bb
 
 
 
 
 
 
f6696e9
 
 
 
 
 
 
 
aeba0bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6696e9
 
 
 
aeba0bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
license: apache-2.0
base_model:
- depth-anything/Depth-Anything-V2-Small-hf
library_name: executorch
pipeline_tag: depth-estimation
inference: false
tags:
- executorch
- webgpu
- on-device
- browser
---
# Depth Anything V2 Small for ExecuTorch WebGPU

This repository contains an [ExecuTorch](https://github.com/pytorch/executorch) conversion of
[depth-anything/Depth-Anything-V2-Small-hf](https://huggingface.co/depth-anything/Depth-Anything-V2-Small-hf) for the ExecuTorch **WebGPU** backend, so the model runs entirely in a web browser on
the visitor's GPU. It powers the corresponding demo in the ExecuTorch WebGPU Playground (launching soon on [executorch.ai](https://executorch.ai)).

- **Base model:** [depth-anything/Depth-Anything-V2-Small-hf](https://huggingface.co/depth-anything/Depth-Anything-V2-Small-hf)
- **Format:** ExecuTorch `.pte` programs delegated to the WebGPU backend
- **Quantization:** fp32 (as exported)
- **Total size:** 92.8 MB

> **Note:** This is the Small variant, which is licensed Apache-2.0 (the larger Depth Anything V2 variants use a different license).

## About the original model

The Small variant of Depth Anything V2, a monocular depth estimation model trained on about 595K synthetic labeled images and 62M+ real unlabeled images.

- **Developed by:** Lihe Yang et al. (HKU and TikTok)
- **Paper:** [Depth Anything V2](https://arxiv.org/abs/2406.09414)
- 24.8M parameters
- Predicts relative depth from a single image

For training data, evaluation results and full details, see the original model card: [depth-anything/Depth-Anything-V2-Small-hf](https://huggingface.co/depth-anything/Depth-Anything-V2-Small-hf).

## Intended use and limitations

Relative depth maps for photos and camera frames.

Outputs relative (not metric) depth. Accuracy drops on reflective or transparent surfaces and unusual scenes.

## What changed in this conversion

- Fixed 224x224 input (upstream processes larger images)

## Inputs and outputs

- Input `[1, 3, 224, 224]` float32 RGB, ImageNet-normalized: `(x / 255 - mean) / std`, mean 0.485/0.456/0.406, std 0.229/0.224/0.225
- Output `[1, 224, 224]` float32 relative inverse depth (larger means closer)

## Files

| File | Size | SHA-256 |
|---|---|---|
| `depth_v2s_webgpu.pte` | 92.8 MB | `285602ed3a34a26a…` |

Full checksums are in `manifest.json`. The playground verifies them after download.

## Running it

These programs were exported with the ExecuTorch WebGPU backend
([backends/webgpu](https://github.com/pytorch/executorch/tree/main/backends/webgpu)) and validated with the
WebAssembly runtime build used by the ExecuTorch WebGPU Playground (launching soon on [executorch.ai](https://executorch.ai)). That runtime build is not published yet; until it is,
the playground is the supported way to run them. It downloads these files once, caches them in the browser,
and runs everything locally.

Requirements: a browser with WebGPU enabled.

## Provenance

- **Weights:** `depth-anything/Depth-Anything-V2-Small-hf` @ `5426e4f0f36572d16453bbda7a8389317b1bef99`, file `None`, sha256 `None` (official)
- **Exported with:** executorch 1.5.1+cpu, torch 2.14.1+cpu, torchao 0.18.0+cpu, transformers 5.19.0 (executorch git `3b6068392324`)
- **Reproduce:** `python recipes/depth-anything-v2-small.py --out out/depth-anything-v2-small` (recipe in `export/`)
- Re-running the recipe produces byte-identical files.

## Citation

If you use this model, please cite the original work:

```bibtex
@misc{yang2024depth,
  title={Depth Anything V2},
  author={Lihe Yang and Bingyi Kang and Zilong Huang and Zhen Zhao and Xiaogang Xu and Jiashi Feng and Hengshuang Zhao},
  year={2024},
  eprint={2406.09414},
  archivePrefix={arXiv},
  primaryClass={cs.CV}
}
```

## License

This is a derivative of the upstream model and is distributed under the same terms
(`apache-2.0`); see `LICENSE`.
Modifications (conversion to the ExecuTorch format) by Meta Platforms, Inc.