You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i have issue with converting librosa method to onnx.
I used skl2onnx libary but need to write custom canculator and convertor either of example didnt work, maybe some one could give some advice.
Example of code:
class FetureExtractor(TransformerMixin, BaseEstimator):
def __init__(self, X = None, alpha=0.):
self.mult_coeff = 2
self._mel = np.ones((1,16,8,1))
def fit(self, X, y = None):
print("-----fit TestFeatureExtractor-----")
return self
def transform(self, X, sample_rate = 22050):
# We extract mfcc feature from data
mels = np.mean(librosa.feature.melspectrogram(y=X, sr=sample_rate).T,axis=0)
self._mel = mels.reshape(1,16,8,1)
return self._mel
def test_feature_extractor_calculator(operator):
op = operator.raw_operator
input_type = operator.inputs[0].type.__class__
input = operator.inputs[0] # inputs in ONNX graph
N = input.type.shape[0]
print(operator.inputs[0].type)
input_dim = operator.inputs[0].get_first_dimension()
print(input_dim)
operator.outputs[0].type = FloatTensorType((1,16,8,1))
def test_feature_extractor_converter(scope, operator, container):
op = operator.raw_operator
opv = container.target_opset
out = operator.outputs
X = operator.inputs[0]
print('X {}'.format(X))
dtype = guess_numpy_type(X.type)
N = 20 # number of observations
C = 20 # dimension of outputs
coef = np.full((1,16,8,1), op.mult_coeff).astype(dtype)
Y = OnnxMatMul(X,coef, op_version=opv, output_names=out[:1])
Y.add_to(scope, container)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, i have issue with converting librosa method to onnx.
I used skl2onnx libary but need to write custom canculator and convertor either of example didnt work, maybe some one could give some advice.
Example of code:
Beta Was this translation helpful? Give feedback.
All reactions