Path = untar_data

Hi I’m new to the course. Just starting Fastai. I am doing the dog breed exercice. When I define the path, can I use an image folder locally instead of downloading from url? If so, how do I pass path it to ImageDataLaoders? I pass it as a string?

thanks
David

from fastai.vision.all import *
path = untar_data(URLs.PETS)/‘images’

def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
path, get_image_files(path), valid_pct=0.2, seed=42,
label_func=is_cat, item_tfms=Resize(224))

learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)

Hi Daguer hope your having a wonderful day!

Just pass the path of the images directory as a string.

# create path
path2 = Path("/content/sample_data")

# check if path is directory
print(path2.is_dir())

Hope this helps

Cheers mrfabulous1 :smiley: :smiley:

Ok it answers my questions ! Cheers

Usually I use os.listdir(PATH)

where PATH = ‘…/data/’

So I simply pass PATH to ImageDataLoader. :slight_smile:

1 Like