This topic describes how to upload images to Alibaba Cloud Image Search.
Background information
Image Search allows you to use the following methods to upload images: Use the Image Search API or the SDK, or use the OSSImport tool.
- If you need to upload only a small number of images, we recommend that you use the Image Search API or SDK. For more information, see Add images.
- If you are an enterprise user or need to upload a large number of images, we recommend that you use the OSSImport tool. For more information, see Procedure.
Introduction to the OSSImport tool
OSSImport is a tool that is provided by Alibaba Cloud Object Storage Service (OSS) to migrate data to OSS buckets. You can deploy OSSImport on your Elastic Compute Service (ECS) instance in the cloud or on your local server to migrate data that is stored locally or in another cloud storage system to OSS.
- Provides a quick method for you to update images to the image search engine.
- Allows the same OSS bucket to be used by different projects, such as development projects and online projects.
- Provides an easy method for you to organize and manage different image sources based on your business requirements.
- Provides an effective method for you to manage complex projects, such as development projects and user acceptance testing (UAT) projects.
- Allows you to upload a large number of images at a time. The uploaded images can be reused in different scenarios. This makes full use of the network bandwidth.
- Allows you to standardize the management of image search services.
Image limits
- The size of each image to be uploaded cannot exceed 2 MB.
- The length and width of each image must range from 100 pixels to 4,096 pixels.
Procedure
Step 1: Download the OSSImport tool
- If the size of the data to be migrated is smaller than 30 TB, we recommend that you use the standalone mode. You can deploy OSSImport on a machine that can access the data to be migrated and can access the OSS service. You can use the following link to download the OSSImport tool: OSSImport.
- If the size of the data to be migrated is larger than 30 TB, we recommend that you use the distributed mode. You can deploy OSSImport on multiple machines that can access the data to be migrated and can access the OSS service. You can use the following link to download the OSSImport tool: OSSImport.
Step 2: Activate the OSS service
For more information, see Activate OSS.
Step 3: Create an OSS bucket
Step 4: Import the images that are specified in the increment.meta file
{"OperationType": "ADD","ProductId": "1000","PicName": "girl_cloth1.jpg","CategoryId": 0,"IntAttr": 0,"StrAttr": "value1","CustomContent": "k1:v1,k2:v2,k3:v3","Region": "20,40,60,80"}
{"OperationType": "ADD","ProductId": "1000","PicName": "girl_cloth2.jpg","CategoryId": 0,"IntAttr": 0,"StrAttr": "value2","CustomContent": "k1:v1,k2:v2,k3:v3","Region": "20,40,60,80"}
{"OperationType": "ADD","ProductId": "1001","PicName": "girl_cloth3.jpg","CategoryId": 1,"CustomContent": "k1:v1,k2:v2,k3:v3"}
{"OperationType": "ADD","ProductId": "1002","PicName": "girl_cloth4.jpg","CategoryId": 0,"CustomContent": "k1:v1,k2:v2,k3:v3","Crop": false}
{"OperationType": "ADD","ProductId": "1003","PicName": "girl_cloth7.jpg","CustomContent": "https://www.aliyun.com/imagesearch/girl_cloth7.jpg"}
{"OperationType": "ADD","ProductId": "1003","PicName": "girl_cloth6.jpg","CustomContent": "k1:v1,k2:v2,k3:v3"}
{"OperationType": "DELETE","ProductId": "1004","PicName": "fengyi.jpg"}
{"OperationType": "DELETE","ProductId": "1005"}
Parameter | Type | Required | Description |
---|---|---|---|
OperationType | String | Yes | The type of the operation. Valid values:
|
ProductId | String | Yes | The unique ID of the image. |
PicName | String | Yes | The name of the image. The name of the image that is stored in the OSS bucket.
Note Each row contains at most one image name. If one image ID corresponds to multiple
image names, you must write multiple rows.
|
CategoryId | Integer | No | The category of the image. For more information, see Category reference.
|
CustomContent | String | Yes | The user-defined content. The value can be up to 4,096 characters in length. |
IntAttr | Integer | No | The integer attribute. The attribute can be used to filter images when you search for images. |
StrAttr | String | No | The string attribute. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. |
Crop | Boolean | No | Specifies whether to recognize the subject in the image and search for images based
on the recognized subject. Valid values: true and false. Default value: true.
Note For cloth image searches, this parameter does not take effect. By default, the system
searches for images based on the entire image.
|
Region | String | No | The subject area in the image. The subject area is in the format of x1,x2,y1,y2 . x1 and y1 represent the upper-left corner pixel. x2 and y2 represent the lower-right
pixel.
Note
|
Step 5: Grant Image Search the permission to access OSS
Image Search provides the batch operation feature based on OSS. You must use Security Token Service (STS) to grant your Image Search account permissions to access OSS.
- Create a RAM role.
- Create a policy.
- Grant permissions.
Step 6: Upload images
Result
- If the import task is in the Failed state, click Show Import History to view the details.
For more information, see General.
- If the images are uploaded as expected, click the instance ID. On the page that appears,
click the Search by Image tab. On this tab, perform an image search test.