Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- vision
|
5 |
+
- image-segmentation
|
6 |
+
datasets:
|
7 |
+
- scene_parse_150
|
8 |
+
widget:
|
9 |
+
- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg
|
10 |
+
example_title: Tiger
|
11 |
+
- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg
|
12 |
+
example_title: Teapot
|
13 |
+
- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpg
|
14 |
+
example_title: Palace
|
15 |
+
---
|
16 |
+
|
17 |
+
# GLPN fine-tuned on KITTI
|
18 |
+
|
19 |
+
Global-Local Path Networks (GLPN) model trained on KITTI for monocular depth estimation. It was introduced in the paper [Global-Local Path Networks for Monocular Depth Estimation with Vertical CutDepth](https://arxiv.org/abs/2201.07436) by Kim et al. and first released in [this repository](https://github.com/vinvino02/GLPDepth).
|
20 |
+
|
21 |
+
Disclaimer: The team releasing GLPN did not write a model card for this model so this model card has been written by the Hugging Face team.
|
22 |
+
|
23 |
+
## Model description
|
24 |
+
|
25 |
+
GLPN uses SegFormer as backbone and adds a lightweight head on top for depth estimation.
|
26 |
+
|
27 |
+
![model image](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/glpn_architecture.jpg)
|
28 |
+
|
29 |
+
## Intended uses & limitations
|
30 |
+
|
31 |
+
You can use the raw model for monocular depth estimation. See the [model hub](https://huggingface.co/models?search=glpn) to look for
|
32 |
+
fine-tuned versions on a task that interests you.
|
33 |
+
|
34 |
+
### How to use
|
35 |
+
|
36 |
+
Here is how to use this model:
|
37 |
+
|
38 |
+
```python
|
39 |
+
from transformers import GLPNFeatureExtractor, GLPNForDepthEstimation
|
40 |
+
import torch
|
41 |
+
import numpy as np
|
42 |
+
from PIL import Image
|
43 |
+
import requests
|
44 |
+
|
45 |
+
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
46 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
47 |
+
|
48 |
+
feature_extractor = GLPNFeatureExtractor.from_pretrained("vinvino02/glpn-kitti")
|
49 |
+
model = GLPNForDepthEstimation.from_pretrained("vinvino02/glpn-kitti")
|
50 |
+
|
51 |
+
# prepare image for the model
|
52 |
+
inputs = feature_extractor(images=image, return_tensors="pt")
|
53 |
+
|
54 |
+
with torch.no_grad():
|
55 |
+
outputs = model(**inputs)
|
56 |
+
predicted_depth = outputs.predicted_depth
|
57 |
+
|
58 |
+
# interpolate to original size
|
59 |
+
prediction = torch.nn.functional.interpolate(
|
60 |
+
predicted_depth.unsqueeze(1),
|
61 |
+
size=image.size[::-1],
|
62 |
+
mode="bicubic",
|
63 |
+
align_corners=False,
|
64 |
+
)
|
65 |
+
|
66 |
+
# visualize the prediction
|
67 |
+
output = prediction.squeeze().cpu().numpy()
|
68 |
+
formatted = (output * 255 / np.max(output)).astype("uint8")
|
69 |
+
depth = Image.fromarray(formatted)
|
70 |
+
```
|
71 |
+
|
72 |
+
For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/glpn).
|
73 |
+
|
74 |
+
### BibTeX entry and citation info
|
75 |
+
|
76 |
+
```bibtex
|
77 |
+
@article{DBLP:journals/corr/abs-2201-07436,
|
78 |
+
author = {Doyeon Kim and
|
79 |
+
Woonghyun Ga and
|
80 |
+
Pyunghwan Ahn and
|
81 |
+
Donggyu Joo and
|
82 |
+
Sehwan Chun and
|
83 |
+
Junmo Kim},
|
84 |
+
title = {Global-Local Path Networks for Monocular Depth Estimation with Vertical
|
85 |
+
CutDepth},
|
86 |
+
journal = {CoRR},
|
87 |
+
volume = {abs/2201.07436},
|
88 |
+
year = {2022},
|
89 |
+
url = {https://arxiv.org/abs/2201.07436},
|
90 |
+
eprinttype = {arXiv},
|
91 |
+
eprint = {2201.07436},
|
92 |
+
timestamp = {Fri, 21 Jan 2022 13:57:15 +0100},
|
93 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-2201-07436.bib},
|
94 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
95 |
+
}```
|