@@ -34,8 +34,7 @@ def dump_data_and_model(data, model, onnx=None, basename="model", folder=None,
3434 :param backend: backend used to compare expected output and runtime output.
3535 Two options are currently supported: None for no test,
3636 `'onnxruntime'` to use module *onnxruntime*.
37- :param context: used if the model contains a custom operator such
38- as a custom Keras function...
37+ :param context: used if the model contains a custom operator
3938 :param allow_failure: None to raise an exception if comparison fails
4039 for the backends, otherwise a string which is then evaluated to check
4140 whether or not the test can fail, example:
@@ -108,15 +107,10 @@ def dump_data_and_model(data, model, onnx=None, basename="model", folder=None,
108107 with open (dest , "wb" ) as f :
109108 pickle .dump (data , f )
110109
111- if hasattr (model , 'save' ):
112- dest = os .path .join (folder , basename + ".model.keras" )
113- names .append (dest )
114- model .save (dest )
115- else :
116- dest = os .path .join (folder , basename + ".model.pkl" )
117- names .append (dest )
118- with open (dest , "wb" ) as f :
119- pickle .dump (model , f )
110+ dest = os .path .join (folder , basename + ".model.pkl" )
111+ names .append (dest )
112+ with open (dest , "wb" ) as f :
113+ pickle .dump (model , f )
120114
121115 if onnx is None :
122116 array = numpy .array (data )
@@ -168,7 +162,7 @@ def convert_model(model, name, input_types):
168162 """
169163 Runs the appropriate conversion method.
170164
171- :param model: model, *scikit-learn*, *keras*, or *coremltools* object
165+ :param model: model
172166 :return: *onnx* model
173167 """
174168 from sklearn .base import BaseEstimator
@@ -179,13 +173,8 @@ def convert_model(model, name, input_types):
179173 from onnxmltools .convert import convert_sklearn
180174 model , prefix = convert_sklearn (model , name , input_types ), "Sklearn"
181175 else :
182- from keras .models import Model
183- if isinstance (model , Model ):
184- from onnxmltools .convert import convert_keras
185- model , prefix = convert_keras (model , name , input_types ), "Keras"
186- else :
187- from onnxmltools .convert import convert_coreml
188- model , prefix = convert_coreml (model , name , input_types ), "Cml"
176+ from onnxmltools .convert import convert_coreml
177+ model , prefix = convert_coreml (model , name , input_types ), "Cml"
189178 if model is None :
190179 raise RuntimeError ("Unable to convert model of type '{0}'." .format (type (model )))
191180 return model , prefix
0 commit comments