ADDS-DepthNet模型

February 28, 2022 · View on GitHub

English | 简体中文

ADDS-DepthNet模型

内容

在开始使用之前,您需要按照以下命令安装额外的依赖包:

python -m pip install scikit-image
python -m pip install matplotlib

模型简介

本模型以百度机器人与自动驾驶实验室的ICCV 2021论文 Self-supervised Monocular Depth Estimation for All Day Images using Domain Separation 为参考, 复现了基于白天和夜晚图像的自监督单目深度估计模型,其利用了白天和夜晚的图像数据互补性质,减缓了昼夜图像较大的域偏移以及照明变化对深度估计的精度带来的影响,在具有挑战性的牛津RobotCar数据集上实现了全天图像的最先进的深度估计结果。

数据准备

Oxford RobotCar dataset数据下载及准备请参考Oxford RobotCar dataset数据准备

模型训练

Oxford RobotCar dataset数据集训练

下载并添加预训练模型

  1. 下载图像预训练模型resnet18.pdparams作为Backbone初始化参数,或通过wget命令下载

    wget -P ./data https://videotag.bj.bcebos.com/PaddleVideo-release2.2/Resnet18_Imagenet.pdparams
    
  2. 打开PaddleVideo/configs/estimation/adds/adds.yaml,将下载好的权重存放路径填写到下方pretrained:之后

    MODEL: #MODEL field
        framework: "DepthEstimator" #Mandatory, indicate the type of network, associate to the 'paddlevideo/modeling/framework/' .
        backbone: #Mandatory, indicate the type of backbone, associate to the 'paddlevideo/modeling/backbones/' .
            name: 'ADDS_DepthNet'
            pretrained: 将路径填写到此处
    

开始训练

  • Oxford RobotCar dataset数据集使用单卡训练,训练方式的启动命令如下:

    python3.7 main.py --validate -c configs/estimation/adds/adds.yaml --seed 20
    

模型测试

  • ADDS-DepthNet模型在训练时同步进行验证(只对白天或者夜晚的数据进行验证),您可以通过在训练日志中查找关键字best获取模型测试精度,日志示例如下:

    Already save the best model (rmse)8.5531
    
  • 由于模型暂时一次只能测试yaml文件中给定路径的一个白天或者夜晚的数据集,因此若要得到本文档开头处的完整测试分数,需要运行4次测试命令并分别记录下它们的指标(白天40m、白天60m、夜晚40m、夜晚60m)

  • 训练好的模型下载地址:ADDS_car.pdparams

  • 测试命令如下:

    # 夜晚40m
    python3.7 main.py --test -c configs/estimation/adds/adds.yaml -w "output/ADDS/ADDS_best.pdparams" -o DATASET.test.file_path="data/oxford/splits/oxford_day/val_night_files.txt" -o MODEL.head.max_gt_depth=40
    
    # 夜晚60m
    python3.7 main.py --test -c configs/estimation/adds/adds.yaml -w "output/ADDS/ADDS_best.pdparams" -o DATASET.test.file_path="data/oxford/splits/oxford_day/val_night_files.txt" -o MODEL.head.max_gt_depth=60
    
    # 白天40m
    python3.7 main.py --test -c configs/estimation/adds/adds.yaml -w "output/ADDS/ADDS_best.pdparams" -o DATASET.test.file_path="data/oxford/splits/oxford_day/val_day_files.txt" -o MODEL.head.max_gt_depth=40
    
    # 白天60m
    python3.7 main.py --test -c configs/estimation/adds/adds.yaml -w "output/ADDS/ADDS_best.pdparams" -o DATASET.test.file_path="data/oxford/splits/oxford_day/val_day_files.txt" -o MODEL.head.max_gt_depth=60
    

    在Oxford RobotCar dataset的validation数据集上的测试指标如下:

    versionMax DepthAbs RelSq RelRMSERMSE log
    ours(night)400.2091.7416.0310.2430.7080.9230.975
    ours(night)600.2072.0527.8880.2580.6860.9090.970
    ours(day)400.1140.5743.4110.1570.8600.9770.993
    ours(day)600.1190.7934.8420.1730.8380.9670.991

模型推理

导出inference模型

python3.7 tools/export_model.py -c configs/estimation/adds/adds.yaml -p data/ADDS_car.pdparams -o inference/ADDS

上述命令将生成预测所需的模型结构文件ADDS.pdmodel和模型权重文件ADDS.pdiparams以及ADDS.pdiparams.info文件,均存放在inference/ADDS/目录下

上述bash命令中各个参数含义可参考模型推理方法

使用预测引擎推理

python3.7 tools/predict.py --input_file data/example.png \
                           --config configs/estimation/adds/adds.yaml \
                           --model_file inference/ADDS/ADDS.pdmodel \
                           --params_file inference/ADDS/ADDS.pdiparams \
                           --use_gpu=True \
                           --use_tensorrt=False

推理结束会默认以伪彩的方式保存下模型估计出的深度图。

以下是样例图片和对应的预测深度图:

image depth

参考论文