模块未找到错误:未找到名为 'tf_slim' 的模块。

6

使用Anaconda尝试设置deeplab (https://github.com/tensorflow/models/tree/master/research/deeplab)。

通过查看其他问题的答案,我已经解决了很多问题,但是遇到了一个似乎没有答案的问题:

在尝试运行"python deeplab/model_test.py"时,我得到了以下错误:

(base) PS D:\DeepLab\models-master\research> python deeplab/model_test.py
C:\Users\Jake\anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\Jake\anaconda3\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
Traceback (most recent call last):
  File "deeplab/model_test.py", line 22, in <module>
    from deeplab import model
  File "D:\DeepLab\models-master\research\deeplab\model.py", line 58, in <module>
    from deeplab.core import feature_extractor
  File "D:\DeepLab\models-master\research\deeplab\core\feature_extractor.py", line 24, in <module>
    from deeplab.core import nas_network
  File "D:\DeepLab\models-master\research\deeplab\core\nas_network.py", line 44, in <module>
    from deeplab.core import nas_genotypes
  File "D:\DeepLab\models-master\research\deeplab\core\nas_genotypes.py", line 23, in <module>
    from deeplab.core import nas_cell
  File "D:\DeepLab\models-master\research\deeplab\core\nas_cell.py", line 29, in <module>
    from deeplab.core import xception as xception_utils
  File "D:\DeepLab\models-master\research\deeplab\core\xception.py", line 58, in <module>
    from nets.mobilenet import conv_blocks as mobilenet_v3_ops

  **File "D:\DeepLab\models-master\research\slim\nets\mobilenet\conv_blocks.py", line 20, in <module>
    import tf_slim as slim
ModuleNotFoundError: No module named 'tf_slim'**

我发现一些建议称这可能与环境变量相关,但我的所有环境变量都是正确的:环境变量,并且我多次刷新了anaconda窗口以确保更改生效。
我在目录文件夹中有tf_slim:C:\Program Files\Python36\Lib\site-packages\tf_slim。
不确定该怎么办:( 我对这种类型的安装还很陌生。
我使用的操作系统是Windows 10。

2
你可能需要安装 tf_slim - sushanth
3个回答

13

Anaconda默认创建虚拟环境,如果您通过Anaconda提示符打开Python,将会打开虚拟环境中的Python可执行文件。该虚拟环境将拥有自己的模块集,并且不会引用系统级别的Python包。

我建议您打开Anaconda提示符并键入以下命令:

pip install tf_slim


你让我开心了。 - Sajjad Aemmi

7

我相信

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

在测试模型之前,需要从tensorflow/models/research目录内部运行。

然而,对于这个特定的错误,表示缺少库,只需执行此操作即可解决问题。

pip install tf_slim

1
尝试运行。
Export PYTHONPATH=$PYTHONPATH:’pwd’:’pwd’/slim

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接