File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
src/sagemaker/serve/model_server Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,11 @@ def input_fn(input_data, content_type):
4545 try :
4646 if hasattr (schema_builder , "custom_input_translator" ):
4747 deserialized_data = schema_builder .custom_input_translator .deserialize (
48- io .BytesIO (input_data ), content_type
48+ io .BytesIO (input_data ) if type ( input_data ) == bytes else io . BytesIO ( input_data . encode ( 'utf-8' )) , content_type
4949 )
5050 else :
5151 deserialized_data = schema_builder .input_deserializer .deserialize (
52- io .BytesIO (input_data ), content_type [0 ]
52+ io .BytesIO (input_data ) if type ( input_data ) == bytes else io . BytesIO ( input_data . encode ( 'utf-8' )) , content_type [0 ]
5353 )
5454
5555 # Check if preprocess method is defined and call it
Original file line number Diff line number Diff line change @@ -67,11 +67,11 @@ def input_fn(input_data, content_type):
6767 try :
6868 if hasattr (schema_builder , "custom_input_translator" ):
6969 deserialized_data = schema_builder .custom_input_translator .deserialize (
70- io .BytesIO (input_data ), content_type
70+ io .BytesIO (input_data ) if type ( input_data ) == bytes else io . BytesIO ( input_data . encode ( 'utf-8' )) , content_type
7171 )
7272 else :
7373 deserialized_data = schema_builder .input_deserializer .deserialize (
74- io .BytesIO (input_data ), content_type [0 ]
74+ io .BytesIO (input_data ) if type ( input_data ) == bytes else io . BytesIO ( input_data . encode ( 'utf-8' )) , content_type [0 ]
7575 )
7676
7777 # Check if preprocess method is defined and call it
Original file line number Diff line number Diff line change @@ -70,11 +70,11 @@ def input_fn(input_data, content_type):
7070 try :
7171 if hasattr (schema_builder , "custom_input_translator" ):
7272 return schema_builder .custom_input_translator .deserialize (
73- io .BytesIO (input_data ), content_type
73+ io .BytesIO (input_data ) if type ( input_data ) == bytes else io . BytesIO ( input_data . encode ( 'utf-8' )) , content_type
7474 )
7575 else :
7676 return schema_builder .input_deserializer .deserialize (
77- io .BytesIO (input_data ), content_type [0 ]
77+ io .BytesIO (input_data ) if type ( input_data ) == bytes else io . BytesIO ( input_data . encode ( 'utf-8' )) , content_type [0 ]
7878 )
7979 except Exception as e :
8080 raise Exception ("Encountered error in deserialize_request." ) from e
You can’t perform that action at this time.
0 commit comments