导入错误:无法从“object_detection”导入名称“model_lib_v2”(已安装但仍无法正常工作)

问题描述 投票:0回答:1

**嘿伙计们,目前正在进行张量流对象检测并由于错误而卡住。网上的方法都试过了,还是不行。 ** 我使用tensorflow == 2.10.0,模型是http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8.tar.gz 并使用jupyter笔记本,python版本= Python 3.10.9,无tensorflow gpu

以下是与错误相关的所有内容:

(odball) C:\Users\someone\Desktop\website\2023\TensorFlow Object Detection\TFODBall>python Tensorflow\models\research\object_detection\model_main_tf2.py --model_dir=Tensorflow\workspace\models\my_ssd_mobnet --pipeline_config_path=Tensorflow\workspace\models\my_ssd_mobnet\pipeline.config --num_train_steps=4000
Traceback (most recent call last):
  File "C:\Users\someone\Desktop\website\2023\TensorFlow Object Detection\TFODBall\Tensorflow\models\research\object_detection\model_main_tf2.py", line 31, in <module>
    from object_detection import model_lib_v2
ImportError: cannot import name 'model_lib_v2' from 'object_detection' (C:\Users\someone\Desktop\website\2023\TensorFlow Object Detection\TFODBall\odball\lib\site-packages\object_detection\__init__.py)

