Dogs Breed Challenge Error : AttributeError: 'NoneType' object has no attribute 'shape'


Hi All,
I am trying to run Resnet50 over DogsBreed images. With following code:

import cv2
arch = resnet50
data = ImageClassifierData.from_csv(PATH,‘train’, label_csv, bs= 64, tfms=tfms_from_model(arch,sz), val_idxs=val_idxs, test_name=‘valid’)
learn = ConvLearner.pretrained(arch, data, precompute = True)

But getting
AttributeError: ‘NoneType’ object has no attribute ‘shape’

I have tried deleting the folder suggested in


The error should have pointed to a line where the error originates from. Can you share which line it is?


it do say “No such file or Dir”, but while listing some of the 8000 images, first file name appeared.



Still can’t say with a 100% certainty, but it does seem like there’s a file that’s not an image somewhere inside your dataset.

Hence the library’s not available to call the shape function for the file (since it’s not the image)

Try running through the data file and look for anything that’s not an image? Alternatively, you can try segmenting your data into 5 or 10 chunks and run the model with them. See if you can run it without getting any errors that way


I thought we are supposed to follow the naming convention of the files? dogs.01.jpg etc.


Yup just realised this after what @ZaimAwang said - there might be a discrepancy between your file names used in the model and what your file names actually are.

Try inspecting each individual file in the train/valid folders and see what they are. off chances are your download mightve been corrupted


Many thanks, for suggesting workarounds, I have tried executing files (both from the terminal and in for loop) in for a look to check if there are any unwanted files. below are my screenshots:

I could not find any unwanted file :weary:

Will try execution on a smaller set.


@jameslee tried running on a smaller data set, Still same error…
one more question: Downloading dataset from any other location other than Kaggle will help?
If my filenames are corrupted how to spot those?


hold on, i just realised something.

it says no such file data/DogsBreedTrain/train/… you’re missing the “.jpg” for file names. hahaha



I wish so much that this alone solves the error, But I have tried with both with suffix and without it, none works.


damn :frowning:

Can you check if your data folder in the right place? ie in the same directory as the ipynb file you’re currently running.

I take it you’re able to load image with plt in the ipython notebook?


yes I am able to plt image


hmm, well I’m not too sure either. I didn’t encounter this issue when using different data sets too.

The link you posted to the other thread suggested you write a function or a line skipping non-jpg files.

have you tried that


this arch is working fine with Dogs and Cats data set, I am sure the problem lies in DataSet,
I tried executing the function, I am not sure what exactly is being done (excuse me for my beginner level)

So I tried removing labels from line 6 below is my output:

note : train folder contains :422 files(not all)


Cannot rename files as, the result CSV file, has mapped according to current filenames, so to check accuracy filenames should not be changed.


Finally, I could resolve the issues,

I assumed that this problem (likes Dogs and Cats ) also needed the Valid folder, to my surprise CSV file has a reference for Valid and train images. Moving files to the valid folder were not at all required.

Learning from this issue:
While reading Labels from CSV file for a multi-class problem, There is no need for Validation folder.

@jameslee, Many thanks for looking into the issue: :slight_smile:



No problem Seema :slight_smile: Glad I could be of help - although I doubt I did anything :sweat: