diff --git a/README_CN.md b/README_CN.md
index 2f3ab2c..aab3a0c 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -106,7 +106,7 @@ export LD_LIBRARY_PATH=$MINDSPORE_LIB_PATH:${LD_LIBRARY_PATH}
### 开发者教程
- [GRPC接口使用说明](docs/GRPC.md)
-- [RESTful接口使用说明](docs/RESTful.md)
+- [使用RESTful接口](docs/RESTful.md)
- [模型配置接口使用说明](docs/MODEL.md)
有关安装指南、教程和API的更多详细信息,请参阅[用户文档](https://gitee.com/mindspore/serving/tree/master/docs)。
diff --git a/docs/RESTful.md b/docs/RESTful.md
index 1a9acb6..1cf6b33 100644
--- a/docs/RESTful.md
+++ b/docs/RESTful.md
@@ -4,11 +4,10 @@
-- [使用RESTful 接口](#restful-接口使用说明)
+- [使用RESTful 接口](#使用restful-接口)
- [概述](#概述)
- [请求方式](#请求方式)
- [请求输入格式](#请求输入格式)
- - [支持的类型总结如下:](#支持的类型总结如下)
- [请求应答格式](#请求应答格式)
@@ -25,9 +24,7 @@ MindSpore Serving支持`GPRC`和`RESTful`两种请求方式。本章节介绍`RE
与通过`master.start_grpc_server("127.0.0.1", 5500)`启动`GRPC`服务不同的是,`RESTful`服务需要通过`master.start_restful_server("0.0.0.0", 1500)`方式来启动。
-### 特殊说明
-
-`RESTful`请求目前仅支持`Ascend`硬件,不支持`GPU`和`CPU`等硬件。
+>`RESTful`请求目前仅支持`Ascend`硬件,不支持`GPU`和`CPU`等硬件。
### 请求方式
@@ -69,13 +66,13 @@ RESTful支持`Json`请求格式,`key`固定为`instances`,`value`:表示多
- `value`:表示具体的值。当前支持的`value`类型:
- - 标量:`str`、`bytes`、`int`、`float`、`bool`;
+ - 标量:`str`、`bytes`、`int`、`float`、`bool`。
- `bytes`:通过`base64`编码方式支持。
+ `bytes`:通过`base64`编码方式支持。
- 张量:`int`、`float`、`bool`。
- 张量通过数组格式表示数据和维度信息。
+ 张量通过数组格式表示数据和维度信息。
`Json`中支持的`int`类型:是`int32`表示的范围,`float`类型:是`float32`表示的范围。
@@ -122,11 +119,11 @@ RESTful支持`Json`请求格式,`key`固定为`instances`,`value`:表示多
`bytes`类型需要通过`base64`编码进行表示。`base64`除了支持`bytes`类型,也支持表示其他标量和张量,此时需要通过`type`指定数据类型,通过`shape`指定维度信息。
-- `type`:可选,如果不指定,默认为`bytes`;
+- `type`:可选,如果不指定,默认为`bytes`。
- 支持`int8`、`int16`、`int32`、`int64`、`uint8`、`uint16`、`uint32`、`uint64`、`fp16`、`fp32`、`fp64`、`bool`、`str`、`bytes`.
+ 支持`int8`、`int16`、`int32`、`int64`、`uint8`、`uint16`、`uint32`、`uint64`、`fp16`、`fp32`、`fp64`、`bool`、`str`、`bytes`。
-- `shape`:可选,如果不指定,默认为`[1]`.
+- `shape`:可选,如果不指定,默认为`[1]`。
例子:
@@ -146,16 +143,16 @@ RESTful支持`Json`请求格式,`key`固定为`instances`,`value`:表示多
其中`AQACAAIAAwADAAQA`:是`[[1,1],[2,3],[3,4]]`经过`base64`编码字后的字符串。
-#### 支持的类型总结如下
+**支持的类型总结如下:**
-| 支持的类型 | 例子 | 备注 |
-| :----------------------------------------------------------: | ------------------------------------------------------------ | ---------------------------------- |
-| `int` | 1,[1,2,3,4] | 默认`int32`表示范围 |
-| `float` | 1.0,[[1.2, 2.3], [3.0, 4.5]] | 默认`float32`表示范围 |
-| `bool` | true,false,[[true],[false]] | `bool`类型 |
-| `string` | "hello"或者
{"b64":"aGVsbG8=", "type":"str"} | 直接表示或者指定`type`方式表示 |
-| `bytes` | {"b64":"AQACAAIAAwADAAQA"} 或者
{"b64":"AQACAAIAAwADAAQA", "type":"bytes"} | 如果不填`type`,默认为`bytes` |
-| `int8`,`int16`,`int32`,`int64`,`uint8`,`uint16`,`uint32`,`uint64` `float16`,`float32`,`bool` | {"b64":"AQACAAIAAwADAAQA", "type":"int16", "shape":[3,2]} | 利用base64编码,表示指定type的数据 |
+| 支持的类型 | 例子 | 备注 |
+| :------------------------------------------------------------------------------------------: | ------------------------------------------------------------------------------ | ---------------------------------- |
+| `int` | 1,[1,2,3,4] | 默认`int32`表示范围 |
+| `float` | 1.0,[[1.2, 2.3], [3.0, 4.5]] | 默认`float32`表示范围 |
+| `bool` | true,false,[[true],[false]] | `bool`类型 |
+| `string` | "hello"或者
{"b64":"aGVsbG8=", "type":"str"} | 直接表示或者指定`type`方式表示 |
+| `bytes` | {"b64":"AQACAAIAAwADAAQA"} 或者
{"b64":"AQACAAIAAwADAAQA", "type":"bytes"} | 如果不填`type`,默认为`bytes` |
+| `int8`,`int16`,`int32`,`int64`,`uint8`,`uint16`,`uint32`,`uint64` `float16`,`float32`,`bool` | {"b64":"AQACAAIAAwADAAQA", "type":"int16", "shape":[3,2]} | 利用base64编码,表示指定type的数据 |
### 请求应答格式
@@ -181,7 +178,7 @@ RESTful支持`Json`请求格式,`key`固定为`instances`,`value`:表示多
1. 多实例请求后,如果多实例全部成功处理,则响应格式如下:
- 例子:`lenet`请求识别数字`0`和数字`1`
+ 例子:`lenet`请求识别数字`0`和数字`1`。
```json
{
@@ -198,7 +195,7 @@ RESTful支持`Json`请求格式,`key`固定为`instances`,`value`:表示多
2. 如果部分实例出错,则响应格式如下:
- 例子:`lenet`请求识别数字`0`和一个错误数字图片
+ 例子:`lenet`请求识别数字`0`和一个错误数字图片。
```json
{
@@ -215,27 +212,27 @@ RESTful支持`Json`请求格式,`key`固定为`instances`,`value`:表示多
3. 如果请求全部失败,则响应格式如下:
- 例子:`lenet`请求识别两张错误数字图片为例
+ 例子:`lenet`请求识别两张错误数字图片为例。
-```json
-{
- "instances":[
- {
- "error_msg":"Preprocess Failed"
- },
- {
- "error_msg":"Time out"
- }
- ]
-}
-```
+ ```json
+ {
+ "instances":[
+ {
+ "error_msg":"Preprocess Failed"
+ },
+ {
+ "error_msg":"Time out"
+ }
+ ]
+ }
+ ```
4. 出现系统性或者其他解析等错误,则返回格式:
- 例子:`lenet`传入非法`Json`字符串
+ 例子:`lenet`传入非法`Json`字符串。
-```json
-{
- "error_msg":"Parse request failed"
-}
-```
+ ```json
+ {
+ "error_msg":"Parse request failed"
+ }
+ ```
diff --git a/mindspore_serving/ccsrc/master/restful/http_process.cc b/mindspore_serving/ccsrc/master/restful/http_process.cc
index 524e9b8..25b42a4 100644
--- a/mindspore_serving/ccsrc/master/restful/http_process.cc
+++ b/mindspore_serving/ccsrc/master/restful/http_process.cc
@@ -412,8 +412,6 @@ Status RestfulService::ParseItem(const json &value, ProtoTensor *const pb_tensor
size_t shape_size = std::accumulate(shape.begin(), shape.end(), 1LL, std::multiplies());
size_t type_size = pb_tensor->GetTypeSize(type);
pb_tensor->resize_data(shape_size * type_size);
- MSI_LOG_DEBUG << "shape size:" << shape_size << "; type size:" << type_size
- << "; data size:" << shape_size * type_size;
}
status = CheckObjTypeMatchShape(type, shape);
@@ -457,8 +455,6 @@ Status RestfulService::ParseItem(const json &value, ProtoTensor *const pb_tensor
size_t shape_size = std::accumulate(shape.begin(), shape.end(), 1LL, std::multiplies());
size_t type_size = pb_tensor->GetTypeSize(data_type);
pb_tensor->resize_data(shape_size * type_size);
- MSI_LOG_DEBUG << "shape size:" << shape_size << "; type size:" << type_size
- << "; data size:" << shape_size * type_size;
}
if (type_format == HTTP_DATA_OBJ) {
@@ -518,7 +514,6 @@ Status RestfulService::GetArrayData(const json &js, size_t data_index, HTTP_DATA
ProtoTensor *const request_tensor) {
Status status(SUCCESS);
size_t element_nums = js.size();
- MSI_LOG_DEBUG << "element nums:" << element_nums << "; data index:" << data_index;
if (type != HTTP_DATA_OBJ) {
for (size_t k = 0; k < element_nums; k++) {
auto &json_data = js[k];
@@ -561,8 +556,6 @@ Status RestfulService::GetScalarByType(DataType type, const json &js, size_t ind
if (type == kMSI_Unknown) {
return INFER_STATUS_LOG_ERROR(INVALID_INPUTS) << "data type is unknown";
}
- MSI_LOG_DEBUG << "data type:" << type << " ;real data type:" << request_tensor->data_type()
- << " ;data index:" << index;
switch (type) {
case kMSI_Bool:
status = GetScalarData(js, index, false, request_tensor);
@@ -740,7 +733,6 @@ Status RestfulService::ParseRequest(const std::shared_ptr &restf
return INFER_STATUS_LOG_ERROR(FAILED) << "restful reqeust only support instances mode";
}
- PrintRequest(request);
return status;
}
@@ -755,9 +747,6 @@ Status RestfulService::ParseReqCommonMsg(const std::shared_ptr &
request->mutable_servable_spec()->set_name(request_ptr->model_name_);
request->mutable_servable_spec()->set_version_number(request_ptr->version_);
request->mutable_servable_spec()->set_method_name(request_ptr->service_method_);
- MSI_LOG_INFO << "Restful req, model name:" << request->servable_spec().name();
- MSI_LOG_INFO << "Version number:" << request->servable_spec().version_number();
- MSI_LOG_INFO << "Method name:" << request->servable_spec().method_name();
return status;
}
@@ -882,7 +871,6 @@ Status RestfulService::ParseScalar(const ProtoTensor &pb_tensor, size_t index, j
if (data_type == kMSI_Unknown) {
return INFER_STATUS_LOG_ERROR(FAILED) << "Data type is unknown";
}
- MSI_LOG_DEBUG << "Data type:" << data_type << "; index:" << index;
switch (data_type) {
case kMSI_Bool:
status = ParseScalarData(pb_tensor, false, index, js);
@@ -895,11 +883,9 @@ Status RestfulService::ParseScalar(const ProtoTensor &pb_tensor, size_t index, j
break;
case kMSI_Int32:
status = ParseScalarData(pb_tensor, false, index, js);
- MSI_LOG_INFO << "parse int32:" << js->get();
break;
case kMSI_Int64:
status = ParseScalarData(pb_tensor, false, index, js);
- MSI_LOG_INFO << "parse int64:" << js->get();
break;
case kMSI_Uint8:
status = ParseScalarData(pb_tensor, false, index, js);
@@ -959,7 +945,6 @@ Status RestfulService::ParseScalarData(const ProtoTensor &pb_tensor, bool is_byt
pb_tensor.get_bytes_data(index, &ptr, &length);
value.resize(length);
memcpy_s(value.data(), length, reinterpret_cast(ptr), length);
- MSI_LOG_INFO << "Parse string value:" << value;
*js = value;
} else {
auto str_nums = pb_tensor.bytes_data_size();
@@ -977,7 +962,6 @@ Status RestfulService::ParseScalarData(const ProtoTensor &pb_tensor, bool is_byt
pb_tensor.get_bytes_data(index, &ptr, &length);
value.resize(length);
memcpy_s(value.data(), length, reinterpret_cast(ptr), length);
- MSI_LOG_DEBUG << "bytes type, origin str:" << value;
auto target_size = GetB64TargetSize(length);
std::vector buffer(target_size, 0);
@@ -987,7 +971,6 @@ Status RestfulService::ParseScalarData(const ProtoTensor &pb_tensor, bool is_byt
<< "reply bytes, size is not matched, expected size:" << target_size << ", encode size:" << size;
}
std::string str = GetString(buffer.data(), buffer.size());
- MSI_LOG_DEBUG << "bytes type, decoded str:" << str;
(*js)[kB64] = str;
}
}
@@ -1059,7 +1042,6 @@ Status RestfulService::ParseReply(const PredictReply &reply, json *const out_jso
return INFER_STATUS_LOG_ERROR(FAILED) << "restful request only support instance mode";
}
- PrintReply(reply);
return status;
}
@@ -1136,7 +1118,7 @@ void RestfulService::FadeReply(const proto::PredictRequest &request, proto::Pred
MSI_LOG_ERROR << "only support two kind type";
}
MSI_LOG_INFO << "End";
-} // namespace serving
+}
void RestfulService::PrintRequest(const proto::PredictRequest *const request) {
MSI_LOG_INFO << "=============start print quest==================";