• 0

  • 点赞

  • 收藏

人工智能人像抠图 -背景抠图- 发丝级人像分割 - 照片人物特效 - 极链科技

张佳毅

关注互联网动态

7个月前

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

API接口:

调用地址:

vscan.market.alicloudapi.com

请求方式:POST

返回类型:JSON

API 调用:

调用API商品_调用云市场API商品_API 网关-阿里云 调用API商品_调用云市场API商品_API 网关-阿里云

调试工具:

阿里云登录 - 欢迎登录阿里云,安全稳定的云计算服务平台

请求参数(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<String, String> headers = new HashMap<String, String>();
	    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
	    headers.put("Authorization", "APPCODE " + appcode);
	    //根据API的要求,定义相对应的Content-Type
	    headers.put("Content-Type", "application/json; charset=UTF-8");
	    Map<String, String> querys = new HashMap<String, String>();
	    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

<?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, sys


host = 'http://vscan.market.alicloudapi.com'
path = '/object/separation'
method = 'POST'
appcode = '你自己的AppCode'
querys = ''
bodys = {}
url = host + path

bodys[''] = "{\"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-Type
request.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 一键完成人像抠图。可应用于证件照合成,人像照片虚化背景,照片背景替换,特效制作,弹幕隐身等多重功能。

产品说明

VideoAi 视频结构化数据平台 - Video++极链科技集团 - 聚焦视联网,让每个人极简链接视界万物

产品参数

交付方式 API服务

产品截图

 

 

 

免责声明:文章版权归原作者所有,其内容与观点不代表Unitimes立场,亦不构成任何投资意见或建议。

互联网

0

相关文章推荐

未登录头像

暂无评论