前言:未实现原因,是所安装库版本太高了。正确实现过程如下:YOLOv3在Intel Realsense上的Python实现_行秋的博客-CSDN博客

参考代码:

代码:dd​​​​​​​YOLOv3_Realsense: YOLOv3在Intel Realsense上的Python实现,讲识别标注在RGB与Depth图像上,并试图计算目标距离。

1.首先请确保拥有一个Intel Realsense深度摄像头,且该摄像头支持Realsense SDK2.0

2.请在Python3.6版本下运行,并确保一下库已安装

NumPy OpenCV

pyrealsense2

pip install pyrealsense2 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

sklean

pip install -U scikit-learn -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

  Pillow

pip install pillow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

 tensorflow-gpu

pip install tensorflow-gpu -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

keras

3. YOLO网站上下载YOLOv3权重,然后将Darknet YOLO模型转换为Keras 模型, 并将模型存储在model_data文件夹。

下载YOLOv3权重。 https://pjreddie.com/media/files/yolov3.weights

python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5

错误一:

解决:用下面语句,替代。

from keras.layers.normalization.batch_normalization_v1 import BatchNormalization

参考如下: 程序报错如下:ImportError: cannot import name ‘BatchNormalization‘_

错误二:

参考如下:error: the following arguments are required: config_path, weights_path, output问题解决_qiuzitao的博客-CSDN博客

然后在终端上运行后出现这个错误:

通过dir命令,发现convert.py文件命名,多了一个空格。(这里是我用GitHub上的代码,不是我自己多的) 

 修改后,运行又出现这个错误。

把47行注释掉,使用46行的即可。 

 

点击运行demo_Realsense.py,

 将从keras导入改为从tensorflow下的keras导入

 

参考链接:ModuleNotFoundError: No module named &#180sklearn.utils.linear_assignment_&#180_Heyuanfly的博客-CSDN博客

之后再运行,出现错误: AttributeError: module 'tensorflow' has no attribute 'ConfigProto'

 所以,需要将 tf.ConfigProto 修改为 tf.compat.v1.ConfigProto

之后再运行,出现错误:AttributeError: module 'tensorflow' has no attribute 'Session'

tf.Session(config=config)修改为tf.compat.v1.Session(config=config)

 之后再运行,出现错误:OSError: SavedModel file does not exist at: model_data/yolo.h5\{saved_model.pbtxt|saved_model.pb}

 把相对路径改成绝对路径

 之后再运行,出现错误:ValueError: object __array__ method not producing an array

 numpy 1.19.5 tensorflow-gpu 2.6.2

 之后,出现错误RecursionError: maximum recursion depth exceeded while calling a Python object

 更新了numpy

之后运行出现这个错误:

ValueError: Subshape must have computed start >= end since stride is negative, but is 0 and 2 (computed from start 0 and end 9223372036854775807 over shape with rank 2 and stride-1)
关于keras-yolov3-deepsort_只读一本心术书的博客-CSDN博客

 tf.Session(config=config)修改为tf.compat.v1.Session(config=config)

 tf.gfile 也改成 tf.io.gfile了.

tf.compat.v1.GraphDef() 修改为tf.compat.v1.GraphDef() 

tf.get_default_graph()修改为tf.compat.v1.get_default_graph()

 

Logo

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。

更多推荐