@@ -58,7 +58,7 @@ def ACCEPT(self):
58
58
class StringDeserializer (BaseDeserializer ):
59
59
"""Deserialize data from an inference endpoint into a decoded string."""
60
60
61
- ACCEPT = ("application/json" , "text/csv" )
61
+ ACCEPT = ("application/json" ,)
62
62
63
63
def __init__ (self , encoding = "UTF-8" ):
64
64
"""Initialize the string encoding.
@@ -161,16 +161,17 @@ def deserialize(self, stream, content_type):
161
161
class NumpyDeserializer (BaseDeserializer ):
162
162
"""Deserialize a stream of data in the .npy format."""
163
163
164
- ACCEPT = ("application/x-npy" , "text/csv" , "application/json" )
165
-
166
- def __init__ (self , dtype = None , allow_pickle = True ):
164
+ def __init__ (self , dtype = None , accept = "application/x-npy" , allow_pickle = True ):
167
165
"""Initialize the dtype and allow_pickle arguments.
168
166
169
167
Args:
170
168
dtype (str): The dtype of the data (default: None).
169
+ accept (str): The MIME type that is expected from the inference
170
+ endpoint (default: "application/x-npy").
171
171
allow_pickle (bool): Allow loading pickled object arrays (default: True).
172
172
"""
173
173
self .dtype = dtype
174
+ self .accept = accept
174
175
self .allow_pickle = allow_pickle
175
176
176
177
def deserialize (self , stream , content_type ):
@@ -197,6 +198,16 @@ def deserialize(self, stream, content_type):
197
198
198
199
raise ValueError ("%s cannot read content type %s." % (__class__ .__name__ , content_type ))
199
200
201
+ @property
202
+ def ACCEPT (self ):
203
+ """The content types that are expected from the inference endpoint.
204
+
205
+ To maintain backwards compatability with legacy images, the
206
+ NumpyDeserializer supports sending only one content type in the Accept
207
+ header.
208
+ """
209
+ return (self .accept ,)
210
+
200
211
201
212
class JSONDeserializer (BaseDeserializer ):
202
213
"""Deserialize JSON data from an inference endpoint into a Python object."""
0 commit comments