AI智能人脸识别,抠图 |
您所在的位置:网站首页 › 四寸证件照片制作软件免费下载 › AI智能人脸识别,抠图 |
效果展示: def resize_image(self, org_img, width, height, color, filename, suffix, config_path): today = date_util.todaystr() parent_folder = config_path[‘root_folder’] static_folder = config_path[‘static’] temp_folder = config_path[‘temp’] parent_path = os.path.join(parent_folder, static_folder, today) if not os.path.exists(parent_path): os.makedirs(parent_path) temp_path = os.path.join(parent_folder, temp_folder) if not os.path.exists(temp_path): os.makedirs(temp_path) id_image = os.path.join(parent_path, filename + suffix) crop_face(org_img, id_image, int(width), int(height)) model = onnx_test_image.Matting(model_path='./model/modnet.onnx', input_size=(512, 512)) model.predict_image(id_image, os.path.join(parent_path, filename + "_cutout.png"),color) info = {} if width and height: width = int(width) height = int(height) target_image = os.path.join(parent_path, filename + '_finally.jpg') resize_image.resize_image(id_image, width, height, target_image) target_iamge_cut = os.path.join(static_folder, today, filename + '_finally.jpg') info['targetImageCut'] = target_iamge_cut print('target_iamge_cut===', target_iamge_cut) # 最终图包含背景且切图 #原图 source_image = os.path.join(static_folder, today, filename + suffix) source_image_not_back = os.path.join(static_folder, today, filename + "_cutout.png") print('source_image_not_back===', source_image_not_back)代码地址: https://gitee.com/get-help/ai-photo-web |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |