我正在尝试用谷歌Colab存储在我的谷歌硬盘上的数据来训练一个UNet神经网络。
我创建了一个核心库,一个数据集等等。但它访问数据的速度很慢。
为了防止这种情况,我用h5py库构建了一个".hdf5“文件。
XDataPath="/content/drive/My Drive/Dataset/data/X"
YDataPath="/content/drive/My Drive/Dataset/data/Y"
h5Path="/content/drive/My Drive/Dataset/data/dataset.hdf5"
nbX=len(os.listdir(XDataPath))
nbY=len(os.listdir(YDataPath))
# CleanData
dst=[os.path.splitext(f)[0] for f in os.listdir(YDataPath)]
src=[os.path.splitext(f)[0] for f in os.listdir(XDataPath)]
for f in src:
if f not in dst:
fpth=os.path.join(XDataPath,f+'.jpg')
os.remove(fpth)
print(fpth)
for f in dst:
if f not in src:
fpth=os.path.join(YDataPath,f+'.png')
os.remove(fpth)
print(fpth)
with h5py.File(h5Path,'a') as hfile:
if not "X" in hfile:
hfile.create_dataset("X",(nbX,512,512,3))
if not "Y" in hfile:
hfile.create_dataset("Y",(nbY,512,512))
for i,Path in tqdm.tqdm_notebook(enumerate(os.listdir(XDataPath)),total=nbX):
ImPath=os.path.join(XDataPath,Path)
with h5py.File(h5Path,'a') as hfile:
with Image.open(ImPath) as f:
X=np.array(f)
hfile["X"][i]=X文件创建正确:

令我惊讶的是,我在google驱动器上看不到这个文件(只有一个同名的0ko文件)。更重要的是,我没有足够的存储空间来存储它

为什么没有在驱动器上创建此文件?它存储在哪里?
另一个问题是,当我重新启动环境时,hdf5文件现在是0ko,就像在我的google驱动器上一样。当然也是空的!
谢谢,
发布于 2019-12-16 03:05:10
文件创建并存储在Google Cloud(Colab实例)中。该文件太大,因此无法将其同步回Google Drive。
因此,我建议您使用GCS存储桶来存储它,而不是GDrive。
https://stackoverflow.com/questions/59344760
复制相似问题