智能消除API调用说明

智能消除

GET/POST /ai/image/removal

图像智能消除产品专为电商图片定制,自动识别并消除电商图片中的文字、特定名称、透明字块和牛皮癣,可按需指定消除图片内对象,实现大批量图片的高效、精确处理,简化图片编辑工作。

请求参数

参数类型必填参数描述及示例值

image_url

String

原图 URL,与Base64 不能同时为空;推荐上传图片URL,同时传入时优先取 Base64。图像需是JPG、JPEG、PNG或BMP格式的,分辨率应在512x512至3000x3000像素之间,文件大小不超过10MB。

示例值:http://example.jpg/

image_Base64

String

原图 Base64编码(图像需是JPG、JPEG、PNG或BMP格式的,分辨率应在512x512至3000x3000像素之间,文件大小不超过10MB)。

示例值: iVBORw0KGgoAAAANSUhEUgAAAAUAAA...

object_remove_elements

Number[]

去除图片主体上的元素(1=透明字块;2=特定名称;3=文字;4=牛皮癣),元素类型可多选。

各类型说明可见产品说明

图片主体:图片中的核心产品区域。

Example: [1, 2, 4]

non_object_remove_elements

Number[]

去除图片非主体上的元素(1=透明字块;2=特定名称;3=文字;4=牛皮癣),元素类型可多选。

各类型说明可见产品说明

Example: [1, 2, 4]

mask

String

具体的消除区域。非必填,需要配合编辑器使用,入参格式为 RLE。

若传入将优先使用,忽略remove_non_product_area_elements和remove_product_area_elements这两个参数

Example: 474556 160 475356 160 476156 160 476956 160 477756 160 478556 160 479356 160 480156 160 480956 160 481756 160 482556 160 483356 160 484156 160 484956 160 485756 160 486556 160 487356 160 488156 160 488956 160 489756 160 490556 160 491356 160 492156 160

请求示例

IopClient client = new IopClient(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.setApiName("/ai/image/removal");
request.addApiParameter("image_base64", "Base64");
request.addApiParameter("image_url", "https://ae01.alicdn.com/kf/Sa78257f1d9a34dad8ee494178db12ec8l.jpg");
request.addApiParameter("non_object_remove_elements", "[1,2,3,4]");
request.addApiParameter("object_remove_elements", "[1,2,3,4]");
request.addApiParameter("mask", "474556 160 475356 160 476156 160 476956 160 477756 160 478556 160 479356 160 480156 160 480956 160 481756 160 482556 160 483356 160 484156 160 484956 160 485756 160 486556 160 487356 160 488156 160 488956 160 489756 160 490556 160 491356 160 492156  160");
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);

响应参数

参数类型描述

resCode

Number

响应代码; 200 代表调用成功,其他的响应代码可以参考错误码信息。

data

Object

返回结果的结构体信息。

requestId

String

请求 ID;用来识别唯一一次请求调用。

success

Boolean

是否成功;true 代表成功,false 代表失败。

resMessage

String

报错信息,例如“内容包含敏感信息,请尝试其他输入”。

响应示例

{
  "data": {
    "imageUrl": "https://nhci-aigc.oss-cn-zhangjiakou.aliyuncs.com/ppc-records%2Fimage-remove%2F805fe1d4-8335-4eaa-b4c1-f9952fea21ef.png?OSSAccessKeyId=LTAI5tCv9DpB7gYic1oGsAyv&Expires=4935905309&Signature=eIJOXyUEBoxqb3VtUJF08xFlcgM%3D",
    "usage": 1,
    "width": 800,
    "class": "com.aidc.service.api.client.image.dto.ImageGenResponse",
    "height": 1259
  },
  "requestId": "2140e7df17192333083756998ebc3f",
  "success": true,
  "resCode": 200,
  "resMessage": "success",
  "code": "0",
  "request_id": "2101725817192333083795305",
  "_trace_id_": "2140e7df17192333083756998ebc3f"
}

错误码

错误码错误信息描述

500

system error

System error.服务器内部错误

501

rate limit exceed

当前接口已达到限流上限,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们增加当前限制值。

700

invalid input

输入参数的格式不符合要求,resMessage 将返回详细的不符合要求的字段。

701

image url error

图片URL错误,请重试。

702

image base64 error

图片base64下载或识别失败。

703

image size exceeds the limit

图片过大,超出限制,请提供尺寸符合要求的图片。

704

invalid image form

图片格式不支持。

705

image file size exceeds the limit

图片解析后大小应控制在10MB以内。

801

model failed

内部调用异常,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们进行故障排除。

900

tpp url error

内部调用异常,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们进行故障排除。

1000

content has sensitive data, please try other input

内容包含敏感数据,无法处理,请尝试其他输入。

1001

content control failed, please retry

风控服务运行异常,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们。

1002

content risk filter failed, please contact us

风控服务运行异常,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们。

Notice

By using this API, you confirm that you are a legal owner of all intellectual property rights pertaining to the data and content that you provide to us via the API, or have obtained the necessary authorizations for us to receive and use the same from you. You further agree that you will not use this product or any output thereof for any unlawful, unethical, unauthorized or harmful activities.

Last updated