model_server.utils.prediction_utils
create_predict_request
Creates a PredictRequest proto
Arguments:
input_tensorproto_dict
dict - A dictionary with key (typically input tensor name string) and value as TensorProto.name
str - Optional model name. Default Noneversion
str - Optional model version. Default None
Returns:
PredictRequest proto
create_predict_response
Creates a PredictResponse proto
Arguments:
input_tensorproto_dict
dict - A dictionary with key (typically output tensor name string) and value as TensorProto.name
str - Optional model name. Default Noneversion
str - Optional model version. Default None
Returns:
PredictResponse proto
model_server.utils.tensor_utils
create_tensor_proto
Create a TensorProto from numpy array.
Arguments:
array
np.ndarray - The numpy array to convert to TensorProtoshape
tuple - Optional shape of the array to reshape it to. If not given, it is inferred from the numpy array. Default Nonedtype
str - Optional dtype to convert the array to. Refer tensor.proto for supported datatypes. If not given, it is inferred from the numpy array. Default None.name
str - Optional name for the TensorProto. Default None
Returns:
A TensorProto containing the given array
Notes:
- python strings will be encoded to python bytes.
- Use dtype = "object" if the numpy array contains strings.
- dtype "string" and "object" are treated as same.
- "string" is converted to python "object". This is because, numpy handles variable length strings in this way
create_array_from_proto
Retrive array from TensorProto.
Arguments:
tensor_proto
TensorProto - An instance of TensorProto
Returns:
numpy array
Notes:
- python strings will be encoded to python bytes.
- Use dtype = "object" if the numpy array contains strings.
- dtype "string" and "object" are treated as same.
- "string" is converted to python "object". This is because, numpy handles variable length strings in this way
model_server.utils.model_info_utils
create_model_info_proto
Creates a ModelInfo proto
Arguments:
list_of_model_info_dict
list/tuple - A list containing model_info_dicts
Notes:
model_info_dict contains the following keys:
1 2 3 4 5 6 7 8 |
|
Returns:
ModelInfo proto
decode_model_info_proto
Decodes the model_info_proto created by create_model_info_proto
Arguments:
model_info_proto
ModelInfo proto - model_info_proto created by create_model_info_proto
Returns:
list_of_model_info_dict
list - A list containing model_info_dicts
Notes:
model_info_dict contains the following keys:
1 2 3 4 5 6 7 8 |
|