python人像精细分割_python 人像分割问题 foreground
顶上去同步,二值图 和 灰度度 都没有问题,可前景透明图就是出不来
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相关推荐
- python脚本字符串拼接_Python脚本分割和连接字符串
python脚本字符串拼接 This article gives an overview of Python Script functions to split strings and string ...
- python 字符串分割_Python 字符串分割的方法
在平时工作的时候,发现对于字符串分割的方法用的比较多,下面对分割字符串方法进行总结一下: 第一种:split()函数 split()函数应该说是分割字符串使用最多的函数 用法: str.split(' ...
- python列表分割_python列表分割
广告关闭 腾讯云11.11云上盛惠 ,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元! ①list从list列表下标a起取值,每次加b在取值,直到大于或等于list长度 ...
- python 字符串分割_python中分割字符串split切割并选择输出 逐行读取文件后字符串拼接...
字符串根据分隔符切割后输出,一下面 #!/usr/bin/python # -*- coding: utf-8 -*- str="abc,123 efg,567" #以空行分割后输 ...
- python人像变卡通_python 人像转漫画
在网上,以及一些视频软件里面,我们都可以看见将人像转变为漫画的软件,那我们可不可以自己来做一个呢!那还等什么,来看一看吧 #python# 材料准备 按照我们之前的操作,我们都是需要先准备材料. 1. ...
- python如何拆分字符串_python如何分割字符串
Python中的split()方法可以将字符串进行分割,具体的方法如下: split() 方法可以实现将一个字符串按照指定的分隔符切分成多个子串,这些子串会被保存到列表中(不包含分隔符),作为方法的返 ...
- python人像精细分割_基于UNet网络实现的人像分割 | 附数据集
点击上方"AI算法与图像处理",选择加"星标"或"置顶" 重磅干货,第一时间送达 以后我会在公众号分享一些关于算法的应用(美颜相关的),工作 ...
- 人像精细分割问题分析
最近参加了一个oppo举办的比赛,做人像精细分割.题目要求是这样的: 任务描述 随着手机硬件平台和人工智能技术的飞速发展,目前的智能手机基本都可以实现后置双摄像头和前置单摄像头对人像拍照时的背景虚化. ...
- python拆分合并文件_python实现文件的分割与合并
使用Python来进行文件的分割与合并是非常简单的. python代码如下: splitFile--将文件分割成大小为chunksize的块: mergeFile--将众多文件块合并成原来的文件: # ...
最新文章
- Opencv深拷贝与浅拷贝
- 强化学习总结(1-2)——model-base(policy evaluation;policy control)
- Bagging Classifier+Regressor
- python 字符串加密 唯一数字_python实现字符串加密 生成唯一固定长度字符串
- Golang学习 - sort 包
- mac上可以使用的Windows远程桌面APP
- CAD一键统计所有线段长度
- Python定向爬虫入门
- 使用MinMaxScaler 中scaler.inverse_transform不能返回原来数据的原因
- 20sccm_SCCM安装及配置过程总结
- python倒计时代码turtle_python实现屏保计时器
- CodeForces 711C - Coloring Trees DP
- 万字文肝Redis基础知识
- Allein rennen spielen singen beißen.Espoir parfaitement arbre.
- 史上最详细教程!Windows上安装Mac OS!多图收藏
- 近地面无人机植被定量遥感与生理参数反演
- CUIT J2EE 第二次课内容
- 篮球投篮的乐趣,一个开始而已
- java不同版本的遍历方法
- SQL server用户