mycroft-precise
mycroft-precise copied to clipboard
precise-train-incremental gives error: "AttributeError: 'str' object has no attribute 'decode'"
Describe the bug
Starting precise-train-incremental, getting the following traceback:
(.venv) eqware@bc27dc4291ea:~/mycroft$ precise-train-incremental one.net clips/1 -r random_sounds/wav
Using TensorFlow backend.
Loading from one.net...
Traceback (most recent call last):
File "/home/eqware/mycroft/mycroft-precise/.venv/bin/precise-train-incremental", line 33, in
To Reproduce This is in an Ubuntu 18.04 docker container, where I had installed from source and successfully trained a model to recognize the word "one", using the command "precise-train -e 60 one.net clips/1/". I was following the instructions in the training guide for "Reducing False Activations", Method 2, with the pdsounds converted to wav in random_sounds/wav. Here are the contents of the directory where I am running from: clips clips.tar mycroft-precise one.epoch one.logs one.net one.net.params random_sounds
Expected behavior I was hoping to see it train some more, to refine the model.
Environment (please complete the following information):
- Device type: desktop
- OS: Ubuntu 18.04 docker image
- Mycroft-core version: Cloned from https://github.com/mycroftai/mycroft-precise, branch dev, commit e1a635e9675047eb86f64ca489a1b941321c489a
- Other versions:
Additional context Simply trying to follow the tutorial.
I now get this error too when I try to use precise-train-incremental on a new install I just set up. It’s working fine on an older install I have on another machine. Both are Raspberry Pi 4s with the latest Raspberry Pi OS and precise git cloned and source installed.
I also just found that I get the same error too if I just try to run precise-train
again on the .net
file of the first round.
(.venv) pi@testipi4:~/mycroft-precise $ precise-train heypips.net hey-pips-2/ -s 0.7 -e 100
Using TensorFlow backend.
WARNING:tensorflow:From /home/pi/mycroft-precise/.venv/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.AUTO_REUSE is deprecated. Please use tf.compat.v1.AUTO_REUSE instead.
WARNING:tensorflow:From /home/pi/mycroft-precise/.venv/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.AttrValue is deprecated. Please use tf.compat.v1.AttrValue instead.
WARNING:tensorflow:From /home/pi/mycroft-precise/.venv/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.COMPILER_VERSION is deprecated. Please use tf.version.COMPILER_VERSION instead.
WARNING:tensorflow:From /home/pi/mycroft-precise/.venv/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.CXX11_ABI_FLAG is deprecated. Please use tf.sysconfig.CXX11_ABI_FLAG instead.
WARNING:tensorflow:From /home/pi/mycroft-precise/.venv/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.ConditionalAccumulator is deprecated. Please use tf.compat.v1.ConditionalAccumulator instead.
Loading from heypips.net...
Traceback (most recent call last):
File "/home/pi/mycroft-precise/.venv/bin/precise-train", line 33, in <module>
sys.exit(load_entry_point('mycroft-precise', 'console_scripts', 'precise-train')())
File "/home/pi/mycroft-precise/precise/scripts/base_script.py", line 43, in run_main
script = cls(args)
File "/home/pi/mycroft-precise/precise/scripts/train.py", line 87, in __init__
self.model = create_model(args.model, params)
File "/home/pi/mycroft-precise/precise/model.py", line 70, in create_model
model = load_precise_model(model_name)
File "/home/pi/mycroft-precise/precise/model.py", line 54, in load_precise_model
return load_keras().models.load_model(model_name)
File "/home/pi/mycroft-precise/.venv/lib/python3.7/site-packages/keras/models.py", line 242, in load_model
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
I found a mention of this problem in the forum, where someone removed the .decode("utf8) from various places where it blows up. I did the same, and the error goes away, but I don't know if I have created another problem. I suppose that as long as the model is not written out with special utf8 characters, it shouldn't matter.
Hey I have the same issue, when i use the precise-listen command. where to i need to remove 'utf8'?
It says in the error message what file and line the error occurs at. Fix that, then re-run. You will get the same error in another place. Repeat this several times, then it will run without error. I have been away from this for a few days, and I am wondering if I need to find corresponding "encode utf8" calls in the training code. These decode errors are occurring when the previously trained model is getting read in.
Please keep in mind however, I am a newcomer to this - just trying to evaluate mycroft precise for a possible application. I do not have an insider's understanding of the code base.
It says in the error message what file and line the error occurs at. Fix that, then re-run. You will get the same error in another place. Repeat this several times, then it will run without error. I have been away from this for a few days, and I am wondering if I need to find corresponding "encode utf8" calls in the training code. These decode errors are occurring when the previously trained model is getting read in.
Please keep in mind however, I am a newcomer to this - just trying to evaluate mycroft precise for a possible application. I do not have an insider's understanding of the code base.
Hey buddy thanks for the help! I removed all .decode(utf8) and encodes from the code and now precise-listen seems to work. Wish me luck with the wake word training.
Well, I think I have been following the training instructions correctly but my results have not been satisfactory, so it is possible that I broke something.
Mark, can you post about that over in the wake word channel on chat?
Could you give me a link to this chat channel? Maybe I should have asked there in the first place?
https://chat.mycroft.ai/community/channels/wake-word
Also getting this error when trying to do precise-listen on the .net file
So I came across a fix for this problem for now. I stumbled across it in this thread on the Rhasspy forum:
https://community.rhasspy.org/t/mycroft-precise-installation-and-use/628/36?u=jgkk
The error seems to come from the newest version of h5py. If you change the requirements line in the setup.py for h5py from h5py
to h5py<3.0.0
and than run the setup.sh again it will install an older version and you won’t get the decode errors anymore.
Life Saver🙌 Thank you so much!
So I came across a fix for this problem for now. I stumbled across it in this thread on the Rhasspy forum: https://community.rhasspy.org/t/mycroft-precise-installation-and-use/628/36?u=jgkk The error seems to come from the newest version of h5py. If you change the requirements line in the setup.py for h5py from
h5py
toh5py<3.0.0
and than run the setup.sh again it will install an older version and you won’t get the decode errors anymore.
So I came across a fix for this problem for now. I stumbled across it in this thread on the Rhasspy forum: https://community.rhasspy.org/t/mycroft-precise-installation-and-use/628/36?u=jgkk The error seems to come from the newest version of h5py. If you change the requirements line in the setup.py for h5py from
h5py
toh5py<3.0.0
and than run the setup.sh again it will install an older version and you won’t get the decode errors anymore.
Great, solved my problem