Help Center> ImageSearch> Getting Started> Getting Started with ImageSearch
Updated on 2022-02-22 GMT+08:00

Getting Started with ImageSearch

For details about the concept, advantages, functions, and application scenarios of ImageSearch, see the Service Overview.

The procedure of using ImageSearch is as follows:

Scenario Description

To help you quickly get familiar with ImageSearch, this document describes how to use the general image search function of ImageSearch to search for images that match the local image from the image library.

In this example, select the local image 1.jpg. Use ImageSearch to create an instance, select the general image search service model, and import the existing image library to an OBS bucket. After the instance is executed, the information about the images that match the local image 1.jpg is outputted through instance test.

Step 1: Applying for a Service

The procedure is as follows:

  1. Log in to HUAWEI CLOUD. If you do not have a HUAWEI CLOUD account, register on the registration page as prompted.
  2. On the top of the HUAWEI CLOUD page, choose Products > Enterprise Intelligence > ImageSearch. The ImageSearch product page is displayed.
  3. On the ImageSearch page, click Try Now. The ImageSearch management console is displayed.
  4. The Dashboard page displays the total number of API calls in the latest week and the status of all instances. See Figure 1.
    Figure 1 Dashboard

Step 2: Creating an Instance

Before using ImageSearch, create an instance and select a service model for search.

  1. On the Dashboard or Instance Management page, create an instance.

    Creating an instance on the Instance Management page is used as an example. On the Instance Management page, click Create Instance. The Create Instance page is displayed. Refer to the following table to understand the parameters for creating an instance.

    Figure 2 shows the instance parameters.

    Figure 2 Creating an instance
    Table 1 Parameters for creating an instance



    Instance Name

    Name of the instance to be created. The value contains only lowercase letters, digits, hyphens (-), and underscores (_) and must start with a lowercase letter.

    Service Model

    Service models include general image search, copyrighted image recommendation, landmark search, and image copyright protection.

    • General image search: searches for images of similar content or categories in the image library.
    • Copyrighted image recommendation: searches for and recommends the same or similar copyrighted images in the copyrighted photographic image library.
    • Landmark search: searches for landmarks.
    • Image copyright protection: quickly recognizes infringed images from the large image library.

    Customize Tag

    You can add image tags to facilitate image filtering when adding or querying images. A maximum of 10 tags can be added.

    For example, when creating an instance, add a custom tag scenery. After the instance is created, upload an image on the Add Image page, for example, an image of the sky. The value of the scenery tag can be set to sky. After the image is added, you can upload the image to be searched on the Search Image page and enter the tag value sky in the scenery field. In this way, only the image whose tag value is sky is returned in the search result.

    You can set custom tags to filter images that are found. If you do not set a custom tag when creating an instance, you can choose Instance Management > Instance Details to set one.


    Description of the created instance.

    You can purchase a discount package. The package quota is deducted when you start to use the service.

  2. Click Create Now. The created instance is displayed on the Instance Management page. See Figure 3.
    Figure 3 Instance management

Step 3: Offline Import

ImageSearch supports offline import. You can import images in batches to an instance. You can only import images from Object Storage Service (OBS) to ImageSearch. Before using this function, upload the images to OBS.

1. Preparations before offline data import

  1. Before using OBS, you need to subscribe to it. For details, see Logging In to OBS Console in the Object Storage Service Console Operation Guide.
  2. To store data in OBS, create a bucket first. A bucket is a container used to store objects in OBS. For details about how to create a bucket, see Creating a Bucket in the Object Storage Service Console Operation Guide.

    Information about the created OBS bucket:

    Region: CN North-Beijing1

    Bucket Name: obs-5daf

    Storage Class: Standard

    Bucket Policy: Private

    Retain the default value of Bucket Policy.

  3. Upload files to the OBS bucket. For details about how to upload file, see Uploading a File in the Object Storage Service Console Operation Guide.

2. Executing the offline import task

The offline import function can be implemented by using OBS buckets or list files.

  • To import data from an OBS bucket, you need to provide the OBS path where the data is stored.
  • To import data with a list file, you need to provide a JSON file with the extension .batch.

Importing data from an OBS bucket

To implement offline import with OBS, grant the permission to access OBS objects to the ImageSearch service account.

  1. On the Instance Management page, click Offline Import in the Operation column. The Offline Import page is displayed.
  2. Select the OBS bucket where data is stored, for example, obs-5daf. Click Authorize. When the button becomes unavailable, the OBS authorization is complete.
  3. Click OK to create an offline import task. See Figure 4.
    Figure 4 Importing data from an OBS bucket
  4. If you select Specify Directory/File, enter a folder in the OBS bucket and import data from the specified directory. For example, import data from the data directory in the obs-5daf bucket. See Figure 5.
    Figure 5 Importing data from an OBS directory

Importing data with a list file

ImageSearch can obtain the information about the images to be imported from a list file. The file list stores the content related to the offline import task. You can customize tags for the images. The list file format must comply with the following rules:

  1. The file name extension must be .batch.
  2. The list file needs to be stored in the bucket where the data is stored. There are no special requirements on the directories in the bucket. Figure 6 shows offline import with a list file.
    Figure 6 Importing data with a list file
  3. The content format of the list file is as follows:
    • Each line corresponds to an image. See Example list file.
    • The images are in JSON format. For details about the fields, see Table 2.
      Table 2 Parameters in the list file








      Operation type. The value can be add, indicating adding an image.




      Image URL. The URL is used as the ID of an indexed image in the gallery, as well as the address for downloading the image. Currently, images can be downloaded only from OBS in the region where ImageSearch is located.




      Custom image tag. A maximum of 10 tags are supported.

    • Example list file
      {"operation":"add","path":"", "tags":{"tag1":"v1"}}
      {"operation":"add","path":"data/1.jpg", "tags":{"my_tag1":"v1","my_tag2":"v2","my_tag3":"v3"}}

3. Viewing the offline import tasks

On the Instance Management page, click Offline Import in the Operation column. On the Offline Import page that is displayed, view the offline import tasks.

The offline import status can be Initializing, Running, or Successful. Initializing indicates that the task is being prepared. Running indicates that the image is being imported to the instance. Successful indicates that the offline import task is completed,

as shown in Figure 7.

Figure 7 Viewing the offline import tasks

Step 4: Testing the Instance

  1. On the Instance Management page, click Test in the Operation column. On the Test page that is displayed, add an image and search for the similar images.

    This example shows how to search for images that are similar to image 1.jpg in the OBS bucket.

  2. On the Search Image tab page, set Search Method to Local, select image 1.jpg, and click Search, as shown in Figure 8.
    Figure 8 Testing an instance
  3. In the Response Result area, the matching result between the imagesearch-test instance and the local image 1.jpg in the obs-5daf bucket is displayed. For details about the response parameters, see the response parameter description.
    Figure 9 shows the response result.
    Figure 9 Response result

Step 5: Deleting the Instance

If an instance is no longer needed after the instance is run, you can delete it to avoid wasting resources or occupying the quota.

An instance cannot be deleted if it has any offline import task that has not been completed.

Deleted instance cannot be recovered. Exercise caution when performing this operation.

  1. In the left navigation pane, click Instance Management. The Instance Management page is displayed.
  2. Locate the row that contains test1, and choose Mode > Delete in the Operation column.
  3. In the dialog box that is displayed, click OK to delete the instance.