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

So, there’s a few bits you’re missing :slight_smile: Our Blocks that we normally do add two super important transforms:

  1. ToTensor
  2. IntToFloatTensor

These are very very important transforms and do just what they describe. Here is your full pipeline with that:

item_tfms = [Resize(460), ToTensor()]
batch_tfms = [IntToFloatTensor(), *aug_transforms(size=224), Normalize.from_stats(*imagenet_stats)]
dsets = Datasets(items, tfms=[[PILImage.create], [parent_label, MultiCategorize()]])
dls = dset.dataloaders(after_item = item_tfms, after_batch=batch_tfms, bs=64

From here building the test_dl is:

test_dl = dls.test_dl(get_image_files(path), with_labels=True)

(Also sorry I left out the with_labels part originally there)

@mgloria @AjayStark here is the link to the stream:

It will be Sunday @ 2:00pm CST

3 Likes

@muellerzr Hi Zach, I have been following your videos and getting some very good info out of them! Thank you very much! In particular, I have been trying to follow the style transfer video and the reason is that Jeremy uses a similar approach in the Course V3 Lesson about No-GAN super-resolution using the same Feature preservation analogy you use in your video. I have an application where I’m trying to use UNETs to remove some noise from CT data and that approach worked great for me. However, I’m trying to follow what you did to do a FastAI v2 version of the same nb but I’m not very experienced and I’m getting lost in the details. I can see where all the basic blocks are but I can’t piece them together. Do you have any advice on how I can structure the FeatureLoss module to use on this application? Any advice is appreciated :slight_smile:

If you check the course notebooks in the fastai2 repo, every v3 notebook is converted :slight_smile: , so the GAN-based feature preservation notebook should be there. If you can’t find it I’ll try looking later today

Hi there, I am trying to implement the error_rate metric in the Retinanet notebook and have tried:
learn = Learner(data, model, loss_func=crit, metrics = error_rate) and
learn = Learner(data, model, loss_func=crit, metrics = error_rate())
the learning rate finder does display an error rate, but when running learn.fit_one_cycle(5, 1e-4)
I receive the error: fastai TypeError: “error_rate() takes 2 positional arguments” but 3 were given
Does anyboy know how to get this metric to work with the multiple object detection, Retinanet notebook?
Thank you :slight_smile:

It doesn’t. Object detection needs special metrics to work well, hence why we only have our loss function. I’d recommend asking in this thread here about other metrics that could work.

Thank you very much, I was just looking for a metric to use where I could monitor error rate or accuracy but been having trouble. I am looking to use callbacks to save the best epoch and was going to use error_rate to keep my eye on but maybe I could do this with validation loss instead.

Thanks a lot! I just found out about this.

1 Like

Hi, does anyone know how to get the decoded predictions using learn.tta()?

I know that you can pass in with_decoded=True when using:
_, _, preds = learn.get_preds(dl=test_dl, with_decoded=True)

But learn.tta() does not have this parameter with_decoded?

You can’t basically. How far decoded are you wanting? I can help with getting you there :slight_smile: (I may also look at this in fastinference in a moment too)

1 Like

For now not really :sweat_smile:. For the simple decoding like taking argmax of the predictions, I can simply write one extra line. But just curious why this option is not available for learn.tta?

1 Like

Because get_preds only has access to learn.loss_func’s decodes, so it’ll always run the softmax IIRC from your loss function. (Presuming their thought process here)

1 Like

@muellerzr is there a way to get the decoded labels with a multi label model in preds[0]? right now the decoded labels are in preds[2][1] as far as I could see. I could just grab them from there but preds[0] (just like for classification labels) would be easier :slight_smile: .

Not right now, however that is something that definitely be a thing for multi-label. Let me see what I can do :slight_smile: (I noticed this before too, on my todo list :slight_smile: )

1 Like

I’ve added a minor change to the style-transfer notebook, to fix the slightly ‘off’ colours seen in the output generated from the second method (not via predict directly). Instead of showing the output activations directly as an image, they need to be ‘decoded’ first using the ‘reverse-tfms’ that are already in the dataloader. (Though arguably the colour-changes seen can be regarded as a ‘feature’ and not a ‘bug’! =P )

See my pull request here. It’s just a couple of lines, pasted below.

dec_res = dl.decode_batch(tuplify(res))[0][0]
dec_res.show();

There might be easier / more direct way of decoding the activations to show, but I am not sure how.

Yijin

2 Likes

Hi, I’m trying to fine-tune the pretrained xresnet50 on the IMAGEWOOF dataset, but it could not reach the same accuracy level as my baseline pretrained resnet50. Could someone give me some advice on this?

Here is the notebook that I used: XResNet

Quick question.
Is there a way to plot CAM on fastai2? To get where the model is focusing?

Is this what you need @tcapelle?

1 Like

I was sure to have seen that!