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):
45
45
try :
46
46
if hasattr (schema_builder , "custom_input_translator" ):
47
47
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
49
49
)
50
50
else :
51
51
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 ]
53
53
)
54
54
55
55
# 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):
67
67
try :
68
68
if hasattr (schema_builder , "custom_input_translator" ):
69
69
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
71
71
)
72
72
else :
73
73
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 ]
75
75
)
76
76
77
77
# 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):
70
70
try :
71
71
if hasattr (schema_builder , "custom_input_translator" ):
72
72
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
74
74
)
75
75
else :
76
76
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 ]
78
78
)
79
79
except Exception as e :
80
80
raise Exception ("Encountered error in deserialize_request." ) from e
You can’t perform that action at this time.
0 commit comments