当前位置:   article > 正文

【案例教学】华为云API图像搜索ImageSearch的快捷性—AI帮助您快速归类图片_华为imagesearch

华为imagesearch

云服务、API、SDK,调试,查看,我都行

阅读短文您可以学习到:人工智能AI同类型的相片合并归类

1 IntelliJ IDEA 之API插件介绍

API插件支持 VS Code IDE、IntelliJ IDEA等平台、以及华为云自研 CodeArts IDE,基于华为云服务提供的能力,帮助开发者更高效、便捷的搭建应用。API插件关联华为云服务下的 API Explorer、DevStar、CodeLabs、SDK 中心和 CLI 中心产品,致力于为开发者提供更稳定、快速、安全的编程体验。

在本插件中,我们提供了但不局限于如下的功能:

对接华为云API开放平台,支持用户检索API、查看API文档、调试API、以及提供SDK示例代码供用户学习如何使用API。

提供华为云SDK代码片段补全功能,SDK依赖包自动引入,加速用户集成华为云API。

对接华为云开发体验馆Codelabs,提供500+云服务代码示例,向导式教程帮助用户快速学习。

说明:

在IntelliJ IDEA等系列平台和VS Code IDE,华为云API插件的名称是Huawei Cloud API。而在CodeArts IDE,API插件是IDE原生内置的,名称是华为云API开发套件。

API插件在IntelliJ IDEA等系列平台和VS Code IDE的使用依赖底座插件,请提前安装底座插件。

2  API插件安装--IntelliJ IDEA

2.1 IntelliJ IDEA等平台

安装准备:下载并安装JDK1.8或更高版本。下载并安装IntelliJ IDEA 2020.2或更高版本。

须知:IntellIj平台同时支撑包括Goland、Pycharm等在内的IDE,若在其它相关IDE上开发,请下载配置好对应语言的编译器或者解释器。这里以IDEA为例介绍IntelliJ平台插件的安装流程,其他IntelliJ系列的IDE请参考IDEA。https://developer.huaweicloud.com/develop/toolkit.html

开始安装:

您可以在直接在IDE插件市场或者直接在JetBrains插件市场下载离线包安装。

IDE安装

  1. 在IntelliJ IDEA顶部菜单栏中选择File > Settings,在Settings对话框的左侧导航栏中单击Plugins。
  2. Plugins区域单击Marketplace,在搜索栏中输入Huawei Cloud API。
  3. Search Results区域会出现Huawei Cloud API,单击Install,完成后重启IDE。

离线包安装:

  1. 进入插件市场搜索Huawei Cloud API,进入插件详情页,在Versions页签下选择想要版本的API插件,点击Download下载离线的插件压缩包保存到本地。。
  2. 在IntelliJ IDEA顶部菜单栏中选择File > Settings,在Settings对话框的左侧导航栏中单击Plugins。
  3. 在Plugins区域单击 ,再单击Install Plugin from Disk...。
  4. 在Choose Plugin File对话框中选择离线安装包(不用解压),并按照IntelliJ IDEA安装页面的提示,完成后续安装步骤。

说明:若当前您想要安装插件的IntelliJ IDE已经在桌面打开,则进入插件市场搜索Huawei Cloud API,进入插件详情页,在右上角会识别到本地已经打开的IDE,点击相应按钮,在弹出的IDE窗口中点击ok,则IDE后台会开始安装相应版本的API插件。

安装验证:在IntelliJ系列平台上安装插件成功后在左侧的导航栏中可以看到Huawei Cloud Toolkit图标,点击后面板会出现Huawei Cloud API的字样,则说明安装成功。

2.2 API列表

左侧展示API列表,可以查询所有API,目前云服务206,APIs9213

Toolkit-华为云

版本说明

本示例基于华为云SDK V3.0版本开发

功能介绍

创建实例,实例中会生成图片索引库,用来存放图片特征。

该示例展示了如何通过java版SDK实现创建实例。

前置条件

获取AK/SK

