python人像精细分割_人像抠图 - 发丝级人像分割 - 照片人物特效 - 极链科技

利用人工智能深度网络技术训练出的模型,可以模拟 Photoshop 一键完成人像抠图。可应用于证件照合成,人像照片虚化背景,照片背景替换,特效制作,弹幕隐身等多重功能。

请求参数(Body):

{ "imageType": 1, "image": "https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/test/angelababy.jpeg"}

请求示例:

curl

curl -i -X POST 'http://vscan.market.alicloudapi.com/object/separation' -H 'Authorization:APPCODE 你自己的AppCode' --data '{ "imageType": 1, "image": "https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/test/angelababy.jpeg"}' -H 'Content-Type:application/json; charset=UTF-8'//根据API的要求,定义相对应的Content-Type

Java

public static void main(String[] args) { String host = "http://vscan.market.alicloudapi.com"; String path = "/object/separation"; String method = "POST"; String appcode = "你自己的AppCode"; Map headers = new HashMap(); //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 headers.put("Authorization", "APPCODE " + appcode); //根据API的要求,定义相对应的Content-Type headers.put("Content-Type", "application/json; charset=UTF-8"); Map querys = new HashMap(); String bodys = "{\"imageType\":1,\"image\":\"https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/test/angelababy.jpeg\"}"; try { /** * 重要提示如下: * HttpUtils请从 * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java * 下载 * * 相应的依赖请参照 * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml */ HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); System.out.println(response.toString()); //获取response的body //System.out.println(EntityUtils.toString(response.getEntity())); } catch (Exception e) { e.printStackTrace(); }}

C#

//using System.IO;//using System.Text;//using System.Net;//using System.Net.Security;//using System.Security.Cryptography.X509Certificates; private const String host = "vscan.market.alicloudapi.com"; private const String path = "/object/separation"; private const String method = "POST"; private const String appcode = "你自己的AppCode"; static void Main(string[] args) { String querys = ""; String bodys = "{\"imageType\":1,\"image\":\"https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/test/angelababy.jpeg\"}"; String url = host + path; HttpWebRequest httpRequest = null; HttpWebResponse httpResponse = null; if (0 < querys.Length) { url = url + "?" + querys; } if (host.Contains("https://")) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); } else { httpRequest = (HttpWebRequest)WebRequest.Create(url); } httpRequest.Method = method; httpRequest.Headers.Add("Authorization", "APPCODE " + appcode); //根据API的要求,定义相对应的Content-Type httpRequest.ContentType = "application/json; charset=UTF-8"; if (0 < bodys.Length) { byte[] data = Encoding.UTF8.GetBytes(bodys); using (Stream stream = httpRequest.GetRequestStream()) { stream.Write(data, 0, data.Length); } } try { httpResponse = (HttpWebResponse)httpRequest.GetResponse(); } catch (WebException ex) { httpResponse = (HttpWebResponse)ex.Response; } Console.WriteLine(httpResponse.StatusCode); Console.WriteLine(httpResponse.Method); Console.WriteLine(httpResponse.Headers); Stream st = httpResponse.GetResponseStream(); StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8")); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("\n"); } public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; }

PHP

$host = "http://vscan.market.alicloudapi.com"; $path = "/object/separation"; $method = "POST"; $appcode = "你自己的AppCode"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); //根据API的要求,定义相对应的Content-Type array_push($headers, "Content-Type".":"."application/json; charset=UTF-8"); $querys = ""; $bodys = "{\"imageType\":1,\"image\":\"https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/test/angelababy.jpeg\"}"; $url = $host . $path; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); if (1 == strpos("$".$host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); var_dump(curl_exec($curl));?>

Python

import urllib, urllib2, syshost = 'http://vscan.market.alicloudapi.com'path = '/object/separation'method = 'POST'appcode = '你自己的AppCode'querys = ''bodys = {}url = host + pathbodys[''] = "{\"imageType\":1,\"image\":\"https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/test/angelababy.jpeg\"}"post_data = bodys['']request = urllib2.Request(url, post_data)request.add_header('Authorization', 'APPCODE ' + appcode)//根据API的要求,定义相对应的Content-Typerequest.add_header('Content-Type', 'application/json; charset=UTF-8')response = urllib2.urlopen(request)content = response.read()if (content): print(content)

ObjectC

NSString *appcode = @"你自己的AppCode";NSString *host = @"http://vscan.market.alicloudapi.com";NSString *path = @"/object/separation";NSString *method = @"POST";NSString *querys = @"";NSString *url = [NSString stringWithFormat:@"%@%@%@", host, path , querys];NSString *bodys = @"{\"imageType\":1,\"image\":\"https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/test/angelababy.jpeg\"}";NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString: url] cachePolicy:1 timeoutInterval: 5];request.HTTPMethod = method;[request addValue: [NSString stringWithFormat:@"APPCODE %@" , appcode] forHTTPHeaderField: @"Authorization"];//根据API的要求,定义相对应的Content-Type[request addValue: @"application/json; charset=UTF-8" forHTTPHeaderField: @"Content-Type"];NSData *data = [bodys dataUsingEncoding: NSUTF8StringEncoding];[request setHTTPBody: data];NSURLSession *requestSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];NSURLSessionDataTask *task = [requestSession dataTaskWithRequest:request completionHandler:^(NSData * _Nullable body , NSURLResponse * _Nullable response, NSError * _Nullable error) { NSLog(@"Response object: %@" , response); NSString *bodyString = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding]; //打印应答中的body NSLog(@"Response body: %@" , bodyString); }];[task resume];

正常返回示例

{ "status": 200, "taskId": "161b721de5494da69614c1523ea39016", "data": { "url": "https://arithmetic-cloud.oss-cn-shanghai.aliyuncs.com/image/matting/99fb4310c09d4f7fb509f19e6299a49e/result.png" }}

失败返回示例

{ "status": 500, "taskId": "f181cc54ad804de58c857f22a1b5a849", "message": "timeout"}

产品亮点

利用人工智能深度网络技术训练出的模型,可以模拟 Photoshop 一键完成人像抠图。可应用于证件照合成,人像照片虚化背景,照片背景替换,特效制作,弹幕隐身等多重功能。

产品截图

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值