• MVSNet服务器环境配置及测试


    一. 环境配置

    1. 安装Anaconda

    最新版即可,详见:配置深度学习环境(Linux服务器)

    2. 创建conda环境

    conda create -n MVSNet python=3.7

    激活环境

    conda activate MVSNet

    3. 在conda中安装Pytorch

    根据CUDA版本在pytorch官网中找到对应的下载(我的CUDA是11.4)

    conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
    

    Pytorch版本一定要和cuda对应,不要直接粘贴上文,否则有问题!

    4. 安装各种包

    安装OpenCV

    1. pip install opencv_python==3.4.2.17
    2. pip install opencv-contrib-python==3.4.2.17

    安装tensorboard

    1. pip install protobuf==3.19.1
    2. pip install tensorboardX==1.8
    3. pip install tensorboard==1.14.0

    如果还缺什么,就装什么。

    至此,环境就配好了!

    二. 测试

    1. 测试代码(自己写的)

    随机生成图像和内外参,可以快速测试代码并学习网络。

    python temp.py --numdepth=192
    1. import argparse
    2. import torch
    3. import torch.backends.cudnn as cudnn
    4. from models import *
    5. from utils import *
    6. cudnn.benchmark = True
    7. parser = argparse.ArgumentParser(description='A PyTorch Implementation of MVSNet')
    8. parser.add_argument('--model', default='mvsnet', help='select model')
    9. parser.add_argument('--lr', type=float, default=0.001, help='learning rate')
    10. # 训练中采用了动态调整学习率的策略,在第10,12,14轮训练的时候,让learning_rate除以2变为更小的学习率
    11. parser.add_argument('--lrepochs', type=str, default="10,12,14:2", help='epoch ids to downscale lr and the downscale rate')
    12. # weight decay策略,作为Adam优化器超参数,实现中并未使用
    13. parser.add_argument('--wd', type=float, default=0.0, help='weight decay')
    14. #parser.add_argument('--batch_size', type=int, default=12, help='train batch size')
    15. # 深度假设数量,一共假设这么多种不同的深度,在里面找某个像素的最优深度
    16. parser.add_argument('--numdepth', type=int, default=192, help='the number of depth values')
    17. # 深度假设间隔缩放因子,每隔interval假设一个新的深度,这个interval要乘以这个scale
    18. parser.add_argument('--interval_scale', type=float, default=1.06, help='the number of depth values')
    19. model = MVSNet(refine=False).cuda()
    20. with torch.no_grad():
    21. imgs = torch.rand((4, 3, 3, 512, 640)).cuda()
    22. proj_matrices = torch.rand((4, 3, 4, 4)).cuda()
    23. depth_values = torch.rand((4, 192)).cuda()
    24. model(imgs, proj_matrices, depth_values)

    2. train.sh(改路径即可)

    1. #!/usr/bin/env bash
    2. MVS_TRAINING="/data/dtu/mvs_training/dtu/"
    3. CUDA_VISIBLE_DEVICES=1 python train.py --dataset=dtu_yao --batch_size=2 --trainpath=$MVS_TRAINING --trainlist lists/dtu/train.txt --testlist lists/dtu/test.txt --numdepth=192 --logdir ./checkpoints/d192 $@

    3. eval.sh(改路径即可)

    1. #!/usr/bin/env bash
    2. DTU_TESTING="/data/dtu_test/"
    3. CKPT_FILE="./checkpoints/d192/model_000004.ckpt"
    4. CUDA_VISIBLE_DEVICES=1 python eval.py --dataset=dtu_yao_eval --batch_size=1 --testpath=$DTU_TESTING --testlist lists/dtu/test.txt --loadckpt $CKPT_FILE $@

     记得把eval.py中的save_depth()之前的#去掉,要不然跑不通!

    一点心得1:网上有很多博主写了配环境的帖子,参考之后我并没有配置成功,猜测可能是因为服务器等客观因素吧。只能说,每个博主至少在自己机子上是可以运行的,包括我这篇,但不代表你就能成功!建议大家直接先在自己配好的环境里跑一下试试(有项目可以直接成功运行的环境),没准大力就出奇迹了!!!

    一点心得2:阅读原码的时候,千万别手抖,删了什么或者加了空格,一旦原码报错,还找不到问题,简直怀疑人生!!!

  • 相关阅读:
    C++ 小游戏 视频及资料集(5)
    如何让论文成为一篇可发表的期刊文章?
    01_CCC3.0数字钥匙_蓝牙OOB配对过程
    java版opencv之Javacv各种场景使用案例
    即插即用篇 | YOLOv8 引入具备跨空间学习的高效多尺度注意力 Efficient Multi-Scale Attention | 《ICASSP 2023 最新论文》
    leetcode做题笔记146. LRU 缓存
    Jumpserver安全一窥:Sep系列漏洞深度解析
    【TypeScript】深入学习TypeScript模块
    自动控制原理8.2---常见非线性特性及其对系统运动的影响
    TypeScript应用
  • 原文地址:https://blog.csdn.net/qq_43307074/article/details/128011842