开发者在使用前需先获取账号的ak、sk、endpoint。

您需要拥有华为云账号以及该账号对应的 Access Key(AK)和 Secret Access Key(SK)。请在华为云控制台“我的凭证-访问密钥”页面上创建和查看您的 AK/SK。更多信息请查看访问密钥。

endpoint 华为云各服务应用区域和各服务的终端节点,详情请查看地区和终端节点。

运行环境

Java JDK 1.8 及其以上版本,推荐通过Maven 安装依赖的方式使用JAVA版本SDK。

SDK获取和安装

在Maven 项目的 pom.xml 文件加入相应版本的依赖项即可。

以引入3.0.67版本的内容审核SDK为例:

<dependency>

    <groupId>com.huaweicloud.sdk</groupId>

    <artifactId>huaweicloud-sdk-imagesearch</artifactId>

    <version>3.0.67</version>

</dependency>

3 创建图像搜索实例

图像内容审核示例代码只需将AK/SK信息替换为实际AK/SK,代码中可以使用CreateInstanceReq类的setName或setModel方法配置实例名称和模型名称,配置完成后运行即可。

  1. import com.huaweicloud.sdk.core.auth.ICredential;
  2. import com.huaweicloud.sdk.core.auth.BasicCredentials;
  3. import com.huaweicloud.sdk.core.exception.ConnectionException;
  4. import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
  5. import com.huaweicloud.sdk.core.exception.ServiceResponseException;
  6. import com.huaweicloud.sdk.imagesearch.v1.ImageSearchClient;
  7. import com.huaweicloud.sdk.imagesearch.v1.model.RunCreateInstanceRequest;
  8. import com.huaweicloud.sdk.imagesearch.v1.model.CreateInstanceReq;
  9. import com.huaweicloud.sdk.imagesearch.v1.model.RunCreateInstanceResponse;
  10. import com.huaweicloud.sdk.imagesearch.v1.region.ImageSearchRegion;
  11. public class ImageSearchCreateInstanceDemo {
  12. public static void main(String[] args) {
  13. String ak = "<YOUR AK>";
  14. String sk = "<YOUR SK>";
  15. ICredential auth = new BasicCredentials()
  16. .withAk(ak)
  17. .withSk(sk);
  18. ImageSearchClient client = ImageSearchClient.newBuilder()
  19. .withCredential(auth)
  20. .withRegion(ImageSearchRegion.valueOf("cn-north-4"))
  21. .build();
  22. RunCreateInstanceRequest request = new RunCreateInstanceRequest();
  23. CreateInstanceReq body = new CreateInstanceReq();
  24. body.setName("instance-name");
  25. body.setModel("common-search");
  26. request.setBody(body);
  27. try {
  28. RunCreateInstanceResponse response = client.runCreateInstance(request);
  29. System.out.println(response.toString());
  30. } catch (ConnectionException e) {
  31. System.out.println(e.getMessage());
  32. } catch (RequestTimeoutException e) {
  33. System.out.println(e.getMessage());
  34. } catch (ServiceResponseException e) {
  35. System.out.println(e.getHttpStatusCode());
  36. System.out.println(e.getErrorCode());
  37. System.out.println(e.getErrorMsg());
  38. }
  39. }
  40. }

4 删除图像搜索实例

