Update README.md
Browse files
README.md
CHANGED
@@ -9,4 +9,45 @@ repo_url: https://github.com/lpiccinelli-eth/UniDepth
|
|
9 |
|
10 |
This model has been pushed to the Hub using **UniDepth**:
|
11 |
- Repo: https://github.com/lpiccinelli-eth/UniDepth
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
This model has been pushed to the Hub using **UniDepth**:
|
11 |
- Repo: https://github.com/lpiccinelli-eth/UniDepth
|
12 |
+
|
13 |
+
## Installation
|
14 |
+
|
15 |
+
First install the UniDepth package as follows:
|
16 |
+
|
17 |
+
```python
|
18 |
+
!git clone -b add_hf https://github.com/NielsRogge/UniDepth.git
|
19 |
+
!cd UniDepth
|
20 |
+
!pip install -r requirements.txt
|
21 |
+
```
|
22 |
+
|
23 |
+
## Usage
|
24 |
+
|
25 |
+
Next, one can load the model and perform inference as follows:
|
26 |
+
|
27 |
+
```python
|
28 |
+
from unidepth.models import UniDepthV1HF
|
29 |
+
import numpy as np
|
30 |
+
from PIL import Image
|
31 |
+
|
32 |
+
model = UniDepthV1HF.from_pretrained("nielsr/unidepth-v1-convnext-large")
|
33 |
+
|
34 |
+
# Move to CUDA, if any
|
35 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
36 |
+
model = model.to(device)
|
37 |
+
|
38 |
+
# Load the RGB image and the normalization will be taken care of by the model
|
39 |
+
rgb = torch.from_numpy(np.array(Image.open(image_path))).permute(2, 0, 1) # C, H, W
|
40 |
+
|
41 |
+
predictions = model.infer(rgb)
|
42 |
+
|
43 |
+
# Metric Depth Estimation
|
44 |
+
depth = predictions["depth"]
|
45 |
+
|
46 |
+
# Point Cloud in Camera Coordinate
|
47 |
+
xyz = predictions["points"]
|
48 |
+
|
49 |
+
# Intrinsics Prediction
|
50 |
+
intrinsics = predictions["intrinsics"]
|
51 |
+
|
52 |
+
|
53 |
+
```
|