Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开始训练时报错 AttributeError: 'str' object has no attribute 'decode' 已找到解决办法 #13

Closed
BackMountainDevil opened this issue Mar 15, 2022 · 0 comments

Comments

@BackMountainDevil
Copy link

模型训练-v1.pdf

集MODEL和DEPTHMUL开始训练: make train MODEL=yolo_mobilev1 DEPTHMUL=0.75 MAXEP=10
ILR=0.001 DATASET=voc CLSNUM=20 IAA=False BATCH=8

报错误

$ make train MODEL=yolo_mobilev1 DEPTHMUL=0.75 MAXEP=10
ILR=0.001 DATASET=voc CLSNUM=20 IAA=False BATCH=8
python ./keras_train.py \
                --train_set voc \
                --class_num 20 \
                --pre_ckpt "" \
                --model_def yolo_mobilev1 \
                --depth_multiplier 0.75 \
                --augmenter False \
                --image_size 224 320 \
                --output_size 7 10 14 20 \
                --batch_size 32 \
                --rand_seed 3 \
                --max_nrof_epochs 10 \
                --init_learning_rate 0.0005 \
                --learning_rate_decay_factor 0 \
                --obj_weight 1 \
                --noobj_weight 1 \
                --wh_weight 1 \
                --obj_thresh 0.7 \
                --iou_thresh 0.5 \
                --vaildation_split 0.05 \
                --log_dir log \
                --is_prune False \
                --prune_initial_sparsity 0.5 \
                --prune_final_sparsity 0.9 \
                --prune_end_epoch 5 \
                --prune_frequency 100 
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

2022-03-15 16:21:52.145631: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2022-03-15 16:21:52.167418: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2096875000 Hz
2022-03-15 16:21:52.168281: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5643bd94b6a0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2022-03-15 16:21:52.168352: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2022-03-15 16:21:52.169885: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2022-03-15 16:21:52.169909: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2022-03-15 16:21:52.169922: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (xx): /proc/driver/nvidia/version does not exist
[ INFO  ] data augment is  False
WARNING:tensorflow:From /home/kearney/.conda/envs/k210/lib/python3.7/site-packages/tensorflow_core/python/data/util/random_seed.py:58: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
[ INFO  ] data augment is  False
WARNING:tensorflow:From /home/kearney/.conda/envs/k210/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py:1630: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.
Instructions for updating:
If using Keras pass *_constraint arguments to layers.
Traceback (most recent call last):
  File "./keras_train.py", line 155, in <module>
    args.prune_frequency)
  File "./keras_train.py", line 51, in main
    yolo_model, yolo_model_warpper = network([image_size[0], image_size[1], 3], len(h.anchors[0]), class_num, alpha=depth_multiplier)
  File "/home/kearney/Downloads/k210/Yolo-for-k210/Yolo-for-k210/models/yolonet.py", line 19, in yolo_mobilev1
    base_model.load_weights('data/mobilenet_v1_base_7.h5')
  File "/home/kearney/.conda/envs/k210/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py", line 182, in load_weights
    return super(Model, self).load_weights(filepath, by_name)
  File "/home/kearney/.conda/envs/k210/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py", line 1373, in load_weights
    saving.load_weights_from_hdf5_group(f, self.layers)
  File "/home/kearney/.conda/envs/k210/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 645, in load_weights_from_hdf5_group
    original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'
make: *** [Makefile:35:train] 错误 1

解决办法来自 成功解决AttributeError: ‘str‘ object has no attribute ‘decode‘

pip install 'h5py<3.0.0' -i https://pypi.tuna.tsinghua.edu.cn/simple

猜测是作者 pip freeze 的时候删除了很多东西,我 pip 出来有好多个包,如下所示

$ pip list
Package                       Version
----------------------------- -----------
absl-py                       1.0.0
astor                         0.8.1
cached-property               1.5.2
certifi                       2021.10.8
cycler                        0.11.0
gast                          0.2.2
google-pasta                  0.2.0
grpcio                        1.44.0
h5py                          3.6.0
imageio                       2.9.0
imgaug                        0.2.9
importlib-metadata            4.11.3
Keras-Applications            1.0.8
Keras-Preprocessing           1.1.2
kiwisolver                    1.4.0
Markdown                      3.3.6
matplotlib                    3.0.3
networkx                      2.6.3
numpy                         1.16.2
opencv-python                 4.0.0.21
opt-einsum                    3.3.0
Pillow                        6.2.0
pip                           21.2.2
protobuf                      3.19.4
pyparsing                     3.0.7
python-dateutil               2.8.2
PyWavelets                    1.1.1
scikit-image                  0.15.0
scipy                         1.2.1
setuptools                    58.0.4
Shapely                       1.8.1.post1
six                           1.16.0
tensorboard                   1.15.0
tensorflow                    1.15.0
tensorflow-estimator          1.15.1
tensorflow-model-optimization 0.1.1
termcolor                     1.1.0
typing_extensions             4.1.1
Werkzeug                      2.0.3
wheel                         0.37.1
wrapt                         1.14.0
zipp                          3.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant