---
title: cv_newcrfs_image-depth-estimation_indoor
canonical_url: "https://www.modelscope.cn/models/damo/cv_newcrfs_image-depth-estimation_indoor"
md_url: "https://www.modelscope.cn/models/damo/cv_newcrfs_image-depth-estimation_indoor.md"
repository: damo/cv_newcrfs_image-depth-estimation_indoor
chinese_name: "基于神经窗口全连接CRFs的单目深度估计"
last_updated: 2023-02-09
license: "Apache License 2.0"
pipeline_tag: image-depth-estimation
tasks:
  - image-depth-estimation
model_type:
  - roberta
library_name:
  - pytorch
frameworks:
  - pytorch
domain:
  - cv
downloads: 54823
stars: 23
tags:
  - Transformer
  - Alibaba
  - Monocular
  - Depth
  - "3D Vision"
  - CRFs
  - XR
---

# cv_newcrfs_image-depth-estimation_indoor

> cv_newcrfs_image-depth-estimation_indoor - damo 在 ModelScope 开源的模型。单目深度估计是从单张RGB图预测场景深度，是一个很具有挑战性的任务。现在做这个任务的方法大都是设计越来越复杂的网络来简单粗暴地回归深度图，但我们采取了一个更具可解释性的路子，就是使用优化方法中的条件随机场（CRFs）。由于CRFs的计算量很大，通常只会用于计算相邻节点的能量，而很难用于计算整个图模型中所有节点之间的能量。为了借助这种全连接CRFs的强大表征力，我们采取了一种折中的方…

damo/cv_newcrfs_image-depth-estimation_indoor 是 ModelScope 魔搭社区上的image-depth-estimation模型，采用 Apache License 2.0 许可。

- **Repository**: damo/cv_newcrfs_image-depth-estimation_indoor
- **License**: Apache License 2.0
- **Tasks**: image-depth-estimation
- **Tags**: Transformer, Alibaba, Monocular, Depth, 3D Vision, CRFs, XR
- **Downloads**: 54823
- **Stars**: 23
- **Last updated**: 2023-02-09

Source: https://www.modelscope.cn/models/damo/cv_newcrfs_image-depth-estimation_indoor

---

# 单目深度估计算法介绍

## 任务
输入一张单目RGB图像，单目深度估计算法将分析场景三维结构、输出图像对应的稠密深度图

## 模型描述

本模型基于**NeW CRFs: Neural Window Fully-connected CRFs for Monocular Depth Estimation**算法，是该算法的官方模型。

技术细节请见：

**NeW CRFs: Neural Window Fully-connected CRFs for Monocular Depth Estimation** <br />
Weihao Yuan, Xiaodong Gu, Zuozhuo Dai, Siyu Zhu, Ping Tan <br />
**CVPR 2022** <br />
**[[Project Page](https://weihaosky.github.io/newcrfs/)]** | 
**[[Paper](https://arxiv.org/abs/2203.01502)]** |
**[[中文解读](https://zhuanlan.zhihu.com/p/522214395)]**  <br />


<p float="left">
  &emsp;&emsp; <img src="description/intro.png" width="400" />
</p>

![Output1](description/output_nyu2_compressed.gif)


## 如何使用

### 代码示例

```python
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.utils.cv.image_utils import depth_to_color


task = 'image-depth-estimation'
model_id = 'damo/cv_newcrfs_image-depth-estimation_indoor'

input_location = 'data/test/images/image_depth_estimation.jpg'
estimator = pipeline(Tasks.image_depth_estimation, model=model_id)
result = estimator(input_location)
depth_vis = result[OutputKeys.DEPTHS_COLOR]
cv2.imwrite('result.jpg', depth_vis)
```

### 适用范围

默认输入图片的摄像机参数应与训练数据集（NYUv2）保持一直, 即分辨率为640x480，内参为
```
518.8579,      0.0,   320
     0.0, 518.8579,   240
     0.0,      0.0,   0.0
```
如输入图像不一致，请将输入图片矫正为上述参数，否则会影响结果准确性


## 模型精度
在NYUv2上的结果为
| Model | Abs.Rel. | Sqr.Rel | RMSE | RMSElog | a1 | a2 | a3| SILog| 
| :--- | :---: | :---: | :---: |  :---: |  :---: |  :---: |  :---: |  :---: |
|NYUv2 | 0.0952 | 0.0443 | 0.3310 | 0.1185 | 0.923 | 0.992 | 0.998 | 9.1023 |


## Demo Video

![Output1](description/output_nyu1_compressed.gif)


## Bibtex

```
@inproceedings{yuan2022newcrfs,
  title={NeWCRFs: Neural Window Fully-connected CRFs for Monocular Depth Estimation},
  author={Yuan, Weihao and Gu, Xiaodong and Dai, Zuozhuo and Zhu, Siyu and Tan, Ping},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={},
  year={2022}
}
```
