def process_image(im_fp, dset_part):
bn = path.basename(im_fp)
dn = path.dirname(im_fp)
img_idx = int(bn[:bn.find("_")])
body_fp = path.join(dn, bn + '_body.pkl')
im = sm.imread(im_fp)
if not path.exists(body_fp):
raise Exception("Body fit not found for `%s`!" % (im_fp))
rendering = upr.render_body_impl(body_fp,
resolution=(im.shape[0], im.shape[1]),
quiet=True,
use_light=False)[0]
annotation = upm.regions_to_classes(rendering, upm.six_region_groups,
warn_id=str(img_idx))
out_fp = path.join('..', 'data', 'pose', 'extracted', dset_part,
"{:0{width}d}_bodysegments.png".format(
img_idx, width=bn.find("_")))
sm.imsave(out_fp, annotation)
out_fp = path.join('..', 'data', 'pose', 'extracted', dset_part,
"{:0{width}d}_bodysegments_vis.png".format(
img_idx, width=bn.find("_")))
sm.imsave(out_fp, vs.apply_colormap(annotation, vmin=0, vmax=6,
cmap=config.CMAP)[:, :, 0:3])
评论列表
文章目录