未验证 提交 79014eca 编写于 作者: S Steffy-zxf 提交者: GitHub

Fix humanseg bug (#714)

上级 5e4d0c55
......@@ -22,7 +22,7 @@ from deeplabv3p_xception65_humanseg.data_feed import reader
author="baidu-vis",
author_email="",
summary="DeepLabv3+ is a semantic segmentation model.",
version="1.1.0")
version="1.1.1")
class DeeplabV3pXception65HumanSeg(hub.Module):
def _initialize(self):
self.default_pretrained_model_path = os.path.join(
......@@ -220,3 +220,11 @@ class DeeplabV3pXception65HumanSeg(hub.Module):
"""
self.arg_input_group.add_argument(
'--input_path', type=str, help="path to image.")
if __name__ == "__main__":
m = DeeplabV3pXception65HumanSeg()
import cv2
img = cv2.imread('./meditation.jpg')
res = m.segmentation(images=[img])
print(res[0]['data'])
......@@ -52,8 +52,9 @@ def postprocess(data_out,
for logit in data_out:
logit = logit[1] * 255
logit = cv2.resize(logit, (org_im_shape[1], org_im_shape[0]))
ret, logit = cv2.threshold(logit, thresh, 0, cv2.THRESH_TOZERO)
logit = 255 * (logit - thresh) / (255 - thresh)
logit -= thresh
logit[logit < 0] = 0
logit = 255 * logit / (255 - thresh)
rgba = np.concatenate((org_im, np.expand_dims(logit, axis=2)), axis=2)
if visualization:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册