From ef2ee57a8e64b3b4ced3bae3e9e2ebb4fdff385d Mon Sep 17 00:00:00 2001 From: MRXLT Date: Wed, 20 May 2020 17:13:07 +0800 Subject: [PATCH] fix shape check for numpy array --- python/paddle_serving_client/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/paddle_serving_client/__init__.py b/python/paddle_serving_client/__init__.py index 0d173550..6ea94a38 100644 --- a/python/paddle_serving_client/__init__.py +++ b/python/paddle_serving_client/__init__.py @@ -203,7 +203,12 @@ class Client(object): def shape_check(self, feed, key): if key in self.lod_tensor_set: return - if len(feed[key]) != self.feed_tensor_len[key]: + if isinstance(feed[key], + list) and len(feed[key]) != self.feed_tensor_len[key]: + raise SystemExit("The shape of feed tensor {} not match.".format( + key)) + if type(feed[key]).__module__ == np.__name__ and np.size(feed[ + key]) != self.feed_tensor_len[key]: raise SystemExit("The shape of feed tensor {} not match.".format( key)) -- GitLab