Lesson 2 In-Class Discussion ✅

I’ve asked the same question as well. I am working on an object detection project right now, where my objects overlap. I am guessing for my training set, I will use only objects that are not overlapping, while for my validation set I will include images where there is overlap. Haven’t read anything about this, but I think for standard image classification it won’t matter so much, unless there is some kind of time dependency in your image data.

Yes! Would love to see this!

I actually wrote this a little bit later. One of my most popular writings. Seems like people liked it.

1 Like

Thanks for the reply! I’ll check it out!

Hi I would like to ask what is the setup for the notebooks when downloading images from google.
So how I understand it I should use jupyter notebook on my local computer with the code from second lesson to download the images from google right?
And then it is uploaded somehow to the Azure machine I have setup earlier with all the fast ai content? How is it being uploaded? Thanks for the clarification regarding this issue.

Hi atpim I hope you are having wonderful day!

I don’t use azure I use google colab, which is one of the orher online jupyter notebook sites like azure.

When I did this lesson there was no special setup, though I always mount my google drive.

So how I understand it I should use jupyter notebook on my local computer with the code from second lesson to download the images from google right?

Yes.

I dragged them from my MacBook Pro to the directories I made on the online notebook.

I was making a watch classifier so had to create these directories and drag the images.

###Create directory and upload urls file into your server automatically

# Create data classes list for labeled images
classes = [ 'a_lange_and_sohne', 'audemars_piguet', 'blancpain', 'breguet_and_fils', 'breitling', 'cartier', 'chopard', 'girard_perregaux', 'hublot', 'iwc_schaff_hausen', 'jaeger_lecoulture', 'mont_blanc', 'omega', 'panarai', 'patek_phillipe', 'piaget', 'rolex', 'tag_heuer', 'ulysse_nardin', 'vacheron_constantin']
classes_folder_name = "watches"

# create a folder and file name for each class name
for c in classes:
    print(c)
    print("urls_" + c + ".csv")
    folder = c
    file = "urls_" + c + ".csv"
    
    path = Path('data/' + classes_folder_name)
    dest = path/folder
    dest.mkdir(parents=True, exist_ok=True)
    print(dest)

cheers hope this helps mrfabulous1 :smiley::smiley:

1 Like

Thanks that helped.

I also have question about this cell:

learn_cln = cnn_learner(db, models.resnet34, metrics=error_rate)

learn_cln.load('stage-2');

After we cleaned the data from bad images using the widget we get cleaned.csv file.
I understand we load it from csv to the db variable. Now this is passed to cnn_learner but why we dont train it again? Why the next line is .load(‘stage-2’)? should we train it beforehand?

Hi atpim
Hope you are having a marvelous day!

It is my understanding that you DO train it again with the cleaned data.

That’s how I interpreted it from the notebook and the video!

Cheers mrfabulous1 :smiley: :smiley:

In lesson 2 Teddy Bear problem when i do learn.fit_one_cycle(4) error rate is pretty inconsistent from 20 % to 2%. attached screenshot. is this acceptable?

To be more clear in epoch 0 error rate is 20%
In epoch1 error rate is 9.1%
epoch2 error rate is 5.7%
epoch3 error rate is 2.2%

In lesson 2 for the bear problem i get that the learn.recorder.plot() is an empty graph. attached the screenshot so that some one could give better inputs. Thanks

In lesson two i have imported widgets by doing fastai.widgets import *

when i use fd = FileDeleter(file_paths=top_loss_paths) there is an error that name ‘FileDeleter’ is not defined

1 Like

That’s exactly how it shoud be: error_rate must decrease as your model trains.
Accuracy = 1 - error_rate is growing.

Thanku…

Tried again today. learn.recorder.plot() gave me a blank X and Y without any graph. would appreciate if any one has more insight on this

When i load the models by doing learn.load(‘stage-2’) i see the train Label:list says teddy, teddy, teddy

where as ValidLabel has all classes like teddy, grizzyly, black. Is the model being trained

mostly on Teddys?
Attached screenshot …

@moulika, I’ve noticed your graph has VERY low LR on x-axis, although defaults in lr_find are:
start_lr = 1e-7, end_lr = 10

Try to specify start_lr in your call to lr_find explicitly.

1 Like

Lesson 2-SGD
plt.scatter(x[:,0],y)
plt.scatter(x[:,0],x@a);

RuntimeError: Can’t call numpy() on Variable that requires grad. Use var.detach().numpy() instead.

I had the same issue with this - there seems to be a grad_fn at the end of the tensor which is preventing the plotting.

I resolved it by changing the second line to

plt.scatter(x[:,0],x@a.detach());

You’ll also need to make the same changes in the animate it! section

9 Likes

Thanks @shanetwinterhalter. I updated and tried and worked like a charm. I’m super new to this, is there an explanation to why we needed to use the .detach method? Thanks again! :slight_smile: :smiley:

I got pretty good results with my bear model, but for some reason lr_find() stopped already after 8% and recorder.plot() did not draw anything. It did not print any error messages either.

How is that?