After a model is prepared, you can deploy it as a batch service. The Service Deployment > Batch Services page lists all batch services. You can enter a service name in the search box in the upper right corner and click to query the service.
Parameter |
Description |
---|---|
Model and Version |
Select the model and version that are in the Normal state. |
Input Path |
Select the OBS directory where the data is to be uploaded. Select a folder or a .manifest file. For details about the specifications of the .manifest file, see Manifest File Specifications. NOTE:
|
Request Path |
API URI of a batch service. |
Mapping Relationship |
If the model input is in JSON format, the system automatically generates the mapping based on the configuration file corresponding to the model. If the model input is other file, mapping is not required. Automatically generated mapping file. Enter the field index corresponding to each parameter in the CSV file. The index starts from 0. Mapping rule: The mapping rule comes from the input parameter (request) in the model configuration file config.json. When type is set to string/number/integer/boolean, you are required to set the index parameter. For details about the mapping rule, see Example Mapping. The index must be a positive integer starting from 0. If the value of index does not comply with the rule, this parameter is ignored in the request. After the mapping rule is configured, the corresponding CSV data must be separated by commas (,). |
Output Path |
Select the path for saving the batch prediction result. You can select the empty folder that you create. |
Specifications |
The system provides available compute resources matching your model. Select an available resource from the drop-down list. |
Instances |
Set the number of instances for the current model version. If you set Instances to 1, the standalone computing mode is used. If you set Instances to a value greater than 1, the distributed computing mode is used. Select a computing mode based on the actual requirements. |
Environment Variable |
Set environment variables and inject them to the container instance. To ensure data security, do not enter sensitive information, such as plaintext passwords, in environment variables. |
You can go to the batch service list to view the basic information about the batch service. In the batch service list, after the status of the newly deployed service changes from Deploying to Running, the service is deployed successfully.
Batch services of the inference platform support the manifest file. The manifest file describes the input and output of data.
{"source": "<obs path>/test/data/1.jpg"} {"source": "https://infers-data.obs.xxx.com:443/xgboosterdata/data.csv?AccessKeyId=2Q0V0TQ461N26DDL18RB&Expires=1550611914&Signature=wZBttZj5QZrReDhz1uDzwve8GpY%3D&x-obs-security-token=gQpzb3V0aGNoaW5hixvY8V9a1SnsxmGoHYmB1SArYMyqnQT-ZaMSxHvl68kKLAy5feYvLDM..."}
Example output manifest file
OBS bucket/directory name ├── test-bucket │ ├── test │ │ ├── infer-result-0.manifest │ │ ├── infer-result │ │ │ ├── 1.jpg_result.txt │ │ │ ├── 2.jpg_result.txt
{"source": "<obs path>/obs-data-bucket/test/data/1.jpg", "inference-loc": "<obs path>/test-bucket/test/infer-result/1.jpg_result.txt"} {"source ": "https://infers-data.obs.xxx.com:443/xgboosterdata/2.jpg?AccessKeyId=2Q0V0TQ461N26DDL18RB&Expires=1550611914&Signature=wZBttZj5QZrReDhz1uDzwve8GpY%3D&x-obs-security-token=gQpzb3V0aGNoaW5hixvY8V9a1SnsxmGoHYmB1SArYMyqnQT-ZaMSxHvl68kKLAy5feYvLDMNZWxzhBZ6Q-3HcoZMh9gISwQOVBwm4ZytB_m8sg1fL6isU7T3CnoL9jmvDGgT9VBC7dC1EyfSJrUcqfB...", "inference-loc": "obs://test-bucket/test/infer-result/2.jpg_result.txt"}
The following example shows the relationship between the configuration file, mapping rule, CSV data, and inference request.
Assume that the apis parameter in the configuration file used by your model is as follows:
[ { "protocol": "http", "method": "post", "url": "/", "request": { "type": "object", "properties": { "data": { "type": "object", "properties": { "req_data": { "type": "array", "items": [ { "type": "object", "properties": { "input_1": { "type": "number" }, "input_2": { "type": "number" }, "input_3": { "type": "number" }, "input_4": { "type": "number" } } } ] } } } } } } ]
At this point, the corresponding mapping relationship is shown below. The ModelArts management console automatically resolves the mapping relationship from the configuration file. When calling a ModelArts API, write the mapping relationship by yourself according to the rule.
{ "type": "object", "properties": { "data": { "type": "object", "properties": { "req_data": { "type": "array", "items": [ { "type": "object", "properties": { "input_1": { "type": "number", "index": 0 }, "input_2": { "type": "number", "index": 1 }, "input_3": { "type": "number", "index": 2 }, "input_4": { "type": "number", "index": 3 } } } ] } } } } }
The data for inference, that is, the CSV data, is in the following format. The data must be separated by commas (,).
5.1,3.5,1.4,0.2 4.9,3.0,1.4,0.2 4.7,3.2,1.3,0.2
Depending on the defined mapping relationship, the inference request is shown below. The format is similar to the format used by the real-time service.
{ "data": { "req_data": [{ "input_1": 5.1, "input_2": 3.5, "input_3": 1.4, "input_4": 0.2 }] } }