I Have tried to create visualization of what conv net sees at every layer. Hope this can help us all to understand what happens at every layer and what are the changes that occur with the input.
Very nice! It will be interesting to visualize a distinct object, like a cat.
Yeah just needs to change the model weights and I/p ️:slight_smile:️
I look forward to try to run your notebook, but I got stuck in a quite annoying bug.
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-32-7d2bde4a6b2c> in <module>()
1 arch = models.resnet50
2 sz = 256
----> 3 data = get_data(sz)
4 learn = conv_learner.ConvLearner.pretrained(arch,data)
<ipython-input-31-2080aaa6de83> in get_data(sz)
3 data = conv_learner.ImageClassifierData.from_csv(path = path, folder='train',csv_fname='labels.csv' ,test_name='test',
4 tfms=conv_learner.tfms_from_model(arch, sz, aug_tfms=conv_learner.transforms_side_on),
----> 5 val_idxs=indexes, bs=16)
6 return data
~/fastai/courses/dl1/fastai/dataset.py in from_csv(cls, path, folder, csv_fname, bs, tfms, val_idxs, suffix, test_name, continuous, skip_header, num_workers)
350 ImageClassifierData
351 """
--> 352 fnames,y,classes = csv_source(folder, csv_fname, skip_header, suffix, continuous=continuous)
353 ((val_fnames,trn_fnames),(val_y,trn_y)) = split_by_idx(val_idxs, np.array(fnames), y)
354
~/fastai/courses/dl1/fastai/dataset.py in csv_source(folder, csv_file, skip_header, suffix, continuous)
74
75 def csv_source(folder, csv_file, skip_header=True, suffix='', continuous=False):
---> 76 fnames,csv_labels,all_labels,label2idx = parse_csv_labels(csv_file, skip_header)
77 full_names = [os.path.join(folder,fn+suffix) for fn in fnames]
78 if continuous:
~/fastai/courses/dl1/fastai/dataset.py in parse_csv_labels(fn, skip_header)
61 def parse_csv_labels(fn, skip_header=True):
62 skip = 1 if skip_header else 0
---> 63 csv_lines = [o.strip().split(',') for o in open(fn)][skip:]
64 fnames = [fname for fname, _ in csv_lines]
65 csv_labels = {a:b.split(' ') for a,b in csv_lines}
FileNotFoundError: [Errno 2] No such file or directory: 'labels.csv'
Alhough If I try to read the labels.csv file as in the library df = pd.read_csv(os.path.join(path, csv_fname))
I can read it without any problem …
Thank you in advance!
@alessa Can you share folder structure where Plant seed training data is present?
Or you can change this part of your code to the way you have defined get_data function. It will not be an issue. and then you can try loading the weight you have.
Super! The layers show some of the images being sensitive to edges, some of them detecting the soil texture at various granularities. The white boxes are a by-product of display right? Yes, as @anandsaha says you should try it with a more interesting image
That’s a clever way you implemented that! FYI, there’s a much easier way, which is to use a forward hook in pytorch. See the definition of summary()
in fastai for an example, along with the pytorch docs.
Yeah after trying that I read about hook in pytorch. Will try it with that. thanks
Yeah White boxes are empty. They were just because of the structure.i will fix that later. Yeah I will try this with cats and dogs model. Thanks
Thanks for your answer @merajat It’s not clear for me where the labels.csv should be, right now there in the PATH ~/data/plant-sleedings-classification …
Try giving the absolute path for label.csv or you can copy it into your working directory. Please let me know if it works
Yes, it works. Thanks @merajat
path = '/home/ubuntu/data/plant-seedlings-classification/'
label_csv = f'{path}labels.csv'
indexes = [100,200,210] # just some random data to we will be not be training the model
def get_data(sz):
data = conv_learner.ImageClassifierData.from_csv(path = path, folder='train',csv_fname=label_csv ,test_name='test',
tfms=conv_learner.tfms_from_model(arch, sz, aug_tfms=conv_learner.transforms_side_on),
val_idxs=indexes, bs=16)
return data
cool
Do Share the images…
It’s really cool to look at them…
I have no weights . Do you have them? Or it’s better to train it by myself.
Update:
When I try to train I have this error
error: /io/opencv/modules/imgproc/src/color.cpp:10606: error: (-215) scn == 3 || scn == 4 in function cvtColor
You should be training them, It will be fun you can try it on dogs and cat model.
yes, you are right! maybe it’s better for dogs and cats, since I worked with them already and have everything ready
@alessa
This thread will solve your problem
Problem is with the image_id’s spaces and folder structure…
BTW if anyone is interested trying contributing to fastai, here’s a good opportunity - add some simple error checking to open_image
in dataset.py that checks that the file exists, and that it is a file (not a directory).
os.path.isdir() and os.path.isfile() should be sufficient ?