当前位置: 首页 > news >正文

深度估计 双目深度估计+单目深度估计 ONNX运行程序

双目深度估计ONNX Practical Stereo Matching via Cascaded Recurrent Network with Adaptive Correlation https://github.com/ibaiGorordo/ONNX-CREStereo-Depth-Estimation

  • 双目深度估计需要从dataset读取左右两个view的图片。
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  • 使用模型进行深度图的估计

model_path = f'models/crestereo_{version}_iter{iters}_{shape[0]}x{shape[1]}.onnx'
depth_estimator = CREStereo(model_path)
disparity_map = depth_estimator(left_img, right_img)
CREStereo model: https://github.com/megvii-research/CREStereo
CREStereo - Pytorch: https://github.com/ibaiGorordo/CREStereo-Pytorch
PINTO0309's model zoo: https://github.com/PINTO0309/PINTO_model_zoo
PINTO0309's model conversion tool: https://github.com/PINTO0309/openvino2tensorflow
Driving Stereo dataset: https://drivingstereo-dataset.github.io/
Depthai library: https://pypi.org/project/depthai/
Original paper: https://arxiv.org/abs/2203.11483

单目深度估计monocular

GLPDepth

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

  • 下载github代码(稍微修改一下,用本地读取替换在线读取)
    在这里插入图片描述

  • 去PINTO0309’s model zoo: https://github.com/PINTO0309/PINTO_model_zoo下载模型

  • 运行bash
    在这里插入图片描述
    在这里插入图片描述

monodepth2 https://github.com/nianticlabs/monodepth2

python test_simple.py --image_path assets/test_image.jpg --model_name mono+stereo_640x192

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

    with torch.no_grad():
        for idx, image_path in enumerate(paths):

            if image_path.endswith("_disp.jpg"):
                print('don t try to predict disparity for a disparity image!')
                continue

            # Load image and preprocess
            input_image = pil.open(image_path).convert('RGB')
            original_width, original_height = input_image.size
            input_image = input_image.resize((feed_width, feed_height), pil.LANCZOS)
            input_image = transforms.ToTensor()(input_image).unsqueeze(0)

            # PREDICTION
            input_image = input_image.to(device)
            features = encoder(input_image)
            outputs = depth_decoder(features)

            disp = outputs[("disp", 0)]
            # 还原大小  torch.Size([1, 1, 235, 638])
            disp_resized = torch.nn.functional.interpolate(
                disp, (original_height, original_width), mode="bilinear", align_corners=False)

            # Saving numpy file
            output_name = os.path.splitext(os.path.basename(image_path))[0]
            scaled_disp, depth = disp_to_depth(disp, 0.1, 100)
            if args.pred_metric_depth:
                name_dest_npy = os.path.join(output_directory, "{}_depth.npy".format(output_name))
                metric_depth = STEREO_SCALE_FACTOR * depth.cpu().numpy()
                np.save(name_dest_npy, metric_depth)
            else:
                name_dest_npy = os.path.join(output_directory, "{}_disp.npy".format(output_name))
                np.save(name_dest_npy, scaled_disp.cpu().numpy())

            # Saving colormapped depth image
            disp_resized_np = disp_resized.squeeze().cpu().numpy()
            vmax = np.percentile(disp_resized_np, 95)
            normalizer = mpl.colors.Normalize(vmin=disp_resized_np.min(), vmax=vmax)
            mapper = cm.ScalarMappable(norm=normalizer, cmap='magma')
            colormapped_im = (mapper.to_rgba(disp_resized_np)[:, :, :3] * 255).astype(np.uint8)
            im = pil.fromarray(colormapped_im)

            name_dest_im = os.path.join(output_directory, "{}_disp.jpeg".format(output_name))
            im.save(name_dest_im)

            print("   Processed {:d} of {:d} images - saved predictions to:".format(
                idx + 1, len(paths)))
            print("   - {}".format(name_dest_im))
            print("   - {}".format(name_dest_npy))

    print('-> Done!')

