Datadriven-GPVAD
Datadriven-GPVAD copied to clipboard
The error about “python3 extract_features.py wavs.txt -o hdf5/balanced.h5”
Hi,
I have some issue about extract feature.
1, In the file "configs/example.yaml"
data: data/softlabels/hdf5/balanced.h5 label: data/softlabels/csv/balanced.csv -> csv_labels/balanced.csv
2, when I run "python3 extract_features.py" command, there is an error!
in prepare_labels.py can't find "encoders/balanced.pth". it should be "labelencoders/vad.path" ? but when use models " 'gpvb':" ?
could you give me advice about it ?
MODELS = { 'crnn': { 'model': crnn, 'encoder': torch.load('encoders/balanced.pth'), 'outputdim': 527, }, 'gpvb': { 'model': crnn, 'encoder': torch.load('../labelencoders/vad.pth'), #('encoders/balanced_binary.pth'), 'outputdim': 2, } }
thanks for your response!
Hey there,
- I didn't quite get the question here? Its just an example file. If your path of the extracted data differs from mine, just change the path.
- Its the same label encoder (0 - Silence, 1- Speech) for all binary vad models i.e., GPVB, VAD-C and so on.
1, data: data/softlabels/hdf5/balanced.h5 for this set it h5 format or csv ? data: data/csv_labels/balanced.csv could you help me confirm it ? 2, Why we use binary model(eg. labelencoders/vad.path) to label the data for teaching training, since there are 527 classes in the paper? Or which model in the repo is more prefered to label the data from scratch ?
- Just as the
.yamlsays:
data: data/softlabels/hdf5/balanced.h5
label: data/softlabels/csv/balanced.csv
,thus data is the extracted feature hdf5 file and label are the corresponding labels, mapping a filename to a hdf5path and a label.
- Well I like to be a bit flexible with my code, since it often happens that my labelset changes during research (i.e., using only 2 labels, using all 527 or using a subset of the 527). Thus I use (and still often do ) a binary "dict" that simply maps
label -> number. So to be again specific for the training: The teacher model is trained on 527 label, but only predicts two frame-level labels (Speech, non-Speech) to a student. Thus it is prefferable that you use a 527 label model for any further training.
Thanks for your patience!!
1, I use the config " data: data/softlabels/hdf5/balanced.h5 label: data/softlabels/csv/balanced.csv " but in the step "python3 run.py train configs/example.yaml", there is an error as below:
_[2021-05-27 15:13:03] threshold: null
[2021-05-27 15:13:03] transforms:
[2021-05-27 15:13:03] - timemask
[2021-05-27 15:13:03] - freqmask
[2021-05-27 15:13:03]
[2021-05-27 15:13:03] Running on device cpu
Traceback (most recent call last):
File "run.py", line 637, in
please help me confirm!
Hmm seems that I am an idiot and didn't test my code well enough :(((.
Here is how to solve the issue: First check exactly the intro for training from scratch. https://github.com/RicherMans/Datadriven-GPVAD#training-from-scratch
Second, I now also know, the field:
data: csv_labels/balanced.csv
label: softlabels/csv/balanced.csv
Thus, the data file contains:
filename hdf5path
--PJHxphWEs_30.000.wav hdf5/balanced.h5
--ZhevVpy1s_50.000.wav hdf5/balanced.h5
--aE2O5G5WE_0.000.wav hdf5/balanced.h5
--aO5cdqSAg_30.000.wav hdf5/balanced.h5
and the label file is the one generated via prepare_labels.py.
Hi,
I had a problem after training the first epoch. It looks like the label of cv data are all zero. Is there anything wrong when labeling the data? Or I use the wrong model to label the data ?
Since I didn't find your model in the prepare_labels.py, I changed to the existing one in the repo:
MODELS = { 'crnn': { 'model': crnn, 'encoder': torch.load('../labelencoders/vad.pth'), # torch.load('encoders/balanced.pth'), 'outputdim': 527, }, 'gpvb': { 'model': crnn, 'encoder': torch.load('../labelencoders/vad.pth'), #('encoders/balanced_binary.pth'), 'outputdim': 2, } }
After epoch one, the log is:
Epoch [1/15]: [389/389]
Engine run is terminating due to exception: Precision must have at least one example before it can be computed.
Engine run is terminating due to exception: Precision must have at least one example before it can be computed.
Traceback (most recent call last):
File "run.py", line 637, in
plz try to use encoder': torch.load('../pretrained_models/labelencoders/teacher.pth') instead of using 'encoder': torch.load('../labelencoders/vad.pth')
Actually I am not sure how the label encoder are trained or generated. Could you please simply explain how the label encoder work and generated ? @RicherMans
Alright, where exactly in which file is the problem? Just in case, you can also provide me a PR if you'd like.
The encoder is just a MultiLabelBinarizer, found here.
A minimum working example can be just taken from there:
>>> mlb = MultiLabelBinarizer()
>>> mlb.fit([['sci-fi', 'thriller', 'comedy']])
MultiLabelBinarizer()
>>> mlb.classes_
array(['comedy', 'sci-fi', 'thriller'], dtype=object)
In my case just:
labelencoder = MultiLabelBinarizer()
labelencoder.fit([df['labels'].unique())
labelencoder.transform(['Speech']) # If Speech is in df['labels']
Hi,
I had a problem after training the first epoch. It looks like the label of cv data are all zero. Is there anything wrong when labeling the data? Or I use the wrong model to label the data ?
Since I didn't find your model in the prepare_labels.py, I changed to the existing one in the repo:
MODELS = { 'crnn': { 'model': crnn, 'encoder': torch.load('../labelencoders/vad.pth'), # torch.load('encoders/balanced.pth'), 'outputdim': 527, }, 'gpvb': { 'model': crnn, 'encoder': torch.load('../labelencoders/vad.pth'), #('encoders/balanced_binary.pth'), 'outputdim': 2, } }
After epoch one, the log is:
Epoch [1/15]: [389/389]
Engine run is terminating due to exception: Precision must have at least one example before it can be computed. Engine run is terminating due to exception: Precision must have at least one example before it can be computed. Traceback (most recent call last): File "run.py", line 637, in fire.Fire(Runner) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/fire/core.py", line 127, in Fire component_trace = _Fire(component, args, context, name) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/fire/core.py", line 366, in _Fire component, remaining_args) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/fire/core.py", line 542, in _CallCallable result = fn(*varargs, **kwargs) File "run.py", line 241, in train train_engine.run(trainloader, max_epochs=config_parameters['epochs']) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 702, in run return self._internal_run() File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 775, in _internal_run self._handle_exception(e) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 469, in _handle_exception raise e File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 752, in _internal_run self._fire_event(Events.EPOCH_COMPLETED) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 424, in _fire_event func(*first, *(event_args + others), **kwargs) File "run.py", line 212, in compute_metrics inference_engine.run(cvdataloader) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 702, in run return self._internal_run() File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 775, in _internal_run self._handle_exception(e) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 469, in _handle_exception raise e File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 752, in _internal_run self._fire_event(Events.EPOCH_COMPLETED) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/engine/engine.py", line 424, in _fire_event func(*first, *(event_args + others), **kwargs) File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/metrics/metric.py", line 309, in completed result = self.compute() File "/data/XXXXXX/anaconda3/envs/gpvad/lib/python3.6/site-packages/ignite/metrics/precision.py", line 57, in compute f"{self.class.name} must have at least one example before it can be computed." ignite.exceptions.NotComputableError: Precision must have at least one example before it can be computed.
Hi, I have a similar problem to this problem, when the code is runing at "inference_engine.run(cvdataloader)" in "run.py", it throws up the following error and then I have checked the val_datasets, there is no problem~ File "run.py", line 249, in train train_engine.run(trainloader, max_epochs=config_parameters['epochs']) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 892, in run return self._internal_run() File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 935, in _internal_run return next(self._internal_run_generator) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 993, in _internal_run_as_gen self._handle_exception(e) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 638, in _handle_exception raise e File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 965, in _internal_run_as_gen self._fire_event(Events.EPOCH_COMPLETED) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 425, in _fire_event func(*first, *(event_args + others), **kwargs) File "run.py", line 219, in compute_metrics inference_engine.run(cvdataloader) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 892, in run return self._internal_run() File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 935, in _internal_run return next(self._internal_run_generator) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 993, in _internal_run_as_gen self._handle_exception(e) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 638, in _handle_exception raise e File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 959, in _internal_run_as_gen epoch_time_taken += yield from self._run_once_on_dataset_as_gen() File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 1087, in _run_once_on_dataset_as_gen self._handle_exception(e) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 638, in _handle_exception raise e File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 1069, in _run_once_on_dataset_as_gen self._fire_event(Events.ITERATION_COMPLETED) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/engine/engine.py", line 425, in _fire_event func(*first, *(event_args + others), **kwargs) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/metrics/metric.py", line 310, in iteration_completed self.update(output) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/metrics/metric.py", line 607, in wrapper func(self, *args, **kwargs) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/metrics/precision.py", line 376, in update y_pred, y, correct = self._prepare_output(output) File "/xxx/.pyenv/versions/anaconda3-2020.02/envs/xxx/lib/python3.8/site-packages/ignite/metrics/precision.py", line 71, in _prepare_output y_pred = y_pred.view(-1) RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
Looking forward to your reply.
Hey,
I had a problem after training the first epoch. It looks like the label of cv data are all zero. Is there anything wrong when labeling the data? Or I use the wrong model to label the data ?
Yep you used a wrong model actually, but its also wrong on my part I'm sorry for that.
So the labelencoders are just dicts that map a label (Speech) to some value i.
Thus they are not usable as a model checkpoint.
I wrote in these scripts the wrong paths, sorry, the models you are looking for are in pretrained_models/teacher1/model.pth and pretrained_models/teacher2/model.pth. These correspond to the T1 and T2 from the paper.
You can also check out the other models within forward.py.
Sorry hope that helps!
Hey,
I had a problem after training the first epoch. It looks like the label of cv data are all zero. Is there anything wrong when labeling the data? Or I use the wrong model to label the data ?
Yep you used a wrong model actually, but its also wrong on my part I'm sorry for that. So the
labelencodersare just dicts that map a label (Speech) to some valuei. Thus they are not usable as a model checkpoint.I wrote in these scripts the wrong paths, sorry, the models you are looking for are in
pretrained_models/teacher1/model.pthandpretrained_models/teacher2/model.pth. These correspond to the T1 and T2 from the paper.You can also check out the other models within forward.py.
Sorry hope that helps!
Thank you for your patient response