删除实例示例代码只需将AK/SK信息替换为实际AK/SK,代码中可以使用RunDeleteInstanceRequest类的setInstanceName方法配置实例名称,配置完成后运行即可。

  1. import com.huaweicloud.sdk.core.auth.ICredential;
  2. import com.huaweicloud.sdk.core.auth.BasicCredentials;
  3. import com.huaweicloud.sdk.core.exception.ConnectionException;
  4. import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
  5. import com.huaweicloud.sdk.core.exception.ServiceResponseException;
  6. import com.huaweicloud.sdk.imagesearch.v1.ImageSearchClient;
  7. import com.huaweicloud.sdk.imagesearch.v1.model.RunDeleteInstanceRequest;
  8. import com.huaweicloud.sdk.imagesearch.v1.model.RunDeleteInstanceResponse;
  9. import com.huaweicloud.sdk.imagesearch.v1.region.ImageSearchRegion;
  10. public class ImageSearchDeleteInstanceDemo {
  11. public static void main(String[] args) {
  12. String ak = "<YOUR AK>";
  13. String sk = "<YOUR SK>";
  14. ICredential auth = new BasicCredentials()
  15. .withAk(ak)
  16. .withSk(sk);
  17. ImageSearchClient client = ImageSearchClient.newBuilder()
  18. .withCredential(auth)
  19. .withRegion(ImageSearchRegion.valueOf("cn-north-4"))
  20. .build();
  21. RunDeleteInstanceRequest request = new RunDeleteInstanceRequest();
  22. request.setInstanceName("instance-name");
  23. try {
  24. RunDeleteInstanceResponse response = client.runDeleteInstance(request);
  25. System.out.println(response.toString());
  26. } catch (ConnectionException e) {
  27. System.out.println(e.getMessage());
  28. } catch (RequestTimeoutException e) {
  29. System.out.println(e.getMessage());
  30. } catch (ServiceResponseException e) {
  31. System.out.println(e.getHttpStatusCode());
  32. System.out.println(e.getErrorCode());
  33. System.out.println(e.getErrorMsg());
  34. }
  35. }
  36. }

5 相册中筛选同类型的相片合并归类

