许可协议:apache-2.0
标签:
演示示例:
- 图片链接:https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg
示例标题:老虎
- 图片链接:https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg
示例标题:茶壶
- 图片链接:https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpg
示例标题:宫殿
基于NYUv2微调的GLPN模型
全局-局部路径网络(GLPN)模型在NYUv2数据集上训练,用于单目深度估计。该模型由Kim等人在论文《用于单目深度估计的全局-局部路径网络与垂直CutDepth》中提出,并首次发布于此代码库。
免责声明:发布GLPN的团队未为此模型编写模型卡,因此本模型卡由Hugging Face团队撰写。
模型描述
GLPN使用SegFormer作为主干网络,并在顶部添加了一个轻量级头部用于深度估计。

预期用途与限制
您可以将原始模型用于单目深度估计。请访问模型中心查找针对您感兴趣任务微调的版本。
使用方法
以下是使用该模型的方法:
from transformers import GLPNImageProcessor, GLPNForDepthEstimation
import torch
import numpy as np
from PIL import Image
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
processor = GLPNImageProcessor.from_pretrained("vinvino02/glpn-nyu")
model = GLPNForDepthEstimation.from_pretrained("vinvino02/glpn-nyu")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predicted_depth = outputs.predicted_depth
prediction = torch.nn.functional.interpolate(
predicted_depth.unsqueeze(1),
size=image.size[::-1],
mode="bicubic",
align_corners=False,
)
output = prediction.squeeze().cpu().numpy()
formatted = (output * 255 / np.max(output)).astype("uint8")
depth = Image.fromarray(formatted)
更多代码示例,请参阅文档。
BibTeX条目及引用信息
@article{DBLP:journals/corr/abs-2201-07436,
author = {Doyeon Kim and
Woonghyun Ga and
Pyunghwan Ahn and
Donggyu Joo and
Sehwan Chun and
Junmo Kim},
title = {Global-Local Path Networks for Monocular Depth Estimation with Vertical
CutDepth},
journal = {CoRR},
volume = {abs/2201.07436},
year = {2022},
url = {https://arxiv.org/abs/2201.07436},
eprinttype = {arXiv},
eprint = {2201.07436},
timestamp = {Fri, 21 Jan 2022 13:57:15 +0100},
biburl = {https://dblp.org/rec/journals/corr/abs-2201-07436.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}