ImageDataBunch function is not defined-FastAI windows

Question:

I am trying to install fastai in my windows 10.

My laptop has no GPU, I am using pip in cmd to install fastai.

In pip page, they mentioned to install pytroch before installing fastai.

I followed that step,

For pytorch

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

Then, For fastai-

pip install fastai

These python packages are installed successfully.

from fastai.vision import *

This statement is imported fastai.vision successfully,

But when I use the ImageDataBunch function,

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

It shows error, NameError: name 'ImageDataBunch' is not defined

I do not know what is happening, Could you please help me to solve this error, thanks

Asked By: user14064037

||

Answers:

from fastai.vision.data import ImageDataLoaders

Instead of using ImageDataBunch use data = ImageDataLoaders.from_folder(path, valid_pct=0.2) check here for more fastai vision documentation

Answered By: Dulanga Heshan

I got this error when forgetting to use from fastbook import *

Answered By: Samer Baslan

Just install "!pip install fastai==1.0.58" instead of "!pip install fastai" and you are good to go

Answered By: Fiza Saeed Malik