Python处理mat数据集

MATLAB存储mat文件,数据大小超过2GB,采用-v7.3存储; 不超过的话采用一般格式

在Python中读取MATLAB的.mat文件一般使用scipy,但是scipy不支持-v7.3版本的.mat文件(-v7.3版本能支持较大的文件);因此使用h5py进行读取。

python读取mat文件

-v7格式

scipy.io库

import scipy.io as sio 
matfn = '/home/weiliu/workspace/python/matlab/mat4py.mat'
data = sio.loadmat(matfn)

-v7.3格式

h5py库

import h5py
nyu = h5py.File('../FCRN/nyu_depth_v2_labeled.mat')
imgs = nyu['images']
dpts = nyu['depths']
sems = nyu['labels']
print(nyu.keys())

如果有其他程序在用这个数据集(即mat文件)的时候,有可能会报错

Guess you like

Origin blog.csdn.net/hxxjxw/article/details/120871133