castorini / honkling

Web app for keyword spotting using TensorflowJS
https://castorini.github.io/honkling/
MIT License
69 stars 13 forks source link

Weight file format #92

Closed cogmeta closed 5 years ago

cogmeta commented 5 years ago

Format of node_js/src/weights/RES8_NARROW.js and the weight file created by training.py do not have same format. How to convert the file created by training.py into format similar to node_js/src/weights/RES8_NARROW.js ? Thanks.

cogmeta commented 5 years ago

I tried loading the raw weight file generated by training.py but it does not work. keyError at line 210 in SpeechResModel.js

image

ljj7975 commented 5 years ago

Sorry. iirc training.py is outdated. Use honkling branch of honk, to train a model and genrate js weight files What you want is in these lines : https://github.com/castorini/honk/blob/honkling/utils/train.py#L154-L161

cogmeta commented 5 years ago

@ljj7975 Thanks. will give it a try. Btw, awesome job on honkling. Thank you so much!

ljj7975 commented 5 years ago

@cogmeta let me know if you get it working so that I can close this issue once you are done. Also, I updated readme explaining how to customize Honkling. #93

cogmeta commented 5 years ago

python3 -m utils.train --no_cuda --wanted_words yes no up down left right on off stop go --dev_every 1 --n_labels 12 --n_epochs 26 --weight_decay 0.00001 --lr 0.1 0.01 0.001 --schedule 3000 6000 --model res26-narrow

right , folder size - 2367 , missing count - 0 off , folder size - 2357 , missing count - 0 go , folder size - 2372 , missing count - 0 yes , folder size - 2377 , missing count - 0 down , folder size - 2359 , missing count - 0 left , folder size - 2353 , missing count - 0 Traceback (most recent call last): File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, runglobals) File "/home/psasatte/exp/honk/utils/train.py", line 211, in main() File "/home/psasatte/exp/honk/utils/train.py", line 201, in main train(config) File "/home/psasatte/exp/honk/utils/train.py", line 113, in train for , (model_in, labels) in enumerate(train_loader): File "/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py", line 615, in next batch = self.collate_fn([self.dataset[i] for i in indices]) File "/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py", line 615, in batch = self.collate_fn([self.dataset[i] for i in indices]) File "/home/psasatte/exp/honk/utils/model.py", line 399, in getitem return self.preprocess(self.audio_files[index]), self.audio_labels[index] File "/home/psasatte/exp/honk/utils/model.py", line 295, in preprocess data = torch.from_numpy(preprocess_audio(data, self.n_mels, self.filters)) File "/home/psasatte/exp/honk/utils/manage_audio.py", line 18, in preprocess_audio data = librosa.feature.melspectrogram(data, sr=16000, n_mels=n_mels, hop_length=160, n_fft=480, fmin=20, fmax=4000) File "/usr/local/lib/python3.5/dist-packages/librosa/feature/spectral.py", line 1391, in melspectrogram mel_basis = filters.mel(sr, n_fft, **kwargs) File "/usr/local/lib/python3.5/dist-packages/librosa/filters.py", line 247, in mel lower = -ramps[i] / fdiff[i] ValueError: operands could not be broadcast together with shapes (1,241) (0,)

ljj7975 commented 5 years ago

I found that librosa version was outdated. you need v0.6.2. pip install librosa --upgrade librosa==0.6.2

cogmeta commented 5 years ago

Awesome! It is building the model after upgrading librosa to 0.63. I will check if i can the load model in browser soon. Thank you so much.

cogmeta commented 5 years ago

...

cogmeta commented 5 years ago

Works, Thank you so much. Closing it.