模型调用参考
要调用您完成部署的模型,需要首先下载工业视觉智能 SDK DEMO
初始化SDK
String accessKeyID = "<your accessKey>";
String accessKeySecret = "<your accessSecret>";
String regionId = "cn-hangzhou";
DefaultProfile.addEndpoint(regionId, regionId, "indvi", "indvi.cn-hangzhou.aliyuncs.com");
IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyID, accessKeySecret);
//初始化client
client = new DefaultAcsClient(profile);
依赖公共包导入
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-indvi</artifactId>
<version>1.0.0</version>
</dependency>
发起调用
示例程序:
private static String detectUrl = "<your detect url>";
private static String imageUrl = "<your image url>";
public static void detectTest() {
GetDetectionResultRequest request = new GetDetectionResultRequest();
request.setDetectPath(detectUrl);
request.setImageUrl(imageUrl);
try {
GetDetectionResultResponse response = (GetDetectionResultResponse) executeTest(request);
if (null == response) {
return;
}
if (response.getSuccess() == false) {
System.out.print(response.toString());
return;
}
String result = response.getResult();//图片测试结果
System.out.print(result);
} catch (Exception e) {
e.printStackTrace();
}
}
API说明
获取图片推测结果接口:
GetDetectionResult
请求参数:
名称 | 类型 | 必要 | 描述 |
---|---|---|---|
DetectPath | String | 是 | 调用的API路径 |
ImageUrl | String | 是 | 需要预测的图片链接 |
获取图片推测结果
返回值:
名称 | 类型 | 描述 |
---|---|---|
RequestId | String | 阿里云为请求生产的唯一标识符 |
Success | Boolean | 表示是否调用成功。true表示调用成功,false表示 |
Code | String | 错误码 |
ErrorMessage | String | 调用失败时,返回的出错信息 |
Result | String | 推测结果 |
错误码
错误码 | 代码 | 说明 |
---|---|---|
SUCCESS | 200 | 成功 |
UNKONW_ERROR | -1 | 系统异常 |
EMPTYPARAM | 201 | 请求参数不能为空 |
UNKOWNPARAM | 202 | 请求参数不合法 |
NODATA | 203 | 无返回数据 |
ISEXIST | 204 | 对象已存在 |
NOTEXIST | 205 | 对象不存在或被删除 |
USERAUTHORITYINVALID | 403 | 用户无权限 |
TRAIN_FORBIDDEN | 405 | 产品训练服务没有开通 |
DEPLOY_FORBIDDEN | 406 | 产品部署服务没有开通 |
RAM_FORBIDDEN | 407 | 没有ram权限 |