使用如下代码(来自ImageSearchService.py)同步查询特定 Region 下的图像搜索服务(IS),调用前请根据实际情况替换如下变量 {your ak string}、{your sk string}、{your region string}、{your endpoint string} 、{your projectId string} 以及 {your file path string}

  1. class ImageSearchService(object):
  2. def __init__(self, service_name, region, ak, sk, end_point_url, project_id):
  3. self.end_point_url = end_point_url
  4. self.project_id = project_id
  5. self.sig = signer.Signer()
  6. self.sig.Key = ak
  7. self.sig.Secret = sk
  8. self.name = service_name
  9. self.region = region
  10. def create_instance(self, project_id, model, name, description="", tags=["test-tags"]):
  11. uri = "https://imagesearch.cn-north-4.myhuaweicloud.com/v1/%s/service"%project_id
  12. data = {"project_id": project_id,
  13. "model": model,
  14. "name": name,
  15. "description": description,
  16. "tags": tags
  17. }
  18. json_data = json.dumps(data)
  19. r = signer.HttpRequest("POST", uri)
  20. r.body = json_data
  21. r.headers = {"content-type": "application/json"}
  22. self.sig.Sign(r)
  23. resp = requests.request(r.method,
  24. r.scheme+"://"+r.host+r.uri,
  25. headers=r.headers,
  26. data=r.body)
  27. # print(resp.status_code, resp.reason)
  28. # print(resp.content)
  29. return resp
  30. def delete_instance(self, project_id, instance_name):
  31. uri = "https://imagesearch.cn-north-4.myhuaweicloud.com/v1/%s/service/%s"%(project_id, instance_name)
  32. data = {}
  33. json_data = json.dumps(data)
  34. r = signer.HttpRequest("DELETE", uri)
  35. r.body = json_data
  36. r.headers = {"content-type": "application/json"}
  37. self.sig.Sign(r)
  38. resp = requests.request(r.method,
  39. r.scheme+"://"+r.host+r.uri,
  40. headers=r.headers,
  41. data=r.body)
  42. # print(resp.status_code, resp.reason)
  43. # print(resp.content)
  44. return resp
  45. def check_user_instance(self, end_point_url, project_id, instance_name):
  46. uri = "%s/v1/%s/service/%s"%(end_point_url, project_id, instance_name)
  47. print(uri)
  48. data = {}
  49. json_data = json.dumps(data)
  50. r = signer.HttpRequest("GET", uri)
  51. r.body = json_data
  52. r.headers = {"content-type": "application/json"}
  53. self.sig.Sign(r)
  54. resp = requests.request(r.method,
  55. r.scheme+"://"+r.host+r.uri,
  56. headers=r.headers,
  57. data=r.body)
  58. # print(resp.status_code, resp.reason)
  59. # print(resp.content)
  60. return resp
  61. def add_picture(self, project_id, instance_name, path, file="", is_crop=False, tags={"test-tags": "test-default"}):
  62. print("call add_picture: %s, length of file path %d"%(path, len(path)))
  63. uri = "https://imagesearch.cn-north-4.myhuaweicloud.com/v1/%s/%s/image"%(project_id, instance_name)
  64. # print(uri)
  65. data = {}
  66. data["path"] = path
  67. data["file"] = file
  68. data["tags"] = tags
  69. json_data = json.dumps(data)
  70. r = signer.HttpRequest("POST", uri)
  71. r.body = json_data
  72. r.headers = {"content-type": "application/json"}
  73. self.sig.Sign(r)
  74. resp = requests.request(r.method,
  75. r.scheme+"://"+r.host+r.uri,
  76. headers=r.headers,
  77. data=r.body)
  78. # print(resp.status_code, resp.reason)
  79. # print(resp.content)
  80. return resp
  81. def search_picture(self, project_id, instance_name,
  82. path="", box={"height": 0, "width": 0, "x": 0, "y": 0},
  83. file="", is_crop=False, limit=0, offset=0):
  84. uri = "https://imagesearch.cn-north-4.myhuaweicloud.com/v1/%s/%s/image/search"%(project_id, instance_name)
  85. data = {}
  86. data["path"] = path
  87. data["file"] = file
  88. json_data = json.dumps(data)
  89. r = signer.HttpRequest("POST", uri)
  90. r.body = json_data
  91. r.headers = {"content-type": "application/json"}
  92. self.sig.Sign(r)
  93. resp = requests.request(r.method,
  94. r.scheme+"://"+r.host+r.uri,
  95. headers=r.headers,
  96. data=r.body)
  97. # print(resp.status_code, resp.reason)
  98. # print(resp.content)
  99. return resp
  100. def delete_picture(self, project_id, instance_name, path):
  101. uri = "https://imagesearch.cn-north-4.myhuaweicloud.com/v1/%s/%s/image"%(project_id, instance_name)
  102. data = {}
  103. data["path"] = path
  104. json_data = json.dumps(data)
  105. r = signer.HttpRequest("DELETE", uri)
  106. r.body = json_data
  107. r.headers = {"content-type": "application/json"}
  108. self.sig.Sign(r)
  109. resp = requests.request(r.method,
  110. r.scheme+"://"+r.host+r.uri,
  111. headers=r.headers,
  112. data=r.body)
  113. # print(resp.status_code, resp.reason)
  114. # print(resp.content)
  115. return resp
  116. def check_picture(self, project_id, instance_name, path):
  117. uri = "https://imagesearch.cn-north-4.myhuaweicloud.com/v1/%s/%s/image/check"%(project_id, instance_name)
  118. data = {}
  119. data["path"] = path
  120. json_data = json.dumps(data)
  121. r = signer.HttpRequest("POST", uri)
  122. r.body = json_data
  123. r.headers = {"content-type": "application/json"}
  124. self.sig.Sign(r)
  125. resp = requests.request(r.method,
  126. r.scheme+"://"+r.host+r.uri,
  127. headers=r.headers,
  128. data=r.body)
  129. # print(resp.status_code, resp.reason)
  130. # print(resp.content)
  131. return resp
  132. def update_picture(self, project_id, instance_name, path, tags={}):
  133. uri = "https://imagesearch.cn-north-4.myhuaweicloud.com/v1/%s/%s/image"%(project_id, instance_name)
  134. data = {}
  135. data["path"] = path
  136. data["tags"] = tags
  137. json_data = json.dumps(data)
  138. r = signer.HttpRequest("PUT", uri)
  139. r.body = json_data
  140. r.headers = {"content-type": "application/json"}
  141. self.sig.Sign(r)
  142. resp = requests.request(r.method,
  143. r.scheme+"://"+r.host+r.uri,
  144. headers=r.headers,
  145. data=r.body)
  146. # print(resp.status_code, resp.reason)
  147. # print(resp.content)
  148. return resp

