Tensorflow 对象检测 API - 当我尝试运行 model_builder_test.py 时出现 ImportError
Posted
技术标签:
【中文标题】Tensorflow 对象检测 API - 当我尝试运行 model_builder_test.py 时出现 ImportError【英文标题】:Tensorflow Object Detection API - ImportError when I try to run model_builder_test.py 【发布时间】:2021-10-26 17:29:53 【问题描述】:我正在使用张量对象检测 API 创建自定义对象检测模型。我安装了this 笔记本中提到的所有内容,并按照本笔记本中提到的相同步骤进行操作,但是当我尝试运行 model_builder_test.py 文件时
import os
os.environ['PYTHONPATH'] += ':/../models/research/:/../models/research/slim/'
!python object_detection/builders/model_builder_test.py
我收到以下错误:
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "object_detection/builders/model_builder_test.py", line 21, in <module>
from object_detection.builders import model_builder
File "/home/u83829/object_detection_usecase/tensorflow/models/research/object_detection/builders/model_builder.py", line 23, in <module>
from object_detection.builders import image_resizer_builder
File "/home/u83829/object_detection_usecase/tensorflow/models/research/object_detection/builders/image_resizer_builder.py", line 19, in <module>
from object_detection.core import preprocessor
File "/home/u83829/object_detection_usecase/tensorflow/models/research/object_detection/core/preprocessor.py", line 82, in <module>
from object_detection.core import densepose_ops
File "/home/u83829/object_detection_usecase/tensorflow/models/research/object_detection/core/densepose_ops.py", line 29, in <module>
import scipy.io
File "/glob/development-tools/versions/oneapi/2021.3/inteloneapi/intelpython/latest/lib/python3.7/site-packages/scipy/io/__init__.py", line 97, in <module>
from .matlab import loadmat, savemat, whosmat, byteordercodes
File "/glob/development-tools/versions/oneapi/2021.3/inteloneapi/intelpython/latest/lib/python3.7/site-packages/scipy/io/matlab/__init__.py", line 11, in <module>
from .mio import loadmat, savemat, whosmat
File "/glob/development-tools/versions/oneapi/2021.3/inteloneapi/intelpython/latest/lib/python3.7/site-packages/scipy/io/matlab/mio.py", line 9, in <module>
from .mio4 import MatFile4Reader, MatFile4Writer
File "/glob/development-tools/versions/oneapi/2021.3/inteloneapi/intelpython/latest/lib/python3.7/site-packages/scipy/io/matlab/mio4.py", line 9, in <module>
import scipy.sparse
File "/glob/development-tools/versions/oneapi/2021.3/inteloneapi/intelpython/latest/lib/python3.7/site-packages/scipy/sparse/__init__.py", line 228, in <module>
from .csr import *
File "/glob/development-tools/versions/oneapi/2021.3/inteloneapi/intelpython/latest/lib/python3.7/site-packages/scipy/sparse/csr.py", line 10, in <module>
from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks,
ImportError: numpy.core.multiarray failed to import
我在 Intel OneAPI Devcloud 上使用 python 3.7.10 和 tensorflow 2.6.0。请帮我解决这个错误。
【问题讨论】:
您可能需要修改您的numpy
版本。这有帮助吗:***.com/questions/20518632/…?这是一篇关于您遇到相同错误的帖子。
【参考方案1】:
试试这个,
pip uninstall numpy
那么,
pip install numpy
对于特定版本的numpy,
pip install numpy==1.8
【讨论】:
【参考方案2】:该错误是因为您的 numpy 版本可能与 tensorflow 对象检测 API 使用的版本不兼容。要解决此问题,您可以使用以下命令将 numpy 升级到最新版本。
pip install -U numpy
【讨论】:
以上是关于Tensorflow 对象检测 API - 当我尝试运行 model_builder_test.py 时出现 ImportError的主要内容,如果未能解决你的问题,请参考以下文章
TensorFlow 对象检测 API 没有 train.py 文件
Tensorflow 对象检测 api 获取按边界框坐标排序的预测