diff --git a/.gitignore b/.gitignore index 7d62f1a858..de444c578d 100644 --- a/.gitignore +++ b/.gitignore @@ -122,3 +122,5 @@ examples/models/onnx_resnet50/resnet.onnx #openapi engine/src/main/resources/static/seldon.json api-frontend/src/main/resources/static/seldon.json +wrappers/python/seldon.json + diff --git a/wrappers/python/microservice.py b/wrappers/python/microservice.py index 8f90c7aea8..17b3e3d660 100644 --- a/wrappers/python/microservice.py +++ b/wrappers/python/microservice.py @@ -112,7 +112,13 @@ def array_to_rest_datadef(array,names,original_datadef): def grpc_datadef_to_array(datadef): data_type = datadef.WhichOneof("data_oneof") if data_type == "tensor": - features = np.array(datadef.tensor.values).reshape(datadef.tensor.shape) + sz = np.prod(datadef.tensor.shape) # get number of float64 entries + c = datadef.tensor.SerializeToString() # get bytes + # create array from packed entries which are at end of bytes - assumes same endianness + features = np.frombuffer(memoryview(c[-(sz*8):]), dtype=np.float64, count=sz, offset=0) + features = features.reshape(datadef.tensor.shape) + # Previous method which is slower + # features = np.array(datadef.tensor.values).reshape(datadef.tensor.shape) elif data_type == "ndarray": features = np.array(datadef.ndarray) else: