[Project] Stanford-Cars with fastai v1

First notebook in a series on image classification for the Stanford-Cars data using the fastai v1 library.

Goal is 90%+ accuracy, I’m at 84.95% with this basic version, without any fancy tuning at all!

Amazing to see how small the differences between car models are that the model gets confused by.

Would love to hear any thoughts, questions or feedback!

1 Like

Hi Morgan!

I also made my first notebook on the Stanford-Cars dataset after watching lesson 1. I got the accuracy around 85% too.

If you can share the updated link for your notebook, I would really appreciate it. Currently, the link you shared is broken and shows 404 error.

thanks @gabriel_chen for pointing that out, I fixed the link in the original post, here it is again:

https://github.com/morganmcg1/Projects/blob/master/stanford-cars/1_stanford_cars_basic.ipynb)

Would love to hear how you’re doing on it, I’m up to 88%, still a bit far from my goal of 90+%!

Latest results for Stanford Cars image classification up to 89% using Mixup

Slowly getting to that 90%+ goal! :smiley:

2 Likes

nice work, I learned a lot here

1 Like

Can anyone please tell me how are you guys able to make the databunch because i cant get the classes right because class 1 is supposed to be hummer SUV where as in the images its actually some audi sedan here are the images.
Here are the classes:


The 000001.jpg has the first class:


Whereas actually its this:

Yep I had trouble with this too, @jianshen92 has some nice code here (cleaner than mine :slight_smile: ) which should help with your data import :

Thanks for quoting @morgan. This project was an entry to an AI challenge by Grab, which is the Uber here in Southeast Asia. This submission made it to the top 50, so I’m very grateful for Jeremy and team for creating this library!

Happy to answer any questions regarding my notebook!

1 Like

Nice work! I’m going to run your code in the next day or two and see how it performs, I had been struggling to get over 90%!

Hey @jianshen92, in your notebook above was there a specific reason you trained your model in bursts of 5 epochs? Instead of maybe just doing fit_one_cycle for 25epochs for example? It seems to have worked well so I’m just curious if there is a little trick that I don’t know about :slight_smile:

@morgan It is something I found out empirically and I have no strong mathematical explanation for this :sweat_smile:

When I was experimenting I trained every cycle with 5 epochs because I wanted to try to tune the parameters after every checkpoint to see if the model will improve further without waiting for too long.

One thing for sure though, fitting one cycle for many epoch vs fitting many one_cycle with less epoch, is not exactly equivalent, because of the cyclic momentum and cyclic learning rate within a cycle. Perhaps fitting it for many cycles enable it to search deeper to the hyperspace’s minima because of the multiple cycle of increasing and decreasing learning rate.

Just a guess anyway!

1 Like

Nice! I get the practicality of it, I’ll be sure to remember to try it in other projects! I’m trying to run your notebook now, starting with Facebooks’s ResNext 101 WSL model (trained on 840m Instagram images and fine-tuned on Imagenet) weights, but I’m hitting OOM errors at the moment. Will keep trying reducing the batch size and/or use a smaller model version :smiley:

I tried with ResNext too but just with the one provided by torch.vision. End up not using it because improvements are very minimal, like .05 % increase in accuracy but train much longer.

Let me know how it goes for you!

1 Like

Updating progress here, current accuracy at 93.29% (with TTA), 93.19% without. Using the SQUISH resize transform as well as paying more attention to the LR at each stage really helped here!

1 Like

Hey congrats for pushing it up to 93%. As far as i know, the SOTR accuracy for this dataset is at 94.8% according to here https://paperswithcode.com/sota/fine-grained-image-classification-on-stanford

1 Like

Thanks! Yep I just started playing around with EfficientNet to see how close I can get to their SOTA on stanford cars. EfficientNets seem tricky to train though, have you tried them? will keep playing around :smiley:

Thats awesome! Can you describe abt what you mean by “paying more attention to the LR at each stage really helped here!”? What did you observe and then change?

Thanks @bluesky314, just that I trained for a smaller set of epochs (5 or sometimes 10) and then ran lr_find() again to see if it suggested I needed to change the learning rate, I more or less copied how @jianshen92 had done it :slight_smile:

Haven’t tried the EfficientNet, haven’t been working on this project ever since the competition has ended. I admire your perseverance on this!

Recently there is this Radam and LookAhead optimizer that just came out and the community almost says that it guarantees improvement in accuracy and allows us to use a higher learning rate. I think it is worth a try!

Thanks @jianshen92, I think I am just too unimaginative to try something else :smiley: Have been trying Radam + LookAhead (Ranger) alright, RangerLars looks like it should be better again from the discussion here: https://forums.fast.ai/t/imagenette-woof-leaderboards-guidelines-for-proving-new-high-scores/52714/57:

RangerLars: https://github.com/lessw2020/mish/blob/master/rangerlars.py

Have you seen this new Mish activation too? Going to swap it in the EfficientNet and see how it goes: Meet Mish: New Activation function, possible successor to ReLU?

Crazy time for new techniques!!