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

本文介绍了一种利用人工智能深度网络技术训练的模型,该模型能够实现类似Photoshop的人像抠图功能,支持证件照合成、背景虚化、照片背景替换等多种应用场景。通过提供的API接口,开发者可以方便地在PHP中调用此技术,进行POST请求并获取JSON格式的返回结果。
摘要由CSDN通过智能技术生成

69916647a9c708eeedd87c44a1b36f79.png

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

API接口:

调用地址:

https://vscan.market.alicloudapi.com/object/separation​vscan.market.alicloudapi.com

请求方式:POST

返回类型:JSON

API 调用:

调用API商品_调用云市场API商品_API 网关-阿里云​help.aliyun.com
098b169c253407ba035658bfb9367fa6.png
调用API商品_调用云市场API商品_API 网关-阿里云​help.aliyun.com
098b169c253407ba035658bfb9367fa6.png

调试工具:

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

请求参数(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++极链科技集团 - 聚焦视联网,让每个人极简链接视界万物​videojj.com
fa698e827f36dcee80786507dd135d6f.png

产品参数

交付方式API服务

产品截图

ba61b57203cb5685c0473e9d1f042af8.png

7ddf4a446289cad276dabf2e12695e99.png

ba61b57203cb5685c0473e9d1f042af8.png

7ddf4a446289cad276dabf2e12695e99.png

使用指南

立即下载​netmarket.oss-cn-hangzhou.aliyuncs.com
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值