A walk with fastai2 - Vision - Study Group and Online Lectures Megathread

Hi muellerzr hope your day is going fabulously.

Thanks for the quick reply, I didn’t reply to you directly as I know your busy. I am happy that sgugger’s dealing with it. I am also happy that it is actually is an issue and not just my lack of understanding. If my coding skills were better I would fix it myself, but I think I am a little way from that yet.

My only concern is that for the new starters to fastai deploying their first ML app, is probably one of the highlights of their learning year, it was for me anyway.

Cheers mrfabulous1 image .image

1 Like

Once things get less hectic on my end I plan on deploying (at least most) of the models we wind up building. I’ve had thoughts on deploying Maybe on GitHub pages (if they do FTP/interactions) and tagging in an s3 bucket request or something (if it can’t be done on pages manually) for doing predictions. But I do plan on eventually getting to this and tackling it. (Not saying it will be soon)

1 Like

That’s my goal also lol!
On any platform that is cheap that I can understand!
:smiley: :smiley:

2 Likes

that is helpful. for some reason, i had it in my head it was like the F in pytorch. thank you.

1 Like

Here is the schedule for tomorrow’s lesson:

  • Keypoint Regression
  • Keypoint with UNet
  • Object Detection
  • Multimodal models and Kaggle (Bengali.AI) (may need to take this down… looking at the rules, I posted it on the Kaggle discussion forum as well so I think we’re okay, if anyone is more familiar with Kaggle tell me if there is anything else I need to do or if it’s not allowed at all)

Those notebooks are all live (minus Unet, will be done soon), I’ll be working on the Lesson 7 Notebooks this week and then that’ll be it for the vision block :slight_smile:

Lesson 7 will consist of:

  • SuperResolution
  • Audio
  • Siamese Dataloader

For those wanting more GAN, there is a Wassertein GAN example in the course subdirectory here (LSUNS)

1 Like

@mrfabulous1, thank you so much for your detailed reply! Two more questions:

  1. In your response, you have mentioned " I would suggest you complete the production part of the notebook and create a .pkl file for your model" . Prodiction part of which notebook?

  2. I am thinking of using fastai v1 for now, but I am having difficulty installing it on a CPU only machine. Can you please take a look at the post here: Fastai v1 install issues thread

Thank you again for your time!

I had assumed the latter part of the “Custom” notebook but upon further inspection… we never exported the model to get the PKL! Oops (my bad!). So to do so, do learn.export('myModel') and it will show up as myModel in the content panel on colab. (this is shown in the beginning of L2 I think if not I know it’s in the style transfer lesson)

However that is shown on the tail end of the lesson2-download notebook on the fastai2 repo:

Here is the part where Jeremy talks about Hooks from v3 part 2:
Starting at 1:18:17 ish
https://course.fast.ai/videos/?lesson=10

1 Like

Question regarding segmentation: looking at the example notebook, the list of codes looks the following:


So “Animal” would be 0, Archway “1”… and so on. Is there a way to change this? i.e. my food categories have other ids so I would like to pass to fastai the correct pairs e.g. corn “1234”, bread “6543”, popcorn “7654”. Is there a way to pass this dictionary?

A workaround would be to go with it and then update the mask to the correct ids but it feels to me as very inefficient.

You may be able to do it if you sort by lowest to highest value (possibly) and build your list via that. If we check the MaskBlock code we trail to https://github.com/fastai/fastai2/blob/master/fastai2/vision/core.py#L121

We can see that it is just a list of codes (though try a list. It may or may not work, not sure!)

@mgloria i wanted to clarify - you are currently training with non continuous codes ?

for some reason i thought the codes needed to be continuous. That’s why i wanted to check thanks :slight_smile:

Regarding your question i feel i’m missing something, you currently have corn : “1234” but you want to change that to corn : “1” ? That means you have to change your mask values ?

in style transfer why are we doing .eval ?
feat_net = vgg19(pretrained=True).features.cuda().eval()

from my understanding .eval is used for changing behaviour of bn and dropout layers, with vgg19, vgg16 we don’t have those layers in the feature extractor. Is this added just as a safety measure when we add an arch that has one of those layers ?

Because we never train the feature extractor. (Since it’s just there for our loss). So weights never get updated.

This is because our encoder is basically performing an inference, so we want the inference drop out/model setup

1 Like

Also! On a related note between model.eval() and with torch.no_grad(), I was curious if the difference (because I thought it was the same). It’s not!

model.eval() will notify all your layers that you are in eval mode, that way, batchnorm or dropout layers will work in eval mode instead of training mode . torch.no_grad() impacts the autograd engine and deactivate it

2 Likes

adding to that : model.train() and model.eval() do not change any behavior of the gradient calculations, but are used to set specific layers like dropout and batchnorm to train or evaluation mode (dropout won’t drop activations, batchnorm will use running stats instead of batch stats).

go through this thread - https://discuss.pytorch.org/t/model-eval-vs-with-torch-no-grad/19615
i learnt a lot of new things :slight_smile:

2 Likes

Wow! Just finished reading, instantly added to my library of quick reminder bookmarks :slight_smile: Great find

Also, from that discussion:

These two statements are basically the same:

torch.no_grad, torch.set_grad_enabled(False)

1 Like

Which means actually my answer is wrong here. It can, the weights were using are for evaluation though.

@muellerzr
I tried running the style transfer code without:

import torch
data = torch.ones(1000,1000,1000).cuda()

as i didn’t want to abuse it.
But always gave me a cuda memory error when i run - im_feats = feats(style_im)
not sure i understand what is happening?

  1. Is the style image that big ? it is only 1000 x 824 x 3
  2. When does one use !nvidia-smi?
    only thing i could understand was P100 was being used. Is this command more suited to run from the terminal ?

Yes, occasionally I’d get CUDA issues. It’s probably due to the original image size, restarting a few times seemed to help. Unsure to why it’s needed though.

And yes, it’s a terminal command :wink: the only bit we care about is the GPU were using

1 Like

So from my understanding for the style transfer task - setting .eval or putting it in torch.no_grad should give us the same results right ?