nielsr HF staff commited on
Commit
372221f
1 Parent(s): e93beec

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +90 -0
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## ---
2
+ license: apache-2.0
3
+ tags:
4
+ - vision
5
+ - depth-estimation
6
+ widget:
7
+ - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg
8
+ example_title: Tiger
9
+ - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg
10
+ example_title: Teapot
11
+ - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpg
12
+ example_title: Palace
13
+ ---
14
+
15
+ # DPT (large-sized model)
16
+
17
+ Dense Prediction Transformer (DPT) model trained on 1.4 million images for monocular depth estimation. It was introduced in the paper [Vision Transformers for Dense Prediction](https://arxiv.org/abs/2103.13413) by Ranftl et al. and first released in [this repository](https://github.com/isl-org/DPT).
18
+
19
+ Disclaimer: The team releasing DPT did not write a model card for this model so this model card has been written by the Hugging Face team.
20
+
21
+ ## Model description
22
+
23
+ DPT uses the Vision Transformer (ViT) as backbone and adds a neck + head on top for monocular depth estimation.
24
+
25
+ ![model image](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/dpt_architecture.png)
26
+
27
+ ## Intended uses & limitations
28
+
29
+ You can use the raw model for zero-shot monocular depth estimation. See the [model hub](https://huggingface.co/models?search=dpt) to look for
30
+ fine-tuned versions on a task that interests you.
31
+
32
+ ### How to use
33
+
34
+ Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
35
+
36
+ ```python
37
+ from transformers import DPTFeatureExtractor, DPTForDepthEstimation
38
+ import torch
39
+ import numpy as np
40
+ from PIL import Image
41
+ import requests
42
+
43
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
44
+ image = Image.open(requests.get(url, stream=True).raw)
45
+
46
+ feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large")
47
+ model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
48
+
49
+ # prepare image for the model
50
+ inputs = feature_extractor(images=image, return_tensors="pt")
51
+
52
+ with torch.no_grad():
53
+ outputs = model(**inputs)
54
+ predicted_depth = outputs.predicted_depth
55
+
56
+ # interpolate to original size
57
+ prediction = torch.nn.functional.interpolate(
58
+ predicted_depth.unsqueeze(1),
59
+ size=image.size[::-1],
60
+ mode="bicubic",
61
+ align_corners=False,
62
+ )
63
+
64
+ # visualize the prediction
65
+ output = prediction.squeeze().cpu().numpy()
66
+ formatted = (output * 255 / np.max(output)).astype("uint8")
67
+ depth = Image.fromarray(formatted)
68
+ ```
69
+
70
+ For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/dpt).
71
+
72
+ ### BibTeX entry and citation info
73
+
74
+ ```bibtex
75
+ @article{DBLP:journals/corr/abs-2103-13413,
76
+ author = {Ren{\'{e}} Ranftl and
77
+ Alexey Bochkovskiy and
78
+ Vladlen Koltun},
79
+ title = {Vision Transformers for Dense Prediction},
80
+ journal = {CoRR},
81
+ volume = {abs/2103.13413},
82
+ year = {2021},
83
+ url = {https://arxiv.org/abs/2103.13413},
84
+ eprinttype = {arXiv},
85
+ eprint = {2103.13413},
86
+ timestamp = {Wed, 07 Apr 2021 15:31:46 +0200},
87
+ biburl = {https://dblp.org/rec/journals/corr/abs-2103-13413.bib},
88
+ bibsource = {dblp computer science bibliography, https://dblp.org}
89
+ }
90
+ ```