name 'ImageDataBunch' is not defined

Question:

I’m getting this error “name ‘ImageDataBunch’ is not defined” and am not able to find a solution on the Internet.

The full code can be found here: https://dzlab.github.io/jekyll/update/2018/11/13/audio-classification/.

np.random.seed(42)
data = ImageDataBunch.from_lists(path, fnames, labels, ds_tfms=None, size=224, bs=bs)
data.normalize(imagenet_stats)
data.show_batch(rows=5, figsize=(8,8))

I’m running this code on Google Colab and Python 3.6.

Asked By: SySu

||

Answers:

You just need to import the ImageDataBunch class from the fast.ai library. Here’s the docs for it. Just add the following to the top of your code to import the entirety of the vision library classes:

from fastai.vision import *
Answered By: Turtalicious

Use this

from fastai.vision.data import ImageDataBunch

this code will solve the problem

Answered By: Avijit Chowdhury
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.