Baidu AI Application application , obtain APP_ID   API_KEY   SECRET_KEY.

Start drawing :
# -*- coding:utf-8 -*- import cv2 import base64 import numpy as np import os
from aip import AipBodyAnalysis import time import random APP_ID = '25365416'
API_KEY = 'pS5cVzzw2iBfLY6MKRhUE4cw' SECRET_KEY = '×××××××××××××××××××××××'
client = AipBodyAnalysis(APP_ID, API_KEY, SECRET_KEY) # Save the path after image segmentation path =
'./mask_img/' # Save binary path1 = './mask_front/' # Save original foreground # os.listdir Lists the names of pictures saved to pics
= os.listdir('./pictures') print(pics) for im in pics: # Construct picture paths in order img =
os.path.join("./pictures",im) img1 = cv2.imread(img) height, width, _ =
img1.shape # print(height, width) # Reading pictures in binary mode with open(img, 'rb') as fp:
img_info = # Set to return only foreground That is, the split portrait res = client.bodySeg(img_info)
seg_res = client.bodySeg(img_info) labelmap =
base64.b64decode(seg_res['labelmap']) nparr = np.fromstring(labelmap, np.uint8)
labelimg = cv2.imdecode(nparr,1) labelimg = cv2.resize(labelimg,(width,height),
interpolation=cv2.INTER_NEAREST) new_img = np.where(labelimg==1, 255, labelimg)
cv2.imwrite(os.path.join(path,im), new_img) # Return to foreground result =
cv2.bitwise_and(img1, new_img) cv2.imwrite(os.path.join(path1,im), result)
print('======== Image segmentation completed ========')



©2019-2020 Toolsou All rights reserved,
Redis Underlying data structure A person who dissuades others from learning computer , Are not good people win10 System computer C Where's the disc ,c disc users where? (win10c Disk not found users) Freshman c Language student management system ( lower ) hospital WIFI Which family is strong ? utilize Python Script unlimited spoof girlfriend computer C language program design —— Student management system Byte runout - Test development practice - One side cool meridian python Run code at specified time 5 Best style Linux Server system recommendation Anti anxiety life after naked resignation , I believe everything will have the best arrangement