Wiki: Lesson 1

Do we store augmented data in hard drive? Or they just stored in the memory?

1 Like

I was wondering the same

This seemed like an interesting problem that might have real world implications, such as determining whether a passenger in a car pool lane is real or a dummy. I made up a larger set of images (only around 100 of each type) and tried the lesson 1 approach. Although this set is still too small, I could easily get around 90% accuracy on the validation set. Sometimes I could get around 96% with very low validation loss. However, the validation set is quite small, so it doesn’t take much to drop accuracy.

The dataset, instructions on creating it, and my notebook exploring the data are available here:

I followed this to fix this: Jupyter notebook KeyError: ‘allow_remote_access’

Updated the key c.NotebookApp.ip to ‘localhost’ in file $HOME/.jupyter/jupyter_notebook_config.py

Hey guys,

Here is a minor update to the function plot_val_with_title so it works with multiclass image classification:

def plot_val_with_title(idxs, title):
    imgs = [load_img_id(data.val_ds,x) for x in idxs]
    pred_labels = np.array(data.classes)[preds[idxs]]
    pred_labels_prob = np.exp(np.max(log_preds[idxs], axis=1))
    title_probs = ["{}:{:.2f}".format(lab,prob) for lab,prob in \
                   zip(pred_labels, pred_labels_prob)]
    print(title)
    return plots(imgs, rows=1, titles=title_probs, figsize=(16,8)) if len(imgs)>0 else print('Not Found.')

I’m currently working through Fast.AI lesson one on a paperspace machine. I have pulled the latest fastai repo, and have updated the Python / Anaconda libraries as shown herehttps://github.com/reshamas/fastai_deeplearn_part1/blob/master/tools/paperspace.md

In the section Our first model: quick start

I am running into the following error when running this code snippet.

rch=resnet34
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=True)
learn.fit(0.01, 3)

Error Below:
0%| | 0/360 [00:00<?, ?it/s]

TypeError Traceback (most recent call last)
in
1 arch=resnet34
2 data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
----> 3 learn = ConvLearner.pretrained(arch, data, precompute=True)
4 learn.fit(0.01, 3)

~/fastai/courses/dl1/fastai/conv_learner.py in pretrained(cls, f, data, ps, xtra_fc, xtra_cut, custom_head, precompute, pretrained, **kwargs)
112 models = ConvnetBuilder(f, data.c, data.is_multi, data.is_reg,
113 ps=ps, xtra_fc=xtra_fc, xtra_cut=xtra_cut, custom_head=custom_head, pretrained=pretrained)
–> 114 return cls(data, models, precompute, **kwargs)
115
116 @classmethod

~/fastai/courses/dl1/fastai/conv_learner.py in init(self, data, models, precompute, **kwargs)
98 if hasattr(data, ‘is_multi’) and not data.is_reg and self.metrics is None:
99 self.metrics = [accuracy_thresh(0.5)] if self.data.is_multi else [accuracy]
–> 100 if precompute: self.save_fc1()
101 self.freeze()
102 self.precompute = precompute

~/fastai/courses/dl1/fastai/conv_learner.py in save_fc1(self)
177 m=self.models.top_model
178 if len(self.activations[0])!=len(self.data.trn_ds):
–> 179 predict_to_bcolz(m, self.data.fix_dl, act)
180 if len(self.activations[1])!=len(self.data.val_ds):
181 predict_to_bcolz(m, self.data.val_dl, val_act)

~/fastai/courses/dl1/fastai/model.py in predict_to_bcolz(m, gen, arr, workers)
16 m.eval()
17 for x,*_ in tqdm(gen):
—> 18 y = to_np(m(VV(x)).data)
19 with lock:
20 arr.append(y)

~/fastai/courses/dl1/fastai/core.py in VV(x)
67 def VV(x):
68 ‘’‘creates a single or a list of pytorch tensors, depending on input x. ‘’’
—> 69 return map_over(x, VV_)
70
71 def to_np(v):

~/fastai/courses/dl1/fastai/core.py in map_over(x, f)
6 def is_listy(x): return isinstance(x, (list,tuple))
7 def is_iter(x): return isinstance(x, collections.Iterable)
----> 8 def map_over(x, f): return [f(o) for o in x] if is_listy(x) else f(x)
9 def map_none(x, f): return None if x is None else f(x)
10 def delistify(x): return x[0] if is_listy(x) else x

~/fastai/courses/dl1/fastai/core.py in VV_(x)
63 def VV_(x):
64 ‘’‘creates a volatile tensor, which does not require gradients. ‘’’
—> 65 return create_variable(x, True)
66
67 def VV(x):

