Lesson 1 In-Class Discussion ✅

Hey Fabian,

I am working on a similar problem; I was able download and use a good dataset provided by DeepSolar Project:

So far, only their validation data is available, but it’s more than enough to train and validate a model. Let me know if you would like to know more about the steps I took.

Edit: solved my problem. If you’re getting a connection error downloading the dataset, make sure you’ve enable internet access, for which you need to verify your phone # via SMS code. There’s a link on the the right hand side of the notebook within the settings frame.

This is the second time Im trying to run the lab. First time it worked fine, now im getting the following error - “NameError: name ‘create_cnn’ is not defined”. Any ideas as to why that is happening now?

1 Like

I have the same problem as well right now… I just run the same scripts yesterday and it worked fine, but now it prompts “NameError: name ‘create_cnn’ is not defined”…

Hi guys,
First at all thanks for you hard work with this course.

I ran this notebook with no issues. But now I want use trained model on single image to give me prediction of dog or cat breed.

something like this from last year course:

trn_tfms, val_tfms = tfms_from_model(arch, sz)
ds = FilesIndexArrayDataset([fn], np.array([0]), val_tfms, PATH)
dl = DataLoader(ds)
preds = learn.predict_dl(dl)
np.argmax(preds)

Unfortunately this is not working anymore as fastai changed a lot in the mean time.
I tried find solution for this in this thread but with no luck.

I found trn_tfms, val_tfms = tfms_from_model(arch, sz) is now trn_tfms, val_tfms = get_transforms(arch, sz)

But I have no luck with other lines

Any advice will be much appreciated.

Thanks
Roman

create_cnn was changed to cnn_learner from v1.0.47, see here

Yijin

I tried lesson 01 on colab.How can I download the classifier I trained from colab for personal use?

Hello, I am trying to create my own image dataset and having some trouble.

I noticed we create the files through

      urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou);
window.open('data:text/csv;charset=utf-8,' + escape(urls.join('\n')));

which adds all the images to a csv file.

However, download_images(path/file, dest, max_pics=200) pulls from path/file and path/file is a txt file as defined by

folder = 'grizzly'
file = 'urls_grizzly.txt'

&

path = Path('data/bears')
dest = path/folder
dest.mkdir(parents=True, exist_ok=True)

How does this work?

The Javascript grabs a list of urls and stores them into a txt file, from which you will upload to your jupyter notebook.

The path to the data will be under the “data/bears” folder. Grizzly, teddys, and black will be the subfolders, and as well, categories of your data.

The dest.mkdir call, will create those directories for you. Then the download_image calls, will then grab all of the images listed in the urls.txt file.

You just have to make sure you call the corresponding cells so the downloaded images get placed in the correct folders.

The javascript grabs a list of urls and stored them in a CSV file not a txt file though, as defined by

window.open('data:text/csv;charset=utf-8,'

Yeah just make sure to rename it with mv on linux, or right click it on Windows to rename it. Then it should work properly.

1 Like

Hi guys,

I found solution for making prediction for your own picture.

Here is my code:

dataClasses = data.classes

def load_model():
    sz = 224
    arch = models.resnet50
    path = '/home/roman/FastAI/Lesson1' #path where my notebook is stored
    classes = dataClasses
    data = ImageDataBunch.single_from_classes(path, classes, tfms=get_transforms(), size=sz).normalize(imagenet_stats)
    learn = create_cnn(data, arch)
    learn.load('stage-2-50') #name of you saved model
    return learn

img = open_image("/home/roman/FastAI/Lesson1/images/lurcher.jpeg") #path with your image

trained_model = load_model()
pred_class, pred_idx, outputs = trained_model.predict(img)

pred_class #this will give you prediction for your image

1 Like

Thanks @utkb and @SiewLin. I am able to run the assignment now. I was using 1.0.48 version of fastai (through AWS SageMaker) hence had to replace with cnn_learner. One thing to note in case others run into same problem - I had to restart the kernel for the change to take into effect.

Hi,
I’m using colab, I want to use Fast.ai v3 but it has fast.ai v1 (1.0.46) installed. How to upgrade to that?
Because of that cnn_learner wasn’t working and had to change it to create_cnn, to make it work.
Please let me know how to upgrade.

Hi @apoorv16, just run this line before running other codes:

!curl https://course.fast.ai/setup/colab | bash

Were you able to figure this out?

I tried it with clouderizer, it worked well…

Yes, this is what is suggested in"returning to work" page of FastAI.

1 Like

I’ve done lesson 1 so the model is sufficiently trained around 6% error rate and thought it would be fun to throw in a picture of my own cat, to see what race the NN think she is.

How would I do this? I don’t want to retrain the network or anything, but rather put the pretrained model to practical use.

Hi @imago,
You’ll be doing exactly that in Lesson 2 (see section on putting it in production)
but for a quick preview you can run the following in a cell

img = open_image(path/to/your/cat/image)
img # to show your cat image
pred_class,pred_idx,outputs = learn.predict(img)
pred_class # what breed your cat is 

HTH.
Best regards,
Butch

1 Like