nielsr HF staff commited on
Commit
b045f9a
1 Parent(s): 2951e3d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +80 -0
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - vision
5
+ - dinov2
6
+ - depth-estimation
7
+ inference: false
8
+ ---
9
+
10
+ # Model Card: DPT model with DINOv2 backbone
11
+
12
+ ## Model Details
13
+
14
+ 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.
15
+
16
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dpt_architecture.jpg"
17
+ alt="drawing" width="600"/>
18
+
19
+ <small> DPT architecture. Taken from the <a href="https://arxiv.org/abs/2103.13413" target="_blank">original paper</a>. </small>
20
+
21
+ ### Resources
22
+
23
+ - [DINOv2 Paper](https://arxiv.org/abs/2304.07193)
24
+ - [DPT Paper](https://arxiv.org/abs/2103.13413)
25
+
26
+
27
+ ### Use with Transformers
28
+
29
+ ```python3
30
+ from transformers import AutoImageProcessor, DPTForDepthEstimation
31
+ import torch
32
+ import numpy as np
33
+ from PIL import Image
34
+ import requests
35
+
36
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
37
+ image = Image.open(requests.get(url, stream=True).raw)
38
+
39
+ image_processor = AutoImageProcessor.from_pretrained("facebook/dpt-dinov2-large-kitti")
40
+ model = DPTForDepthEstimation.from_pretrained("facebook/dpt-dinov2-large-kitti")
41
+
42
+ # prepare image for the model
43
+ inputs = image_processor(images=image, return_tensors="pt")
44
+
45
+ with torch.no_grad():
46
+ outputs = model(**inputs)
47
+ predicted_depth = outputs.predicted_depth
48
+
49
+ # interpolate to original size
50
+ prediction = torch.nn.functional.interpolate(
51
+ predicted_depth.unsqueeze(1),
52
+ size=image.size[::-1],
53
+ mode="bicubic",
54
+ align_corners=False,
55
+ )
56
+
57
+ # visualize the prediction
58
+ output = prediction.squeeze().cpu().numpy()
59
+ formatted = (output * 255 / np.max(output)).astype("uint8")
60
+ depth = Image.fromarray(formatted)
61
+ ```
62
+
63
+ ## Model Use
64
+
65
+ ### Intended Use
66
+
67
+ The model is intended to showcase that using the DPT framework with DINOv2 as backbone yields a powerful depth estimator.
68
+
69
+ ### BibTeX entry and citation info
70
+
71
+ ```bibtex
72
+ @misc{oquab2023dinov2,
73
+ title={DINOv2: Learning Robust Visual Features without Supervision},
74
+ 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},
75
+ year={2023},
76
+ eprint={2304.07193},
77
+ archivePrefix={arXiv},
78
+ primaryClass={cs.CV}
79
+ }
80
+ ```