~/fastai/courses/dl1/fastai/core.py in create_variable(x, volatile, requires_grad)
51 if type (x) != Variable:
52 if IS_TORCH_04: x = Variable(T(x), requires_grad=requires_grad)
—> 53 else: x = Variable(T(x), requires_grad=requires_grad, volatile=volatile)
54 return x
55

~/fastai/courses/dl1/fastai/core.py in T(a, half, cuda)
39 a = to_half(a) if half else torch.FloatTensor(a)
40 else: raise NotImplementedError(a.dtype)
—> 41 if cuda: a = to_gpu(a, non_blocking=True)
42 return a
43

~/fastai/courses/dl1/fastai/core.py in to_gpu(x, *args, **kwargs)
88 def to_gpu(x, *args, **kwargs):
89 ‘’‘puts pytorch variable to gpu, if cuda is available and USE_GPU is set to true. ‘’’
—> 90 return x.cuda(*args, **kwargs) if USE_GPU else x
91
92 def noop(*args, **kwargs): return

TypeError: _cuda() got an unexpected keyword argument ‘non_blocking’

Hello Rachel,

I am following the online MooC and running into library problems. Can you please tell what are the versions of pytorch, spacy, fastai and torchtext that need to be installed.

I’m looking at the lesson1-pets juptyer notebook from courses/fast-ai/courses-v3/nbs/dl1 and the notebook is very different from the contents of the video here https://course.fast.ai/lessons/lesson1.html. Am I looking at the right notebook?

1 Like

I’m finding the same. There are some notes at http://wiki.fast.ai/index.php/Lesson_1_Notes but that uses VGG rather than resnet so not aligned with the video either.
There was also https://github.com/fastai/courses/tree/master/deeplearning1/nbs but these are the VGG notebooks too.
I started off with the Fast.AI lessons on crestle.ai whihc are resnet but, whilst similar type of content, they aren’t the same as the videos so may be a little confusing.

Cheers
Andy

1 Like

Hi everyone,
I have question why isn’t Kaggle(now that it provides a free GPU) advertised as a potential platform for running the code on this course.

I have a Windows 10 workstation equipped with a GPU, is there any chance I can setup the environment for running the FastAI notebooks on Windows?

Hi, I’m just getting started but spent a significant amount of time getting the jupyter notebook command to open the course content from my paperspace machine. It was very useful to go through the process to figure out how everything works from changing ports to local or remote. But my question is: when we are just getting started, can we access the course folder in jupyter from our local machine by copying the fastai git repo to our local drive, and using anaconda or any other command prompt to open the jupyter notebook from a fastai folder on our local drive? I’m guessing we need the paperspace VM for GPU later down the road, but is it technically the same to run jupyter notebook locally?

Is the dog/cats notebook in lesson one now completely replaced by the pets notebook? Or are we supposed to do it on our own? I’m having some trouble getting started in the right direction.

Google is giving GPU computing for free(for now).
colab.research.google.com

This is a better option to use crestle.
When you use google colab, make sure you install fast ai as follows:
!pip install fastai==0.7.0

Also, you can install pytorch as follows:

# http://pytorch.org/
from os.path import exists
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag

platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
cuda_output = !ldconfig -p|grep cudart.so|sed -e 's/.*\.\([0-9]*\)\.\([0-9]*\)$/cu\10/'    
accelerator = cuda_output[0] if exists('/dev/nvidia0') else 'cpu'
version='0.4.0'
torch_url=f"http://download.pytorch.org/whl/{accelerator}/torch-{version}-{platform}-linux_x86_64.whl"
!pip install -U {torch_url} torchvision

Sorry to bother you!

I downloaded the dataset from http://files.fast.ai/data/dogscats.zip

When training the model, I find that the extracted image got wrong, I find no solution!

Is there any idea about the extracting issue, Thanks a lot!

I have downloaded 100 images of tiger and 100 lion using google-image-download. Can anybody please tell me how to label all images.

Move them into separate folders…

Hi @Sonu,

If you look at the lesson2-download python notebook, you’ll see this process spelled out. It boils down to:

  1. Get a list of URLs from your google images by running a piece of javascript from within the browser console. Note that where it says “You will need to get the urls of each of the images. You can do this by running the following commands” it is best to run each of those commands separately. (I found that I ended up having to copy the list of URLs into VSCode and run a simple regex on them. But the first time I did this it was not necessary). At any rate, you end up with a text file of URLs. Whatever you are going to name these text files will need to match the names that you will use in the code, e.g.:
    folder = ‘black’
    file = ‘urls_black.txt’

  2. Create a folder for each category. I believe the class names should match the folder names. I also think that that is what creates the label: the fact that an image is in the ‘black’ folder means that it will get a ‘black’ label.

:frowning:

Could it be how real to life Barbie dolls are nowadays? In seriousness, I don’t know the answer.