我正在尝试在我的 Windows 10 中安装 fastai。
我的笔记本电脑没有 GPU,我在 cmd 中使用 pip 安装 fastai。
在 pip page ,他们提到在安装 fastai 之前安装 pytroch。
我按照那个步骤,
对于 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
我不知道发生了什么,请你帮我解决这个错误,谢谢
最佳答案
from fastai.vision.data import ImageDataLoaders
不要使用 ImageDataBunch
而是使用 data = ImageDataLoaders.from_folder(path, valid_pct=0.2)
在这里查看更多 fastai vision documentation
关于python - ImageDataBunch 函数未定义-FastAI windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63581422/