Fastai2 Blog Posts, Projects, and Tutorials

Hi all!

Getting into Week 2 of this years course and being in isolation, I finally got around to starting my own blog using fastpages. So here goes the first post which outlines the fastai style to master deep learning.

This will be followed by a series of posts going through my learnings in the course and hacking away at the fastai v2 library! :wink: Happy learning everyone and stay safe!

Thanks a lot to veterans like @muellerzr, @init_27 and @arora_aman for encouraging us to start publishing stuff in our learning journey!

8 Likes

Update:
Just completed my 2nd post on my blog covering the aspects learned in the 1st two weeks of the course: Building an image classifier using Fastai V2 :slight_smile:

2 Likes

I have added an example notebook to do multilabel classification using fastai.

Particularly, for the first example, I followed @radek wonderful notebook on audio classification and applied it to a different multi-label classification dataset.

Also, added an example on how to read four channel images using fastai for Protein Classification. Credits given to @akashpalrecha, @init_27 and @barnacl for working on the second example together. :slight_smile:

6 Likes

I published the following post: 3 ways to pip install a package: fastai2 use-case

Itā€™s a detailed description on how to pip install the fastai2 package using 3 different methods, and which method to pick depending on someoneā€™s use-case.

Method 1: Installing from pypi repository
Method 2: Installing from GitHub - Non-editable package
Method 3: Installing from GitHub - Editable package

2 Likes

@sgugger @jeremy (apologies for tagging you guys directly as I know you receive a ton of notifications).
I put together this notebook to experiment with text classification.
As I clearly state in section 2. Training a text classifier to detect human VS machine articles I leverage a lot of the code in this chapter of fastbook.
The last thing I want to do is to break the bookā€™s license or any community policy.
Is what I am doing allowed?
If not, I will immediately remove the notebook from my repo.
Thanks a lot!

1 Like

I finished fastai2 Image Augmentation using fastpages and it looks at the image augmentation pipeline. Would love to get feedback/check for errors or misunderstandings.

I do have a question though on the pipeline and havenā€™t been able to figure out what the differences are with these pipelines (in particular RandomResizedCrop and RandomResizedCropGPU)

For example using this as a regular example:

tfms = [[PILImage.create], [using_attr(RegexLabeller(r'(.+)_\d+.jpg$'), 'name'), Categorize]]
item_tfms = [ToTensor(), Resize(256)]
splitter=RandomSplitter(seed=42)
after_b = [IntToFloatTensor(), *aug_transforms(xtra_tfms=None)]

dsets = Datasets(repeat_one(source/'images'), tfms=tfms)
dls = dsets.dataloaders(after_item=item_tfms, after_batch=after_b, bs=32, num_workers=0, splits=splitter)
  1. In the default state the dls.after_batch pipeline looks like this:
    Pipeline: IntToFloatTensor -> AffineCoordTfm -> LightingTfm

  2. If we were to add a min_scale value to aug_transforms the pipeline now looks like this:
    Pipeline: IntToFloatTensor -> AffineCoordTfm -> RandomResizedCropGPU -> LightingTfm

  3. However we can also add RandomResizedCrop, the pipeline is now:
    Pipeline: RandomResizedCrop -> IntToFloatTensor -> AffineCoordTfm -> RandomResizedCropGPU -> LightingTfm

I donā€™t visually see any differences in the batches between 2 and 3.

I understand that the order values determine where the transforms are positioned but what is difference between RandomResizedCrop and RandomResizedCropGPU and why the different orders for both, RandomResizedCrop is order 1 and GPU order 40?

1 Like

This I believe is due to RRCGPU being pushed to the GPU, so everything is already in a batch by this point (as anything we push to the GPU should be by then).

I thought it was something on those lines so in that case would it more efficient to always use RandomResizedCropGPU instead of RandomResizedCrop? (although I did not notice any differences in training time between the two)

It depends on the use case. If youā€™re trying to make all the images the same size via RRC (similar to pre-sizing in a way) then no because youā€™d probably want that as an item transform before turning it into a batch. However if you want it in as just regular added augmentation later then yes.

1 Like

I almost forgot to put this here.
A few days ago I wrote a blog that aims to explain exactly how splits and split_idxs work inside of fastai2 and how to use that knowledge to control exactly what split of your data (i.e. train, valid, test, etc.) each of your Transforms is applied to. An instance where this can be useful is when you want to turn off certain image augmentations for your validation set.
Here it is: Using separate Transforms for your training and validation sets in fastai2

Itā€™s kind of rough at this point simply because I wanted to finish it off quickly :sweat_smile:. But I guess it gets the point across.

Any feedback is very much appreciated!

2 Likes

Finally found my v2 project! Think my blog will morph to cover this. Just put up the first post on complex initialization. Right now it doesnā€™t use fastai, but building towards itā€¦

1 Like

I was working around with the functionalities of L in Fastai and decided to make that into a blog post. So here it is:

A look at Fastaiā€™s ā€˜Lā€™ data structure

Iā€™m still working my way around all the functionalities of L and the post is by no means complete. Will try to add on as I discover other stuff. Any suggestions/feedback is highly welcome and anyone who has come across better use cases of L, please do let me know! :slight_smile:

7 Likes

Still working out a few issues with my fastpages implementation, but feel free to add my blog. Itā€™s at https://ohmeow.com.

In honor of last weekā€™s lecture, my first post is how cross-entropy loss works. Given that we just started learning about loss functions and have been using cross-entropy loss since week 1 (whether we knew it or not), I wanted to add some intuition behind how it works and why its the defacto go-to for mult-classification tasks

3 Likes

Hi harish3110 hope you are having a fabulous day!

I really enjoyed your post, it really explains the journey many of us make before we find fast.ai, the funny thing is once you learn fast.ai all the other ML theory courses become much more understandable.

Great post.

Cheers mrfabulous1 :smiley: :smiley:

1 Like

Thanks @mrfabulous1 for the kind words! Fastai has definitely helped in achieve a lot of clarity in many deep learning aspects for sure! :slight_smile:

1 Like

Hereā€™s a follow up post to the baseline image classification model built in my previous post.

In this one, I employ the techniques taught in the course, with an aim to build a benchmark image classifier on the flowers-102 dataset. You can see the post here.

As always please feel free to provide your feedback and your inputs on what I could have done differently! Stay home, stay safe and happy learning! :slight_smile:

1 Like

I used fastai2 to perform some experiments on the Intracranial hemorrhage detection competition on Kaggle. A blogpost about the same is here:

5 Likes

How are you guys testing fastpages locally?

1 Like

I donā€™t :slight_smile: I just look at the notebook and then just push to Git mostly because GitHub actions is better at catching the stuff than I am! IIRC to do so you need to build the docker image (thereā€™s directions, may be better suited for the blog sub forum :slight_smile: )

1 Like

I just finished my first blog using fastpages. https://dienhoa.github.io/dhoa.github.io/loss%20function/classification/2020/05/01/classification_loss_func.html . It is about loss function for multi-classes classification problem.

In short, any function that can return strict increasing values from best prediction to worst prediction can be considered a loss function. I explain it with geometrical perspective rather than probabilities which I think make it easier to understand. The most basic loss function experimented is the dot-product loss function. Then I did some tweaks to improve the performance of my loss function comparing to the most popular loss function: cross-entropy loss function.

This approach of explaining multi-classes loss function is quite rare but I think easier to understand. It is all about vector and the logarithm in cross-entropy is just a tweak to make the function penalize more the wrong prediction.

Hope it helps,

3 Likes