我在代码中添加了rgb及其对应的深度图像,并将结果保存为numpy array 6通道图像。我运行代码,直到193张图片,它都摇摆了,但是之后由于错误GraphDef而停止,不能超过2GB。我搜索并找到了解决方案,但是我无法更改代码。
filename='image_2'
filename1='depth'
filename2='train'
if _platform == "linux" or _platform == "linux2": # linux
data_path = '/home/lps/squeezeDet/data/KITTI/training/'+filename+'/'
data_path1 = '/home/lps/squeezeDet/data/KITTI/training/'+filename1+'/'
data_path2 = '/home/lps/squeezeDet/data/KITTI/training/'+filename2+'/'
elif _platform == "darwin": # MAC OS X
data_path = '/Users/CCLee/image_data/dicom_so/'
# out_path = '/Users/CCLee/tmp/dicom_so/out/'
elif _platform == "win32": # Windows
data_path = 'D:/work_data/dicom_so/'
# out_path = 'D:/work_data/dicom_so/out/'
inpath = pathlib.Path(data_path)
inpath1 = pathlib.Path(data_path1)
outpath = pathlib.Path(data_path2)
if not outpath.exists():
outpath.mkdir()
print('no output path, create {}'.format(filename2))
dicom_lst = sorted(inpath.glob('*.png'))
dicom_lst1 = sorted(inpath1.glob('*.png'))
dicom_list = dicom_lst#[3:4]
num_files = len(dicom_list)
i=0
for fname1, fname in zip(dicom_list,dicom_lst1) :
filename1=fname.name.rsplit('.', 2)[0]
ftitle = fname1.name.rsplit('.', 2)[0]
# ftitle = ftitle[-5:]
print('process {}/{}, depth image:{}, original image: {}'.format(i+1, num_files, fname.name,fname1.name))
i=+1
image = mpimg.imread(str(fname1))
image1 = mpimg.imread(str(fname))
x = tf.Variable(image, name='x')
y = tf.Variable(image1, name='y')
model = tf.global_variables_initializer()
with tf.Session() as session:
z = tf.concat([x,y],2)
#x= tf.concat([tf.expand_dims(t, 2) for t in x,y],2)
session.run(model)
result = session.run(z)
out_name = outpath.joinpath(ftitle+'.npy')
np.save(str(out_name), result)