天天看點

阿裡雲工業視覺智能平台使用Quick Start

Step By Step

1、建立工作區

參考 連結1

2、建立資料集

連結2 測試資料集( Tomato&Cucumber ),注意:修改圖檔名稱為英文。

3、資料标注

連結3

4、模型訓練

連結4

5、模型部署

阿裡雲工業視覺智能平台使用Quick Start
阿裡雲工業視覺智能平台使用Quick Start
阿裡雲工業視覺智能平台使用Quick Start

6、模型調用

6.1 pom.xml

<dependencies>
    <dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-core</artifactId>
      <optional>true</optional>
      <version>[4.3.2,5.0.0)</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.5</version>
    </dependency>
    <dependency>
      <groupId>com.aliyun</groupId>
      <artifactId>aliyun-java-sdk-indvi</artifactId>
      <version>1.0.0</version>
    </dependency>
  </dependencies>           

6.2 Code Sample

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.indvi.model.v20190701.GetDetectionResultRequest;
import com.aliyuncs.indvi.model.v20190701.GetDetectionResultResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;

public class demo1 {
    private static String detectUrl = "vegetables";
    private static String imageUrl = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1594299310969&di=3e8fb67c14b88ff556a0b6b99f22d2de&imgtype=0&src=http%3A%2F%2Fimg4.imgtn.bdimg.com%2Fit%2Fu%3D321323004%2C3243292509%26fm%3D214%26gp%3D0.jpg";

    public static void main(String[] args) throws ClientException {

        // access_key_id, access_key_secret  擷取參考連結:https://yq.aliyun.com/articles/693979?spm=a2c4e.11155435.0.0.319326a2bKJ90g
        String accessKeyID = "LTAIRAcw********";
        String accessKeySecret = "cSyIdKppC2NptI****************";
        String regionId = "cn-hangzhou";
        DefaultProfile.addEndpoint(regionId, regionId, "indvi", "indvi.cn-hangzhou.aliyuncs.com");
        IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyID, accessKeySecret);
        //初始化client
        IAcsClient client = new DefaultAcsClient(profile);

        GetDetectionResultRequest request = new GetDetectionResultRequest();
        request.setDetectPath(detectUrl);
        request.setImageUrl(imageUrl);
        try {
            GetDetectionResultResponse response = client.getAcsResponse(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();
        }
    }
}           

6.3 Result

cucumber           

更多參考

模型調用參考 PAI-AutoLearning 圖像分類使用教程

繼續閱讀