运行示例

执行bash config.bash,脚本会自动python环境相关的依赖,然后根据系统提示输入AK,SK,Project ID。

配置成功后会自动生成cfg.ini,内容类似,其中hwc部分的配置和配置的结果保持一致。当然,你也可以手动配置cfg.ini文件。

  1. [hwc]
  2. ak=******
  3. sk=******
  4. project_id=63kkdjkd******9dkst3tskdgi53
  5. [endpoint]
  6. cn-north-1=https://imagesearch.cn-north-1.myhuaweicloud.com
  7. cn-north-4=https://imagesearch.cn-north-4.myhuaweicloud.com
  8. ap-southeast-1=https://imagesearch.ap-southeast-1.myhuaweicloud.com

输入python3 unit_test.py执行单元测试

输入python3 run.py执行演示程序

运行结果

单元测试输出

  1. create_instance
  2. .
  3. check_user_instance is_788802
  4. https://imagesearch.cn-north-4.myhuaweicloud.com/v1/your_project_id/service/is_788802
  5. <Response [200]>
  6. .
  7. add_picture_by_local is_788802
  8. call add_picture: ./test_picture/43474673_7bb4465a86.jpg, length of file path 38
  9. .
  10. add_picture_by_url is_788802
  11. call add_picture: https://is-smirk.obs.cn-north-4.myhuaweicloud.com:443/flowers_recognition/train/11405573_24a8a838cc_n.jpg, length of file path 105
  12. .
  13. search_picture_by_local is_788802
  14. .
  15. search_picture_by_url is_788802
  16. .
  17. update_picture is_788802
  18. .
  19. check_picture is_788802
  20. .
  21. delete_picture is_788802
  22. .
  23. delete_instance is_788802
  24. .

Ran 10 tests in 18.108s

OK

