Add images

更新时间:
复制 MD 格式

This topic describes four methods to add images to Image Search: using the console (for feature evaluation), calling an API, using an SDK (for small-scale, real-time incremental data operations), and performing a batch operation (for large-scale offline data operations involving millions of images). Choose the method that best suits your needs.

Note

For more product details or technical support, click Online Consulting or contact us through our DingTalk group: 35035130.

Prerequisites

You have created an instance. For more information, see Activate Image Search.

Console

  1. Log in to the Image Search console.

  2. In the left-side navigation pane, select a service type. This topic uses product image search as an example.

    For more information about service types, see Services.

  3. Click the target instance.

    In the instance list, click the target instance's instance ID.

  4. Choose Add Image.

    Configure the parameters and click OK. After you successfully submit the image, the raw JSON response appears on the right. A successful response includes code: 0, message: "success", and picInfo, which contains the categoryId (category ID) and region (coordinates of the subject area). The following table describes the parameters.

    Parameter

    API parameter

    Description

    Required

    Product ID

    ProductId

    The unique ID of the product. It can be up to 256 characters long.

    Yes

    Image name

    PicName

    The name of the image. It can be up to 256 characters long.

    Note

    A combination of the product ID and image name uniquely identifies an image.

    Important

    If you add an image with the same product ID and image name as an existing image, the new image overwrites the existing one, regardless of whether the image content is different.

    Yes

    Upload image

    PicContent

    The Base64-encoded image content. The image must meet the following requirements:

    • The image size cannot exceed 4 MB.

    • Supported formats: PNG, JPG, JPEG, BMP, GIF, WEBP, TIFF, and PPM.

    • The transfer timeout must not exceed 5 seconds.

    • For product image search, generic image search, furniture and household supply image search, and industrial hardware image search, the image width and height must be between 100 and 4,096 pixels.

    • For brand image search, the image width and height must be between 200 and 4,096 pixels.

    • For cloth image search, the image width and height must be between 448 and 4,096 pixels.

    • The image cannot contain rotation information.

    Important

    This parameter requires the Base64-encoded image content. If you want to add an image by URL, see the sample code for the SDK's Add operation.

    Yes

    Image Subject Recognition

    Crop

    Enables or disables subject recognition.

    Yes

    Recognition method

    N/A

    The method for subject recognition:

    • Automatic Recognition: The system automatically recognizes the subject and uses the recognized subject for the search. The response includes the recognition result.

    • Define the main subject area: This enables subject recognition and lets you define the subject area. If you do not define a subject area, the service searches the entire image.

    Yes

    Image category

    CategoryId

    The category of the image. You can set a category when you add an image.

    Note
    1. The product image search service has a built-in automatic category prediction feature. If you do not specify this parameter, Image Search automatically predicts the image category and indexes it. The predicted category is returned in the response.

    2. During a search, the product image search service also predicts the category of the query image and searches within that category to narrow the scope and improve accuracy.

    3. For the product image search service, we recommend using the default automatic category prediction feature.

    4. For cloth image search, brand image search, generic image search, copyright, industrial hardware image search, and furniture and household supply image search, the system sets the category to 88888888 regardless of whether you specify a category.

    5. For a list of categories, see Category reference.

    Important

    If you specify a category when adding an image, you must also specify the same category when searching. Otherwise, a search using the original image might fail to find it.

    No

    Custom content

    CustomContent

    User-defined content, up to 4,096 characters long.

    Note

    The search results include this value. You can use this field to store an image URL or other additional information to link the image to your business data.

    No

    Integer attribute

    IntAttr

    An integer attribute used to filter search results. This attribute is included in the search results.

    Note

    Use integer attributes in a filter condition to filter search results. For more information, see Filter condition.

    No

    Integer attribute 2

    IntAttr2

    No

    Integer attribute 3

    IntAttr3

    No

    Integer attribute 4

    IntAttr4

    No

    String attribute

    StrAttr

    A string attribute, up to 128 characters long. Used to filter search results.

    Note
    • Use string attributes in a filter condition to filter search results. For more information, see Filter condition.

    • Special characters such as \, ¥, $, &, and % are not supported.

    No

    String attribute 2

    StrAttr2

    No

    String attribute 3

    StrAttr3

    No

    String attribute 4

    StrAttr4

    No

  5. Click OK to add the image.

API

You can call the operation by sending HTTP or HTTPS requests. You must authenticate each request with a signature and format the request body as specified. The default queries per second (QPS) for adding images by API is 5. For more information, see AddImage.

SDK

Image Search provides SDKs for multiple programming languages. Using an SDK eliminates the need to handle tedious tasks like signature verification and request body formatting. This method is recommended for adding a small number of images in real time. The QPS limit is 1 for instances with a capacity of 100,000 images and 5 for all other instance types. For more information, see the Add operation.

Batch operations

Image Search integrates with Alibaba Cloud Object Storage Service (OSS), letting you import images in batches from an OSS bucket with a few simple steps. This method is suitable for large-scale (millions of images) offline data import. For more information, see Perform batch operations.