[C:\Users\someone\Desktop\website\2023\TensorFlow Object Detection\TFODBall\Tensorflow\models\research\object_detection\model_main_tf2.py](https://i.stack.imgur.com/mSaqo.png)

The "from object detection" of the image have indicator 

说报告缺少导入“对象检测”无法解决

我尝试过的解决方案:

  1. pip 安装tensorflow-object-detection-api
  2. 卸载并重新安装tensorflow
  3. 重启内核

以下是点列表:

Package                         Version         Editable project location
------------------------------- --------------- ---------------------------------------------------------------------------------------------------------
absl-py                         2.1.0
anyio                           4.3.0
apache-beam                     2.54.0
argon2-cffi                     23.1.0
argon2-cffi-bindings            21.2.0
arrow                           1.3.0
asttokens                       2.4.1
astunparse                      1.6.3
async-lru                       2.0.4
attrs                           23.2.0
avro-python3                    1.10.2
Babel                           2.14.0
beautifulsoup4                  4.12.3
bleach                          6.1.0
cachetools                      5.3.3
certifi                         2024.2.2
cffi                            1.16.0
charset-normalizer              3.3.2
colorama                        0.4.6
comm                            0.2.1
contextlib2                     21.6.0
contourpy                       1.2.0
cycler                          0.12.1
Cython                          3.0.8
debugpy                         1.8.1
decorator                       5.1.1
defusedxml                      0.7.1
dm-tree                         0.1.8
docutils                        0.20.1
exceptiongroup                  1.2.0
executing                       2.0.1
fastjsonschema                  2.19.1
flatbuffers                     23.5.26
fonttools                       4.49.0
fqdn                            1.5.1
gast                            0.4.0
google-auth                     2.28.1
google-auth-oauthlib            0.4.6
google-pasta                    0.2.0
grpcio                          1.62.0
h11                             0.14.0
h5py                            3.10.0
httpcore                        1.0.4
httpx                           0.27.0
idna                            3.6
importlib-metadata              7.0.1
ipykernel                       6.29.3
ipython                         8.22.1
ipywidgets                      8.1.2
isoduration                     20.11.0
jaraco.classes                  3.3.1
jedi                            0.19.1
Jinja2                          3.1.3
json5                           0.9.17
jsonpointer                     2.4
jsonschema                      4.21.1
jsonschema-specifications       2023.12.1
jupyter                         1.0.0
jupyter_client                  8.6.0
jupyter-console                 6.6.3
jupyter_core                    5.7.1
jupyter-events                  0.9.0
jupyter-lsp                     2.2.3
jupyter_server                  2.12.5
jupyter_server_terminals        0.5.2
jupyterlab                      4.1.2
jupyterlab_pygments             0.3.0
jupyterlab_server               2.25.3
jupyterlab_widgets              3.0.10
keras                           2.10.0
Keras-Preprocessing             1.1.2
keyring                         24.3.1
kiwisolver                      1.4.5
libclang                        16.0.6
lvis                            0.5.3
lxml                            5.1.0
Markdown                        3.5.2
markdown-it-py                  3.0.0
MarkupSafe                      2.1.5
matplotlib                      3.8.3
matplotlib-inline               0.1.6
mdurl                           0.1.2
mistune                         3.0.2
ml-dtypes                       0.3.2
more-itertools                  10.2.0
namex                           0.0.7
nbclient                        0.9.0
nbconvert                       7.16.1
nbformat                        5.9.2
nest-asyncio                    1.6.0
nh3                             0.2.15
notebook                        7.1.1
notebook_shim                   0.2.4
numpy                           1.26.4
oauthlib                        3.2.2
object-detection                0.1
opencv-python                   4.9.0.80
opt-einsum                      3.3.0
overrides                       7.7.0
packaging                       23.2
pandas                          2.2.1
pandocfilters                   1.5.1
parso                           0.8.3
pillow                          10.2.0
pip                             24.0
pkginfo                         1.9.6
platformdirs                    4.2.0
portalocker                     2.8.2
prometheus_client               0.20.0
prompt-toolkit                  3.0.43
protobuf                        3.19.6
psutil                          5.9.8
pure-eval                       0.2.2
pyasn1                          0.5.1
pyasn1-modules                  0.3.0
pycocotools                     2.0.7
pycparser                       2.21
Pygments                        2.17.2
pyparsing                       2.4.7
PyQt5                           5.15.10
PyQt5-Qt5                       5.15.2
PyQt5-sip                       12.13.0
python-dateutil                 2.8.2
python-json-logger              2.0.7
pytz                            2024.1
pywin32                         306
pywin32-ctypes                  0.2.2
pywinpty                        2.0.13
PyYAML                          6.0.1
pyzmq                           25.1.2
qtconsole                       5.5.1
QtPy                            2.4.1
readme_renderer                 43.0
referencing                     0.33.0
regex                           2023.12.25
requests                        2.31.0
requests-oauthlib               1.3.1
requests-toolbelt               1.0.0
rfc3339-validator               0.1.4
rfc3986                         2.0.0
rfc3986-validator               0.1.1
rich                            13.7.0
rpds-py                         0.18.0
rsa                             4.9
sacrebleu                       2.2.0
scipy                           1.12.0
Send2Trash                      1.8.2
setuptools                      65.5.0
six                             1.16.0
slim                            0.1             c:\users\someone\desktop\website\2023\tensorflow object detection\tfodball\tensorflow\models\research\slim
sniffio                         1.3.1
soupsieve                       2.5
stack-data                      0.6.3
tabulate                        0.9.0
tensorboard                     2.10.1
tensorboard-data-server         0.6.1
tensorboard-plugin-wit          1.8.1
tensorflow                      2.10.0
tensorflow-estimator            2.10.0
tensorflow-io                   0.31.0
tensorflow-io-gcs-filesystem    0.31.0
tensorflow-object-detection-api 0.1.1
termcolor                       2.4.0
terminado                       0.18.0
tf-models-official              2.15.0
tf-slim                         1.1.0
tinycss2                        1.2.1
tomli                           2.0.1
tornado                         6.4
traitlets                       5.14.1
twine                           5.0.0
types-python-dateutil           2.8.19.20240106
typing_extensions               4.10.0
uri-template                    1.3.0
urllib3                         2.2.1
wcwidth                         0.2.13
webcolors                       1.13
webencodings                    0.5.1
websocket-client                1.7.0
Werkzeug                        3.0.1
wget                            3.2
wheel                           0.42.0
widgetsnbextension              4.0.10
wrapt                           1.16.0
zipp                            3.17.0

我尝试过的解决方案:

1. pip install tensorflow-object-detection-api
2. uninstall and reinstall tensorflow
3. restart kernel 

我期待物体检测能够得到解决,不幸的是它仍然存在导致错误

python tensorflow jupyter-notebook tensorflow2.0 object-detection-api
1个回答
0
投票

我发现了问题,代码已经过时,并且tensorflow 2不支持某些旧版本的软件包。另外,除非我使用其他方法,否则没有特定版本是不可能的。解决方案是学习受支持的新技术并阅读最新的文档和 github 存储库来完成项目。

© www.soinside.com 2019 - 2024. All rights reserved.