Depth Estimation
Transformers
PyTorch
Safetensors
dpt
vision
dinov2
nielsr HF staff commited on
Commit
67e5305
1 Parent(s): 3d9e586

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +79 -0
README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - vision
5
+ - depth-estimation
6
+ inference: false
7
+ ---
8
+
9
+ # Model Card: DPT model with DINOv2 backbone
10
+
11
+ ## Model Details
12
+
13
+ DPT (Dense Prediction Transformer) model with DINOv2 backbone as proposed in [DINOv2: Learning Robust Visual Features without Supervision](https://arxiv.org/abs/2306.09683) by Oquab et al.
14
+
15
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dpt_architecture.jpg"
16
+ alt="drawing" width="600"/>
17
+
18
+ <small> DPT architecture. Taken from the <a href="https://arxiv.org/abs/2103.13413" target="_blank">original paper</a>. </small>
19
+
20
+ ### Resources
21
+
22
+ - [DINOv2 Paper](https://arxiv.org/abs/2304.07193)
23
+ - [DPT Paper](https://arxiv.org/abs/2103.13413)
24
+
25
+
26
+ ### Use with Transformers
27
+
28
+ ```python3
29
+ from transformers import AutoImageProcessor, DPTForDepthEstimation
30
+ import torch
31
+ import numpy as np
32
+ from PIL import Image
33
+ import requests
34
+
35
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
36
+ image = Image.open(requests.get(url, stream=True).raw)
37
+
38
+ image_processor = AutoImageProcessor.from_pretrained("facebook/dpt-dinov2-small-kitti")
39
+ model = DPTForDepthEstimation.from_pretrained("facebook/dpt-dinov2-small-kitti")
40
+
41
+ # prepare image for the model
42
+ inputs = image_processor(images=image, return_tensors="pt")
43
+
44
+ with torch.no_grad():
45
+ outputs = model(**inputs)
46
+ predicted_depth = outputs.predicted_depth
47
+
48
+ # interpolate to original size
49
+ prediction = torch.nn.functional.interpolate(
50
+ predicted_depth.unsqueeze(1),
51
+ size=image.size[::-1],
52
+ mode="bicubic",
53
+ align_corners=False,
54
+ )
55
+
56
+ # visualize the prediction
57
+ output = prediction.squeeze().cpu().numpy()
58
+ formatted = (output * 255 / np.max(output)).astype("uint8")
59
+ depth = Image.fromarray(formatted)
60
+ ```
61
+
62
+ ## Model Use
63
+
64
+ ### Intended Use
65
+
66
+ The model is intended to showcase that using the DPT framework with DINOv2 as backbone yields a powerful depth estimator.
67
+
68
+ ### BibTeX entry and citation info
69
+
70
+ ```bibtex
71
+ @misc{oquab2023dinov2,
72
+ title={DINOv2: Learning Robust Visual Features without Supervision},
73
+ author={Maxime Oquab and Timothée Darcet and Théo Moutakanni and Huy Vo and Marc Szafraniec and Vasil Khalidov and Pierre Fernandez and Daniel Haziza and Francisco Massa and Alaaeldin El-Nouby and Mahmoud Assran and Nicolas Ballas and Wojciech Galuba and Russell Howes and Po-Yao Huang and Shang-Wen Li and Ishan Misra and Michael Rabbat and Vasu Sharma and Gabriel Synnaeve and Hu Xu and Hervé Jegou and Julien Mairal and Patrick Labatut and Armand Joulin and Piotr Bojanowski},
74
+ year={2023},
75
+ eprint={2304.07193},
76
+ archivePrefix={arXiv},
77
+ primaryClass={cs.CV}
78
+ }
79
+ ```