从0开始实现深度估计

目录

1.数据加载以及数据增强

2.网络模型

3.训练网络


1.数据加载以及数据增强

以室内数据NYU为例,txt文件可以在BTS的GitHub上下载,老版本的是csv文件,需用用pandas读取,过程类似

image_file = []
depth_file = []
data_file = r"F:\Datasets\nyu_depth_v2\offical_splits\train.txt"
with open(data_file, 'r') as f:
    listInTXT = [line.strip() for line in f]
print(len(listInTXT))


此时测试的数据读取是正确的,总共 image/depth/focal 一共24231条, line.strip()可以把当前str内的空格删除,这里的作用是为了划分一行一行的数据,否则直接用 f.read(data_file)得到的结果是1条集体数据中包含的字符数。


对于此时已经按照 image/depth/focal 划分好的数据路径,我们可以切片为image_file, depth_file。

import cv2
image_path = []
depth_path = []

for i in range(len(listInTXT)):
    image_file.append(listInTXT[i].split(' ')[0])
    depth_file.append(listInTXT[i].split(' ')[1])
    image_path.append("F:/Datasets/nyu_depth_v2/offical_splits/train" + image_file[i])
    depth_path.append("F:/Datasets/nyu_depth_v2/offical_splits/train" + depth_file[i])

上述路径根据绝对地址自行修改

测试图像是否正确读入

%matplotlib inline
import matplotlib.pyplot as plt
image = cv2.imread(image_path[0])
cv2.imshow("test",image)
cv2.waitKey()


也可以用PIL 读取

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Lins H

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值