ImageDataBunch函数未定义 - FastAI Windows

3

我正试图在 Windows 10 上安装 fastai。

我的笔记本没有 GPU,所以我正在使用 cmd 中的 pip 安装 fastai。

pip 页面上,他们提到在安装 fastai 之前要先安装 pytorch。

我遵循了这个步骤,

关于pytorch-

pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

然后,对于fastai:

pip install fastai

这些Python包已经成功安装。

from fastai.vision import *

成功导入了fastai.vision模块,

但是当我使用ImageDataBunch函数时,

data = ImageDataBunch.from_folder(path, train=".", valid_pct=0.2, size=512, bs=4, seed=24) 

它显示错误,NameError: name 'ImageDataBunch' is not defined

我不知道发生了什么事情,请您帮助我解决这个错误,谢谢。

3个回答

7
from fastai.vision.data import ImageDataLoaders

使用ImageDataLoaders.from_folder(path, valid_pct=0.2)代替ImageDataBunch。更多信息请查看fastai视觉文档


我得到了以下错误:类型对象“Image”没有属性“size” - Resham Wadhwa
尝试升级你的PIL版本,然后重新启动实例。 - Dulanga Heshan
我在Colab中遇到了NameError: name 'ImageDataBunch' is not defined的错误。有什么建议吗?我是这样导入的:from fastai.vision import *。 - AI_NA
今天链接无法使用,请在此处查看更多的fastai视觉文档。 - user2458922

0
只需要安装"!pip install fastai==1.0.58",而不是"!pip install fastai",你就可以开始了。

目前你的回答不够清晰。请编辑并添加更多细节,以帮助其他人理解该如何回答问题。你可以在帮助中心找到更多有关如何编写好回答的信息。 - AlexK

0

在编程时,当我忘记使用from fastbook import *时,出现了这个错误。


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