nielsr HF staff commited on
Commit
a577a1e
1 Parent(s): 25624f0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +93 -0
README.md ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # GLPN fine-tuned on NYUv2
16
+
17
+ Global-Local Path Networks (GLPN) model trained on NYUv2 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).
18
+
19
+ 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.
20
+
21
+ ## Model description
22
+
23
+ GLPN uses SegFormer as backbone and adds a lightweight head on top for depth estimation.
24
+
25
+ ![model image](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/glpn_architecture.jpg)
26
+
27
+ ## Intended uses & limitations
28
+
29
+ You can use the raw model for monocular depth estimation. See the [model hub](https://huggingface.co/models?search=glpn) 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:
35
+
36
+ ```python
37
+ from transformers import GLPNFeatureExtractor, GLPNForDepthEstimation
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 = GLPNFeatureExtractor.from_pretrained("vinvino02/glpn-nyu")
47
+ model = GLPNForDepthEstimation.from_pretrained("vinvino02/glpn-nyu")
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/glpn).
71
+
72
+ ### BibTeX entry and citation info
73
+
74
+ ```bibtex
75
+ @article{DBLP:journals/corr/abs-2201-07436,
76
+ author = {Doyeon Kim and
77
+ Woonghyun Ga and
78
+ Pyunghwan Ahn and
79
+ Donggyu Joo and
80
+ Sehwan Chun and
81
+ Junmo Kim},
82
+ title = {Global-Local Path Networks for Monocular Depth Estimation with Vertical
83
+ CutDepth},
84
+ journal = {CoRR},
85
+ volume = {abs/2201.07436},
86
+ year = {2022},
87
+ url = {https://arxiv.org/abs/2201.07436},
88
+ eprinttype = {arXiv},
89
+ eprint = {2201.07436},
90
+ timestamp = {Fri, 21 Jan 2022 13:57:15 +0100},
91
+ biburl = {https://dblp.org/rec/journals/corr/abs-2201-07436.bib},
92
+ bibsource = {dblp computer science bibliography, https://dblp.org}
93
+ }```