1、ValueError: bad marshal data (unknown type code)
原因:从他那里网上下载的h5文件不可用,需要自己重新生成
注:加载yolo.h5出问题时,主要重新生成yolo.h5替换原有的yolo.h5
yolo.h5生成:
1、下载yad2k:
git clone https://github.com/allanzelener/yad2k.git
2、下载 yolo.weights和yolo.cfg放到yad2k文件夹下:
yolo.cfg——》git clone https://github.com/pjreddie/darknet,然后打开darknet/cfg/yolov2.cfg,修改参数,将width和height都修改为608,最后复制到目录yad2k下
weights文件——》进入网站https://pjreddie.com/darknet/yolov2/ ,找到here(258MB),点击下载,下载完毕之后将weight文件拷贝到目录yad2k下
3、cd yad2k
4、转换为模型h5:
python ./yad2k.py yolov2.cfg yolov2.weights model_data/yolo.h5
5、在本地yad2kmodel_data文件夹下找到yolo.h5,拷贝到作业model_data文件夹中即可
2、上述步骤在走到第四部时,遇到问题,解决avx2问题 完美解决Tensorflow不支持AVX2指令集问题
https://blog.csdn.net/beyond9305/article/details/95896135
不对:第二部描述的问题只是一个警告,不是主要问题,主要问题:
Using TensorFlow backend.
2019-11-20 20:37:10.030212: I d:uild ensorflow ensorflow-r1.9 ensorflowcoreplatformcpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Traceback (most recent call last):
File "./yad2k.py", line 25, in <module>
from yad2k.models.keras_yolo import (space_to_depth_x2,
File "E:吴恩达深度学习cheliangshibieyad2kyad2k.py", line 25, in <module>
from yad2k.models.keras_yolo import (space_to_depth_x2,
ModuleNotFoundError: No module named 'yad2k.models'; 'yad2k' is not a package
我吧那一行的yad2k去掉,之后有注释了两行带有相对路径的错误,才把这个h5文件能下来
3、第三部按照文档给的代码,遇到了一个问题
为题如下:
运行scores, boxes, classes = yolo_eval(yolo_outputs, image_shape)时,报错为InvalidArgumentError Traceback (most recent call last) ~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs) 1658 try: -> 1659 c_op = c_api.TF_FinishOperation(op_desc) 1660 except errors.InvalidArgumentError as e: InvalidArgumentError: Dimensions must be equal, but are 2 and 80 for 'mul_12' (op: 'Mul') with input shapes: [?,?,?,5,2], [?,?,?,5,80]
解决方法:
将yolo_outputs = yolo_head(yolo_model.output, anchors, len(class_names))这句代码改为: yolo_outputs = yolo_head(yolo_model.output, anchors, len(class_names)) print(str(yolo_outputs)) box_xy,box_wh,box_confidence,box_class_probs = yolo_outputs yolo_outputs = (box_confidence,box_xy,box_wh,box_class_probs) print(str(box_confidence)) print(str(box_xy)) print(str(box_wh)) print(str(box_class_probs)) print(str(yolo_outputs)) 报错原因是模型中几个参数的排列顺序变了,从print结果就能看出来
这样程序就能完整的运行出来,在out中可以看到倍圈出的图像。