bzamecnik / ml

Machine learning projects, often on audio datasets
MIT License
92 stars 39 forks source link

predict.py dropping different errors #44

Closed JBloodless closed 6 years ago

JBloodless commented 6 years ago

Hi! I'm trying to test prediction on wav and flac, but both of them drop me different errors: running wav file, I get

File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 98, in predict_class_label x_features = self.load_features(audio_file) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 135, in <module> print(model.predict_class_label(args.audio_file)) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 87, in load_features x_features = self.ch.transform(x0) AttributeError: 'dict' object has no attribute 'transform'

and on flac file

Traceback (most recent call last): File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 135, in <module> print(model.predict_class_label(args.audio_file)) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 98, in predict_class_label x_features = self.load_features(audio_file) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 83, in load_features x, fs = sf.read(audio_file) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 374, in read frames = f._prepare_read(start, stop, frames) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 1447, in _prepare_read self.seek(start, SEEK_SET) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 870, in seek _error_check(self._errorcode) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 1455, in _error_check raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace')) RuntimeError: Internal psf_fseek() failed.

I'm using Python 3.6.2 on Windows and the model from here. Could you help me to figure out the issue?

bzamecnik commented 6 years ago

Hi, in the first problem it seems that tfr.PitchgramTransformer is not correctly deserialized from pickle (instead to dict). Probably because the JSON file contains serialized preprocessing.ChromagramTransformer which got changd to tfr.PitchgramTransformer. Try running the preprocessing again with up-to-date code.

Second error is something to do with soundfile library. Try googing, I don't know. Or maybe just load the audio using librosa...

Good luck!

Kind regards,

Bohumir

2018-04-24 19:28 GMT+02:00 Иван Бескровный notifications@github.com:

Hi! I'm trying to test prediction on wav and flac, but both of them drop me different errors: running wav file, I get

File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 98, in predict_class_label x_features = self.load_features(audio_file) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 135, in print(model.predict_class_label(args.audio_file)) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 87, in load_features x_features = self.ch.transform(x0) AttributeError: 'dict' object has no attribute 'transform'

and on flac file

Traceback (most recent call last): File "C:/dipl0m/ml-master/ instrument-classification/predict.py", line 135, in print(model.predict_class_label(args.audio_file)) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 98, in predict_class_label x_features = self.load_features(audio_file) File "C:/dipl0m/ml-master/instrument-classification/predict.py", line 83, in load_features x, fs = sf.read(audio_file) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 374, in read frames = f._prepare_read(start, stop, frames) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 1447, in _prepare_read self.seek(start, SEEK_SET) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 870, in seek _error_check(self._errorcode) File "C:\Users\jackb\AppData\Roaming\Python\Python36\site-packages\soundfile.py", line 1455, in _error_check raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace')) RuntimeError: Internal psf_fseek() failed.

I'm using Python 3.6.2 on Windows and the model from here https://github.com/bzamecnik/deep-instrument-heroku/tree/master/static/model/2016-10-15_22-11-47_31fdbcbb. Could you help me to figure out the issue?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bzamecnik/ml/issues/44, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbOrCeoeiGrQoILjTiEYXGvpIfqL9m7ks5tr2DEgaJpZM4TiGey .

JBloodless commented 6 years ago

Thanks for pointing out!