顶上去同步,二值图 和 灰度度 都没有问题,可前景透明图就是出不来

from aip import AipBodyAnalysis

import cv2

import numpy as np

import base64

import os

import json

""" 你的 APPID AK SK """

APP_ID = ''

API_KEY = ''

SECRET_KEY = ''

client = AipBodyAnalysis(APP_ID, API_KEY, SECRET_KEY)

""" 读取图片 """

def get_file_content(filePath):

with open(filePath, 'rb') as fp:

return fp.read()

image = get_file_content('test.png')

""" 调用人像分割 """

#client.bodySeg(image);

res = client.bodySeg(image)

foreground = base64.b64decode(res['foreground'])

labelmap = base64.b64decode(res['labelmap'])

scoremap = base64.b64decode(res['scoremap'])

nparr_foreground = np.fromstring(foreground,np.uint8)

foregroundimg = cv2.imdecode(nparr_foreground,1)

foregroundimg = cv2.resize(foregroundimg,(512,512),interpolation=cv2.INTER_NEAREST)

im_new_foreground = np.where(foregroundimg==1, 10, foregroundimg)

cv2.imwrite('foreground.png', im_new_foreground)

nparr_labelmap = np.fromstring(labelmap,np.uint8)

labelmapimg = cv2.imdecode(nparr_labelmap,1)

labelmapimg = cv2.resize(labelmapimg,(512,512),interpolation=cv2.INTER_NEAREST)

im_new_labelmapimg = np.where(labelmapimg==1, 255, labelmapimg)

cv2.imwrite('labelmap.png', im_new_labelmapimg)

nparr_scoremap = np.fromstring(scoremap,np.uint8)

scoremapimg = cv2.imdecode(nparr_scoremap,1)

scoremapimg = cv2.resize(scoremapimg,(512,512),interpolation=cv2.INTER_NEAREST)

im_new_scoremapimg = np.where(scoremapimg==1, 255, scoremapimg)

cv2.imwrite('scoremap.png', im_new_scoremapimg)

问题出在哪????python的代码

python人像精细分割_python 人像分割问题 foreground相关推荐

  1. python脚本字符串拼接_Python脚本分割和连接字符串

    python脚本字符串拼接 This article gives an overview of Python Script functions to split strings and string ...

  2. python 字符串分割_Python 字符串分割的方法

    在平时工作的时候,发现对于字符串分割的方法用的比较多,下面对分割字符串方法进行总结一下: 第一种:split()函数 split()函数应该说是分割字符串使用最多的函数 用法: str.split(' ...

  3. python列表分割_python列表分割

    广告关闭 腾讯云11.11云上盛惠 ,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元! ①list从list列表下标a起取值,每次加b在取值,直到大于或等于list长度 ...

  4. python 字符串分割_python中分割字符串split切割并选择输出 逐行读取文件后字符串拼接...

    字符串根据分隔符切割后输出,一下面 #!/usr/bin/python # -*- coding: utf-8 -*- str="abc,123 efg,567" #以空行分割后输 ...

  5. python人像变卡通_python 人像转漫画

    在网上,以及一些视频软件里面,我们都可以看见将人像转变为漫画的软件,那我们可不可以自己来做一个呢!那还等什么,来看一看吧 #python# 材料准备 按照我们之前的操作,我们都是需要先准备材料. 1. ...

  6. python如何拆分字符串_python如何分割字符串

    Python中的split()方法可以将字符串进行分割,具体的方法如下: split() 方法可以实现将一个字符串按照指定的分隔符切分成多个子串,这些子串会被保存到列表中(不包含分隔符),作为方法的返 ...

  7. python人像精细分割_基于UNet网络实现的人像分割 | 附数据集

    点击上方"AI算法与图像处理",选择加"星标"或"置顶" 重磅干货,第一时间送达 以后我会在公众号分享一些关于算法的应用(美颜相关的),工作 ...

  8. 人像精细分割问题分析

    最近参加了一个oppo举办的比赛,做人像精细分割.题目要求是这样的: 任务描述 随着手机硬件平台和人工智能技术的飞速发展,目前的智能手机基本都可以实现后置双摄像头和前置单摄像头对人像拍照时的背景虚化. ...

  9. python拆分合并文件_python实现文件的分割与合并

    使用Python来进行文件的分割与合并是非常简单的. python代码如下: splitFile--将文件分割成大小为chunksize的块: mergeFile--将众多文件块合并成原来的文件: # ...

最新文章

  1. Opencv深拷贝与浅拷贝
  2. 强化学习总结(1-2)——model-base(policy evaluation;policy control)
  3. Bagging Classifier+Regressor
  4. python 字符串加密 唯一数字_python实现字符串加密 生成唯一固定长度字符串
  5. Golang学习 - sort 包
  6. mac上可以使用的Windows远程桌面APP
  7. CAD一键统计所有线段长度
  8. Python定向爬虫入门
  9. 使用MinMaxScaler 中scaler.inverse_transform不能返回原来数据的原因
  10. 20sccm_SCCM安装及配置过程总结
  11. python倒计时代码turtle_python实现屏保计时器
  12. CodeForces 711C - Coloring Trees DP
  13. 万字文肝Redis基础知识
  14. Allein rennen spielen singen beißen.Espoir parfaitement arbre.
  15. 史上最详细教程!Windows上安装Mac OS!多图收藏
  16. 近地面无人机植被定量遥感与生理参数反演
  17. CUIT J2EE 第二次课内容
  18. 篮球投篮的乐趣,一个开始而已
  19. java不同版本的遍历方法
  20. SQL server用户

热门文章

  1. 07年奋战长春亚冬会,08期待再战北京奥运会
  2. 【MySQ必知必会】MySQL 是怎么存储数据的?
  3. 用c语言编写的atof函数,自己实现的atof()和atoi()代码
  4. 操作系统-虚拟内存、虚拟地址空间机制
  5. 现在java现在发展前景怎么样?
  6. REDD Intelligence宣布高管任命
  7. OpenCV3计算机视觉Python语言实现人脸识别笔记
  8. 国内最容易拍出美照的9个地方,喜欢拍照的人必去!
  9. 2006-京淘Day02-3
  10. 基于ffmpeg的音频转码