def import_json(path='json/MPI_annotations.json', order='json/MPI_order.npy'):
"""Get the json file containing the dataset.
We want the data to be shuffled, however the training has to be repeatable.
This means that once shuffled the order has to me mantained."""
with open(path) as data_file:
data_this = json.load(data_file)
data_this = np.array(data_this['root'])
num_samples = len(data_this)
if os.path.exists(order):
idx = np.load(order)
else:
idx = np.random.permutation(num_samples).tolist()
np.save(order, idx)
is_not_validation = [not data_this[i]['isValidation']
for i in range(num_samples)]
keep_data_idx = list(compress(idx, is_not_validation))
data = data_this[keep_data_idx]
return data, len(keep_data_idx)
process.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录