bconsolvo commited on
Commit
b8ef583
1 Parent(s): 1c047d6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +43 -40
README.md CHANGED
@@ -44,7 +44,7 @@ The model card has been written in combination by the Hugging Face team and Inte
44
  | Version | 1 |
45
  | Type | Computer Vision - Monocular Depth Estimation |
46
  | Paper or Other Resources | [Vision Transformers for Dense Prediction](https://arxiv.org/abs/2103.13413) and [GitHub Repo](https://github.com/isl-org/DPT) |
47
- | License | [MIT](https://github.com/isl-org/DPT/blob/main/LICENSE) |
48
  | Questions or Comments | [Community Tab](https://huggingface.co/Intel/dpt-large/discussions) and [Intel Developers Discord](https://discord.gg/rv2Gp55UJQ)|
49
 
50
  | Intended Use | Description |
@@ -53,6 +53,48 @@ The model card has been written in combination by the Hugging Face team and Inte
53
  | Primary intended users | Anyone doing monocular depth estimation |
54
  | Out-of-scope uses | This model in most cases will need to be fine-tuned for your particular task. |
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  | Factors | Description |
57
  | ----------- | ----------- |
58
  | Groups | Multiple datasets compiled together |
@@ -102,45 +144,6 @@ protocol defined in [30]. Relative performance is computed with respect to the o
102
  | There are no additional caveats or recommendations for this model. |
103
 
104
 
105
- ### How to use
106
-
107
- Here is how to use this model for zero-shot depth estimation on an image:
108
-
109
- ```python
110
- from transformers import DPTFeatureExtractor, DPTForDepthEstimation
111
- import torch
112
- import numpy as np
113
- from PIL import Image
114
- import requests
115
-
116
- url = "http://images.cocodataset.org/val2017/000000039769.jpg"
117
- image = Image.open(requests.get(url, stream=True).raw)
118
-
119
- feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large")
120
- model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
121
-
122
- # prepare image for the model
123
- inputs = feature_extractor(images=image, return_tensors="pt")
124
-
125
- with torch.no_grad():
126
- outputs = model(**inputs)
127
- predicted_depth = outputs.predicted_depth
128
-
129
- # interpolate to original size
130
- prediction = torch.nn.functional.interpolate(
131
- predicted_depth.unsqueeze(1),
132
- size=image.size[::-1],
133
- mode="bicubic",
134
- align_corners=False,
135
- )
136
-
137
- # visualize the prediction
138
- output = prediction.squeeze().cpu().numpy()
139
- formatted = (output * 255 / np.max(output)).astype("uint8")
140
- depth = Image.fromarray(formatted)
141
- ```
142
-
143
- For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/dpt).
144
 
145
  ### BibTeX entry and citation info
146
 
 
44
  | Version | 1 |
45
  | Type | Computer Vision - Monocular Depth Estimation |
46
  | Paper or Other Resources | [Vision Transformers for Dense Prediction](https://arxiv.org/abs/2103.13413) and [GitHub Repo](https://github.com/isl-org/DPT) |
47
+ | License | Apache 2.0 |
48
  | Questions or Comments | [Community Tab](https://huggingface.co/Intel/dpt-large/discussions) and [Intel Developers Discord](https://discord.gg/rv2Gp55UJQ)|
49
 
50
  | Intended Use | Description |
 
53
  | Primary intended users | Anyone doing monocular depth estimation |
54
  | Out-of-scope uses | This model in most cases will need to be fine-tuned for your particular task. |
55
 
56
+
57
+ ### How to use
58
+
59
+ Here is how to use this model for zero-shot depth estimation on an image:
60
+
61
+ ```python
62
+ from transformers import DPTFeatureExtractor, DPTForDepthEstimation
63
+ import torch
64
+ import numpy as np
65
+ from PIL import Image
66
+ import requests
67
+
68
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
69
+ image = Image.open(requests.get(url, stream=True).raw)
70
+
71
+ feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large")
72
+ model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
73
+
74
+ # prepare image for the model
75
+ inputs = feature_extractor(images=image, return_tensors="pt")
76
+
77
+ with torch.no_grad():
78
+ outputs = model(**inputs)
79
+ predicted_depth = outputs.predicted_depth
80
+
81
+ # interpolate to original size
82
+ prediction = torch.nn.functional.interpolate(
83
+ predicted_depth.unsqueeze(1),
84
+ size=image.size[::-1],
85
+ mode="bicubic",
86
+ align_corners=False,
87
+ )
88
+
89
+ # visualize the prediction
90
+ output = prediction.squeeze().cpu().numpy()
91
+ formatted = (output * 255 / np.max(output)).astype("uint8")
92
+ depth = Image.fromarray(formatted)
93
+ ```
94
+
95
+ For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/dpt).
96
+
97
+
98
  | Factors | Description |
99
  | ----------- | ----------- |
100
  | Groups | Multiple datasets compiled together |
 
144
  | There are no additional caveats or recommendations for this model. |
145
 
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  ### BibTeX entry and citation info
149