def write_log(self, results):
"""Process results
Args:
results: y_out, s_out
"""
inp = self._batch
y_out = results['y_out']
d_out = results['d_out']
with h5py.File(self.dataset.h5_fname, 'r+') as h5f:
for ii in xrange(y_out.shape[0]):
idx = inp['idx_map'][ii]
group = h5f[self.dataset.get_str_id(idx)]
if 'foreground_pred' in group:
del group['foreground_pred']
if 'orientation_pred' in group:
del group['orientation_pred']
for cl in range(y_out.shape[3]):
y_out_arr = y_out[ii, :, :, cl]
y_out_arr = (y_out_arr * 255).astype('uint8')
y_out_str = cv2.imencode('.png', y_out_arr)[1]
group['foreground_pred/{:02d}'.format(cl)] = y_out_str
for ch in range(d_out.shape[3]):
d_out_arr = d_out[ii, :, :, ch]
d_out_arr = (d_out_arr * 255).astype('uint8')
d_out_str = cv2.imencode('.png', d_out_arr)[1]
group['orientation_pred/{:02d}'.format(ch)] = d_out_str
评论列表
文章目录