繁体   English   中英

scipy.misc.imresize在GCP ml-engine中不起作用

[英]scipy.misc.imresize not working in GCP ml-engine

我正在尝试在GCP ml-engine中提交以下玩具片段作为工作:

import tensorflow as tf
import numpy as np
import scipy.misc

x = np.zeros([10, 10, 1])
y = scipy.misc.imresize(x[:, :, 0], [50, 50, 1], interp='nearest')
print(y)
print(y.shape)

在服务器上启动作业后,它给出以下错误:

File "/root/.local/lib/python2.7/site-packages/teste/test.py", line 6, in <module>
y = scipy.misc.imresize(x[:, :, 0], [50, 50, 1], interp='nearest')
AttributeError: 'module' object has no attribute 'imresize'

它在本地完美运行,并且根据Cloud-ML文档,支持scipy软件包。 显然这不是模块本身的问题,因为import语句没有给出任何错误。

scipy.misc.imresize要求安装PIL,您可能已经在本地安装了PIL(因为它可以工作)。

为了确保您的代码在云中正确运行,您需要确保安装了pillow 如果您创建了自己的setup.py ,则在需求列表中包括pillow 如果必须创建自己的文件,请创建一个setup.py如下所示:

from setuptools import find_packages
from setuptools import setup

REQUIRED_PACKAGES = ['pillow']

setup(
    name='trainer',
    version='0.1',
    install_requires=REQUIRED_PACKAGES,
    packages=find_packages(),
    include_package_data=True,
    description='My trainer application package.'
)

source ,有一个重要的修改, packages属性)

有关建议的目录布局和打包说明的更多信息,请参阅CloudML Engine官方文档

在1.3.0中已弃用。 与使用枕头相反,重新安装scipy 1.0.0

pip install scipy==1.0.0

要么

pip3 install scipy==1.0.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM