Hi, I am new to fast.ai and I find it really helpful and interesting.
This is my imports and the path for the image folders
import torchvision
import fastcore
from fastai import *
from fastai.vision.all import *
from fastai.callback import *
from fastai.basics import *
from fastai.data import *
import pandas as pd
import numpy
import matplotlib.pyplot as plt
%matplotlib inlinestart_data = ‘/content/drive/MyDrive/ColabNotebooks/Datas/plantvillage-dataset/color’
the structure of the folders is
the getter function has this output that by my understanding works like it should
get_img_data = get_image_files(start_data)
(#54305) [Path('/content/drive/MyDrive/ColabNotebooks/Datas/plantvillage-dataset/color/Apple___Apple_scab/00075aa8-d81a-4184-8541-b692b78d398a___FREC_Scab 3335.JPG'),Path('/content/drive/MyDrive/ColabNotebooks/Datas/plantvillage-dataset/color/Apple___Apple_scab/01f3deaa-6143-4b6c-9c22-620a46d8be04___FREC_Scab 3112.JPG').....
this is the rest of my code that i had no error
#function that splits by default our data train–valid 80–20
seed = 42
splitter = RandomSplitter(seed=seed)#get the labels from the folders of our items
get_y = parent_label#block that we will use Image for images and Multi because is multi classification
blocks=(ImageBlock,MultiCategoryBlock)#our batches
batches = 16tfms = [Rotate(draw = rotate),
FlipItem(p=1.1),
Zoom(draw=1.5),
Brightness(draw=scale),
Contrast(draw=contrast),
Saturation(draw=saturation)
]#we combine all the transforms
comp = setup_aug_tfms(tfms)#item transforms for CPU
item_tfms = Resize(448)#Transforms for batches in GPU
batch_tfms =[comp,Normalize.from_stats(*imagenet_stats)]#Define our Datablock ready to be in a dls (dataloader)
plant= DataBlock(blocks=blocks,
get_items=get_img_data,
get_y=get_y,
splitter=splitter,
item_tfms=item_tfms,
batch_tfms=batch_tfms)
when i pass it in to the dataloader
dls= plant.dataloaders(start_data)
i have the following error and i tried to identify the problem or at least understand it but with no outcome
TypeError Traceback (most recent call last)
in ()
1 #Our dataloader
2 path= “/content/drive/MyDrive/ColabNotebooks/Datas/plantvillage-dataset/color”
----> 3 dls= plant.dataloaders(start_data)1 frames
/usr/local/lib/python3.7/dist-packages/fastai/data/block.py in dataloaders(self, source, path, verbose, **kwargs)
111
112 def dataloaders(self, source, path=‘.’, verbose=False, **kwargs):
→ 113 dsets = self.datasets(source, verbose=verbose)
114 kwargs = {**self.dls_kwargs, **kwargs, ‘verbose’: verbose}
115 return dsets.dataloaders(path=path, after_item=self.item_tfms, after_batch=self.batch_tfms, **kwargs)/usr/local/lib/python3.7/dist-packages/fastai/data/block.py in datasets(self, source, verbose)
105 def datasets(self, source, verbose=False):
106 self.source = source ; pv(f"Collecting items from {source}“, verbose)
→ 107 items = (self.get_items or noop)(source) ; pv(f"Found {len(items)} items”, verbose)
108 splits = (self.splitter or RandomSplitter())(items)
109 pv(f"{len(splits)} datasets of sizes {‘,’.join([str(len(s)) for s in splits])}", verbose)TypeError: ‘L’ object is not callable
I would like some help to overcome this problem but also to understand it
thank you for your time