Skip to content

Latest commit

 

History

History
82 lines (55 loc) · 2.18 KB

File metadata and controls

82 lines (55 loc) · 2.18 KB

function make_grpc_predict_request

make_grpc_predict_request(inputs, model_name, model_version=0)

Aliases:

Description:

Creates GrpcPredictRequest object.

Args:

  • inputs: Python dictionary in format

    {
        ...
        <input_name>:<input_data>
        ...
    }

    Following types are accepted:

    Key Value type
    input_name string
    input_data python scalar, python list, numpy scalar, numpy array, TensorProto

    If provided input_data is not TensorProto, the make_tensor_proto function with default parameters will be called internally.

  • model_name: Name of the model that will receive the request.

  • model_version (optional): Version of the model that will receive the request. By default this value is set to 0, meaning the request will be sent to the default version of the model.

Returns: GrpcPredictRequest object filled with inputs and target model spec.

Raises:

  • TypeError: if unsupported types are provided.
  • ValueError: if arguments have inappropriate values.

Examples:

Request to the default version of the model called "model" that has 2 inputs:

predict_request = make_grpc_predict_request(
    inputs={
        "binary_input": bytes([1, 2, 3, 4, 5, 6]),
        "numeric_input": np.array([[1, 2, 3], [4, 5, 6]], np.int32)
    }, 
    model_name="model"
)

Request to the second version of the model called "model" that has 1 input. Providing data as TensorProto to make sure desired data type is set for the input:

predict_request = make_grpc_predict_request(
    inputs={
        "input": make_tensor_proto([1, 2, 3], dtype=DataTypes.float32)
    }, 
    model_name="model", 
    model_version=2
)

Return to the main page