title: MLServer GRPC cannot reshape array of size 347 into shape (1,)
body: <p>I am following the example to serve sklearn model <a href="https://github.com/SeldonIO/MLServer/blob/master/docs/examples/sklearn/README.md" rel="nofollow noreferrer">https://github.com/SeldonIO/MLServer/blob/master/docs/examples/sklearn/README.md</a></p>
  <p>I am able to train and genreate the model, and then do a REST call for the inference successfully. However, I am trying to craft a gRPC call now, and the only example I could find is this <a href="https://mlserver.readthedocs.io/en/latest/examples/custom-json/README.html?highlight=grpc#send-test-inference-request-grpc" rel="nofollow noreferrer">https://mlserver.readthedocs.io/en/latest/examples/custom-json/README.html?highlight=grpc#send-test-inference-request-grpc</a></p>
  <p>However, this is using another model. SO I try to follow this example but replace it with inference request data from my current infer.py, please see <code>infer-grpc.py</code> below.</p>
  <p>train.py</p>
  <pre><code>from sklearn import datasets, svm, metrics
  from sklearn.model_selection import train_test_split
  
  # The digits dataset
  digits = datasets.load_digits()
  
  # To apply a classifier on this data, we need to flatten the image, to
  # turn the data in a (samples, feature) matrix:
  n_samples = len(digits.images)
  data = digits.images.reshape((n_samples, -1))
  
  # Create a classifier: a support vector classifier
  classifier = svm.SVC(gamma=0.001)
  
  # Split data into train and test subsets
  X_train, X_test, y_train, y_test = train_test_split(
      data, digits.target, test_size=0.5, shuffle=False)
  
  # We learn the digits on the first half of the digits
  classifier.fit(X_train, y_train)
  import joblib
  
  model_file_name = &quot;mnist-svm.joblib&quot;
  joblib.dump(classifier, model_file_name)
  
  
  </code></pre>
  <p>infer.py (http)</p>
  <pre><code>import requests
  # Import datasets, classifiers and performance metrics
  from sklearn import datasets, svm, metrics
  from sklearn.model_selection import train_test_split
  
  # The digits dataset
  digits = datasets.load_digits()
  
  # To apply a classifier on this data, we need to flatten the image, to
  # turn the data in a (samples, feature) matrix:
  n_samples = len(digits.images)
  data = digits.images.reshape((n_samples, -1))
  
  # Create a classifier: a support vector classifier
  classifier = svm.SVC(gamma=0.001)
  
  # Split data into train and test subsets
  X_train, X_test, y_train, y_test = train_test_split(
      data, digits.target, test_size=0.5, shuffle=False)
  
  # We learn the digits on the first half of the digits
  classifier.fit(X_train, y_train)
  
  
  x_0 = X_test[0:1]
  inference_request = {
      &quot;inputs&quot;: [
          {
            &quot;name&quot;: &quot;predict&quot;,
            &quot;shape&quot;: x_0.shape,
            &quot;datatype&quot;: &quot;FP32&quot;,
            &quot;data&quot;: x_0.tolist()
          }
      ]
  }
  
  endpoint = &quot;http://localhost:8089/v2/models/mnist-svm/versions/v0.1.0/infer&quot;
  response = requests.post(endpoint, json=inference_request)
  
  print(response.json())
  </code></pre>
  <p>infer-grpc.py</p>
  <pre><code>
  import mlserver.types
  import requests
  import json
  import grpc
  import mlserver.grpc.converters as converters
  import mlserver.grpc.dataplane_pb2_grpc as dataplane
  import mlserver.types as types
  import requests
  # Import datasets, classifiers and performance metrics
  from sklearn import datasets, svm, metrics
  from sklearn.model_selection import train_test_split
  
  # The digits dataset
  digits = datasets.load_digits()
  
  # To apply a classifier on this data, we need to flatten the image, to
  # turn the data in a (samples, feature) matrix:
  n_samples = len(digits.images)
  data = digits.images.reshape((n_samples, -1))
  
  # Create a classifier: a support vector classifier
  classifier = svm.SVC(gamma=0.001)
  
  # Split data into train and test subsets
  X_train, X_test, y_train, y_test = train_test_split(
      data, digits.target, test_size=0.5, shuffle=False)
  
  # We learn the digits on the first half of the digits
  classifier.fit(X_train, y_train)
  
  
  x_0 = X_test[0:1]
  
  
  
  model_name = &quot;mnist-svm&quot;
  
  ip = {&quot;input&quot;: x_0.tolist()}
  
  
  inputs_bytes = json.dumps(x_0.tolist()).encode(&quot;UTF-8&quot;)
  
  print([len(inputs_bytes)])
  print(inputs_bytes)
  
  inference_request = types.InferenceRequest(
      inputs=[
          types.RequestInput(
              name=&quot;predict&quot;,
              shape=[len(inputs_bytes)],
              datatype=&quot;BYTES&quot;,
              data=[inputs_bytes],
  
  
          )
      ]
  )
  
  
  
  
  inference_request_g = converters.ModelInferRequestConverter.from_types(
      inference_request,
      model_name=model_name,
      model_version=None
  )
  
  grpc_channel = grpc.insecure_channel(&quot;localhost:8081&quot;)
  grpc_stub = dataplane.GRPCInferenceServiceStub(grpc_channel)
  
  response = grpc_stub.ModelInfer(inference_request_g)
  response
  
  </code></pre>
  <p>throws an error:</p>
  <pre><code>
  grpc._channel._InactiveRpcError: &lt;_InactiveRpcError of RPC that terminated with:
      status = StatusCode.UNKNOWN
      details = &quot;Unexpected &lt;class 'ValueError'&gt;: cannot reshape array of size 347 into shape (1,)&quot;
  
  </code></pre>