import numpy as np
import os
import random
from six.moves import cPickle as pickle
from tensorflow.python.platform import gfile
import glob
import TensorflowUtils as utils
DATA_URL = 'http:\\data.csail.mit.edu\\places\\ADEchallenge\\ADEChallengeData2016.zip'
#download and read dataset
def read_dataset(data_dir):
pickle_filename = "MITSceneParsing.pickle"
pickle_filepath = os.path.join(data_dir, pickle_filename)
if not os.path.exists(pickle_filepath):
utils.maybe_download_and_extract(data_dir, DATA_URL, is_zipfile=True)
SceneParsing_folder = os.path.splitext(DATA_URL.split("/")[-1])[0]
result = create_image_lists(os.path.join(data_dir, SceneParsing_folder))
print ("Pickling ...")
with open(pickle_filepath, 'wb') as f:
pickle.dump(result, f, pickle.HIGHEST_PROTOCOL)
else:
print ("Found pickle file!")
with open(pickle_filepath, 'rb') as f:
result = pickle.load(f)
training_records = result['training']
validation_records = result['validation']
del result
return training_records, validation_records
train_records, valid_records = read_dataset('Data_zoo/MIT_SceneParsing')
print(len(train_records))
print(len(valid_records))
结果是:找到了腌菜文件! 0 0 为什么关于train_records和valid_records的镜头是0? 我不知道什么是错的以及如何纠正它。
答案 0 :(得分:0)
这段代码是对的。该错误位于“create_image_lists
”中。
请注意create_image_lists中的此代码:
filename = os.path.splitext(f.split('/')[-1])[0]
这在Linux中没有问题,但在Windows中,分隔符是“\\
”,因此您应该将此代码修改为:
filename = os.path.splitext(f.split('\\')[-1])[0]
然后删除此文件'MITSceneParsing.pickle',再次运行read_dataset。