如何从 txt 文件中创建 HDF5 文件(多标签分类)以在 Caffe 中使用
How to create HDF5 file (mutli label classification) out of txt file to use in Caffe
我在 .txt 文件中有以下结构:
/path/to/image x y
/path/to/image x y
其中 x 和 y 是整数。
我现在要做的是:创建一个hdf5文件在Caffe中使用('train.prototxt'
)
我的 Python 代码如下所示:
import h5py
import numpy as np
import os
text = 'train'
text_dir = text + '.txt'
data = np.genfromtxt(text_dir, delimiter=" ", dtype=None)
h = h5py.File(text + '.hdf5', 'w')
h.create_dataset('data', data=data[:1])
h.create_dataset('label', data=data[1:])
with open(text + "_hdf5.txt", "w") as textfile:
textfile.write(os.getcwd() + '/' +text + '.hdf5')
但这行不通!有什么想法可能是错误的吗?
它不起作用,因为你的 'data'
是 /path/to/image
而不是图像本身。
有关详细信息,请参阅 。
我在 .txt 文件中有以下结构:
/path/to/image x y /path/to/image x y
其中 x 和 y 是整数。
我现在要做的是:创建一个hdf5文件在Caffe中使用('train.prototxt'
)
我的 Python 代码如下所示:
import h5py
import numpy as np
import os
text = 'train'
text_dir = text + '.txt'
data = np.genfromtxt(text_dir, delimiter=" ", dtype=None)
h = h5py.File(text + '.hdf5', 'w')
h.create_dataset('data', data=data[:1])
h.create_dataset('label', data=data[1:])
with open(text + "_hdf5.txt", "w") as textfile:
textfile.write(os.getcwd() + '/' +text + '.hdf5')
但这行不通!有什么想法可能是错误的吗?
它不起作用,因为你的 'data'
是 /path/to/image
而不是图像本身。
有关详细信息,请参阅