演示程序输出

  1. ['hwc', 'endpoint']
  2. [('cn-north-1', 'https://imagesearch.cn-north-1.myhuaweicloud.com'), ('cn-north-4', 'https://imagesearch.cn-north-4.myhuaweicloud.com'), ('ap-southeast-1', 'https://imagesearch.ap-southeast-1.myhuaweicloud.com')]
  3. https://imagesearch.cn-north-1.myhuaweicloud.com
  4. your_AK
  5. https://imagesearch.cn-north-4.myhuaweicloud.com/v1/your_project_id/service/hwc_demo
  6. call add_picture: 151385301_153eacf6b5_n.jpg, length of file path 26
  7. add picture success: ./test_picture/train/151385301_153eacf6b5_n.jpg
  8. call add_picture: 200557977_bf24d9550b.jpg, length of file path 24
  9. add picture success: ./test_picture/train/200557977_bf24d9550b.jpg
  10. call add_picture: 6953297_8576bf4ea3.jpg, length of file path 22
  11. add picture success: ./test_picture/train/6953297_8576bf4ea3.jpg
  12. call add_picture: 134409839_71069a95d1_m.jpg, length of file path 26
  13. add picture success: ./test_picture/train/134409839_71069a95d1_m.jpg
  14. call add_picture: 510874382_f7e3435043.jpg, length of file path 24
  15. add picture success: ./test_picture/train/510874382_f7e3435043.jpg
  16. call add_picture: 15987457_49dc11bf4b.jpg, length of file path 23
  17. add picture success: ./test_picture/train/15987457_49dc11bf4b.jpg
  18. call add_picture: 164670176_9f5b9c7965.jpg, length of file path 24
  19. add picture success: ./test_picture/train/164670176_9f5b9c7965.jpg
  20. call add_picture: 2059172936_032ffc12aa.jpg, length of file path 25
  21. add picture success: ./test_picture/train/2059172936_032ffc12aa.jpg
  22. call add_picture: 2093263381_afd51358a3.jpg, length of file path 25
  23. add picture success: ./test_picture/train/2093263381_afd51358a3.jpg
  24. call add_picture: 3203779656_3580151ea4_m.jpg, length of file path 27
  25. add picture success: ./test_picture/train/3203779656_3580151ea4_m.jpg
  26. call add_picture: 13920113_f03e867ea7_m.jpg, length of file path 25
  27. add picture success: ./test_picture/train/13920113_f03e867ea7_m.jpg
  28. call add_picture: 5794835_d15905c7c8_n.jpg, length of file path 24
  29. add picture success: ./test_picture/train/5794835_d15905c7c8_n.jpg
  30. call add_picture: 146023167_f905574d97_m.jpg, length of file path 26
  31. add picture success: ./test_picture/train/146023167_f905574d97_m.jpg
  32. call add_picture: 486234138_688e0_n.jpg, length of file path 21
  33. add failed
  34. call add_picture: 486234138_688e0_n.jpg, length of file path 21
  35. call add_picture: 184682652_c927a49226_m.jpg, length of file path 26
  36. add picture success: ./test_picture/train/184682652_c927a49226_m.jpg
  37. call add_picture: 40410814_fba3837226_n.jpg, length of file path 25
  38. add picture success: ./test_picture/train/40410814_fba3837226_n.jpg
  39. call add_picture: 80846315_d997645bea_n.jpg, length of file path 25
  40. add picture success: ./test_picture/train/80846315_d997645bea_n.jpg
  41. call add_picture: 413815348_764ae83088.jpg, length of file path 24
  42. add picture success: ./test_picture/train/413815348_764ae83088.jpg
  43. call add_picture: 200557979_a16112aac1_n.jpg, length of file path 26
  44. add picture success: ./test_picture/train/200557979_a16112aac1_n.jpg
  45. call add_picture: 163978992_8128b49d3e_n.jpg, length of file path 26
  46. add picture success: ./test_picture/train/163978992_8128b49d3e_n.jpg
  47. call add_picture: 43474673_7bb4465a86.jpg, length of file path 23
  48. add picture success: ./test_picture/train/43474673_7bb4465a86.jpg
  49. call add_picture: 21652746_cc379e0eea_m.jpg, length of file path 25
  50. add picture success: ./test_picture/train/21652746_cc379e0eea_m.jpg
  51. call add_picture: 118974357_0faa23cce9_n.jpg, length of file path 26
  52. add failed
  53. call add_picture: 118974357_0faa23cce9_n.jpg, length of file path 26
  54. call add_picture: 154332674_453cea64f4.jpg, length of file path 24
  55. add picture success: ./test_picture/train/154332674_453cea64f4.jpg
  56. call add_picture: 162362896_99c7d851c8_n.jpg, length of file path 26
  57. add picture success: ./test_picture/train/162362896_99c7d851c8_n.jpg
  58. call add_picture: 160456948_38c3817c6a_m.jpg, length of file path 26
  59. add picture success: ./test_picture/train/160456948_38c3817c6a_m.jpg
  60. call add_picture: 5794839_200acd910c_n.jpg, length of file path 24
  61. add picture success: ./test_picture/train/5794839_200acd910c_n.jpg
  62. call add_picture: 3179751458_9646d839f6_n.jpg, length of file path 27
  63. add picture success: ./test_picture/train/3179751458_9646d839f6_n.jpg
  64. call add_picture: 2183357362_4b4da4b6b5.jpg, length of file path 25
  65. add picture success: ./test_picture/train/2183357362_4b4da4b6b5.jpg
  66. call add_picture: 141652526_2be95f21c3_n.jpg, length of file path 26
  67. add failed
  68. call add_picture: 141652526_2be95f21c3_n.jpg, length of file path 26
  69. call add_picture: 169371301_d9b91a2a42.jpg, length of file path 24
  70. add picture success: ./test_picture/train/169371301_d9b91a2a42.jpg
  71. call add_picture: 200288046_0032f322ff_n.jpg, length of file path 26
  72. add picture success: ./test_picture/train/200288046_0032f322ff_n.jpg
  73. call add_picture: 3450344423_63ba3190e3.jpg, length of file path 25
  74. add failed
  75. call add_picture: 3450344423_63ba3190e3.jpg, length of file path 25
  76. call add_picture: 11405573_24a8a838cc_n.jpg, length of file path 25
  77. add picture success: ./test_picture/train/11405573_24a8a838cc_n.jpg
  78. call add_picture: 2141413229_3f0425f972_n.jpg, length of file path 27
  79. add picture success: ./test_picture/train/2141413229_3f0425f972_n.jpg
  80. call add_picture: 3554620445_082dd0bec4_n.jpg, length of file path 27
  81. add failed
  82. call add_picture: 3554620445_082dd0bec4_n.jpg, length of file path 27
  83. call add_picture: 44079668_34dfee3da1_n.jpg, length of file path 25
  84. add picture success: ./test_picture/train/44079668_34dfee3da1_n.jpg
  85. call add_picture: 40411019_526f3fc8d9_m.jpg, length of file path 25
  86. add picture success: ./test_picture/train/40411019_526f3fc8d9_m.jpg
  87. call add_picture: 2609353769_dc3654f12f.jpg, length of file path 25
  88. add picture success: ./test_picture/train/2609353769_dc3654f12f.jpg
  89. call add_picture: 40410963_3ac280f23a_n.jpg, length of file path 25
  90. add picture success: ./test_picture/train/40410963_3ac280f23a_n.jpg
  91. [('40410814_fba3837226_n.jpg', 0.8202), ('40411019_526f3fc8d9_m.jpg', 0.7959), ('44079668_34dfee3da1_n.jpg', 0.7957), ('40410963_3ac280f23a_n.jpg', 0.7948), ('200288046_0032f322ff_n.jpg', 0.7419), ('184682652_c927a49226_m.jpg', 0.7291), ('5794839_200acd910c_n.jpg', 0.6738), ('163978992_8128b49d3e_n.jpg', 0.6732), ('200557977_bf24d9550b.jpg', 0.6675), ('134409839_71069a95d1_m.jpg', 0.6608)]
  92. [('162362896_99c7d851c8_n.jpg', 0.9541), ('163978992_8128b49d3e_n.jpg', 0.9534), ('21652746_cc379e0eea_m.jpg', 0.93), ('413815348_764ae83088.jpg', 0.8996), ('5794835_d15905c7c8_n.jpg', 0.8991), ('5794839_200acd910c_n.jpg', 0.8933), ('134409839_71069a95d1_m.jpg', 0.8806), ('169371301_d9b91a2a42.jpg', 0.8272), ('43474673_7bb4465a86.jpg', 0.78), ('44079668_34dfee3da1_n.jpg', 0.7677)]
  93. [('15987457_49dc11bf4b.jpg', 0.7605), ('151385301_153eacf6b5_n.jpg', 0.7571), ('80846315_d997645bea_n.jpg', 0.7416), ('11405573_24a8a838cc_n.jpg', 0.6828), ('146023167_f905574d97_m.jpg', 0.6674), ('13920113_f03e867ea7_m.jpg', 0.6639), ('160456948_38c3817c6a_m.jpg', 0.6396), ('510874382_f7e3435043.jpg', 0.6251)]
  94. [('2141413229_3f0425f972_n.jpg', 1.0), ('2093263381_afd51358a3.jpg', 0.6334)]

演示程序会在华北-北京4自动创建名字为hwc_id_demo的图像搜索服务实例,将test_picture/train下的图片添加到实例中。

然后测试test_picture/test下图片作为搜索图片的搜索结果,在该Demo中过滤了相似度小于0.6的返回结果。

6 体验插件的魅力

华为云devkit已上线:Toolkit-华为云

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/298193
推荐阅读
相关标签
  

闽ICP备14008679号