有时没有网络的情况下运行报错urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

# download_model_if_doesnt_exist(args.model_name)

参考与更多

单目深度估计总结
深入研究自监督单目深度估计:Monodepth2
consistent-video-deprh-estimation:github上的一个有趣的应用
效果惊艳!ONNX-CREStereo深度估计!

monodepth https://github.com/mrharicot/monodepth

https://github.com/nianticlabs/monodepth2
Digging Into Self-Supervised Monocular Depth Estimation
https://arxiv.org/abs/1806.01260

  • https://www.bilibili.com/video/BV1HZ4y1c7nC
    在这里插入图片描述
    在这里插入图片描述

相关文章:

  • Express 路由
  • 2022蓝帽杯初赛电子取证
  • 数据结构与算法复习:第三十六弹
  • CSS - 响应式布局(一)媒体查询
  • 【JAVA预备】课程目录
  • 2022年0902Maven的依赖学习<第四课>
  • Android 11 上的文件读写权限(MANAGE_EXTERNAL_STORAGE)
  • Vue模板语法(01)
  • 世界第一台通用计算机:ENIAC
  • JAVA学习----HashSet类
  • 文章组合生成-免费文章组合生成软件
  • 华为面试应该怎么准备?
  • JDBC如何记忆
  • C语言之预处理
  • Flutter 系列---入门篇
  • Bytom交易说明(账户管理模式)
  • ES6之路之模块详解
  • JS创建对象模式及其对象原型链探究(一):Object模式
  • MD5加密原理解析及OC版原理实现
  • Otto开发初探——微服务依赖管理新利器
  • SpringBoot 实战 (三) | 配置文件详解
  • 基于OpenResty的Lua Web框架lor0.0.2预览版发布
  • 记录:CentOS7.2配置LNMP环境记录
  • 技术攻略】php设计模式(一):简介及创建型模式
  • 如何将自己的网站分享到QQ空间,微信,微博等等
  • 如何优雅的使用vue+Dcloud(Hbuild)开发混合app
  • 思考 CSS 架构
  • 再次简单明了总结flex布局,一看就懂...
  • ​2020 年大前端技术趋势解读
  • ​MySQL主从复制一致性检测
  • #1015 : KMP算法
  • $emit传递多个参数_PPC和MIPS指令集下二进制代码中函数参数个数的识别方法
  • ( )的作用是将计算机中的信息传送给用户,计算机应用基础 吉大15春学期《计算机应用基础》在线作业二及答案...
  • (10)STL算法之搜索(二) 二分查找
  • (ibm)Java 语言的 XPath API
  • (附源码)springboot 基于HTML5的个人网页的网站设计与实现 毕业设计 031623
  • (附源码)ssm码农论坛 毕业设计 231126
  • (蓝桥杯每日一题)love
  • (算法设计与分析)第一章算法概述-习题
  • (译) 理解 Elixir 中的宏 Macro, 第四部分:深入化
  • (原創) 物件導向與老子思想 (OO)
  • (转)Java socket中关闭IO流后,发生什么事?(以关闭输出流为例) .
  • .bat批处理出现中文乱码的情况
  • .NET 5种线程安全集合
  • .net core 6 集成和使用 mongodb
  • .NET Core 控制台程序读 appsettings.json 、注依赖、配日志、设 IOptions
  • @angular/cli项目构建--http(2)
  • @开发者,一文搞懂什么是 C# 计时器!
  • [.NET]桃源网络硬盘 v7.4
  • [2019.2.28]BZOJ4033 [HAOI2015]树上染色
  • [Android Studio 权威教程]断点调试和高级调试
  • [android] 天气app布局练习
  • [AX]AX2012开发新特性-禁止表或者表字段
  • [C#C++]类CLASS
  • [c]扫雷