def convert(inputs):
imname = inputs['original_filename']
image = inputs['image']
labels = inputs['labels']
label_vis = inputs['label_vis']
results = []
segmentation = labels[:, :, 0]
norm_factor = float(crop) / max(image.shape[:2])
image = scipy.misc.imresize(image, norm_factor, interp='bilinear')
segmentation = scipy.misc.imresize(segmentation, norm_factor, interp='nearest')
if image.shape[0] < crop:
# Pad height.
image = pad_height(image, crop)
segmentation = pad_height(segmentation, crop)
if image.shape[1] < crop:
image = pad_width(image, crop)
segmentation = pad_width(segmentation, crop)
labels = np.dstack([segmentation] * 3)
label_vis = apply_colormap(segmentation, vmax=21, vmin=0, cmap=CMAP)[:, :, :3]
results.append([imname, image * (labels != 0), labels, label_vis])
# Swapped version.
imname = path.splitext(imname)[0] + '_swapped' + path.splitext(imname)[1]
image = image[:, ::-1]
segmentation = segmentation[:, ::-1]
segmentation = lrswap_regions(segmentation)
labels = np.dstack([segmentation] * 3)
label_vis = apply_colormap(segmentation, vmax=21, vmin=0, cmap=CMAP)[:, :, :3]
results.append([imname, image * (labels != 0), labels, label_vis])
return results
02_create_clothdataset.py 文件源码
python
阅读 34
收藏 0
点赞 0
评论 0
评论列表
文章目录