A Deep Learning Classifier for FIFA vs Real Football

FIFA or Not? Try it out on www.rish.space/fifa-or-real


I took up the FastAI course a week ago to finally do some hands-on, state of the art, 10-lines-of-code-does-it-all deep learning. I took up many courses in college, joined Kaggle a good 4 years ago (sigh - the only problem I ever solved was the Titanic dataset and honestly didn't find it as fun as making an Android app), and now that I've made up my mind to do more DL, I want a taste of a regular deep learner engineer's everyday job. More on that later, this post is just about identifying whether an image is from FIFA or not.

Here's the why:
I've played FIFA all my life, starting with FIFA 2001 on my PlayStation2. By the time FIFA06 came out, my father used to say it was hard to make out from afar whether I was playing or watching football on TV. And so, I thought it'd be fun to see if a computer could do this.

What I did:
1. Ran a script to scrape URLs of the top 200 images on Google Images for FIFA, and another 200 on the English Premier League and the world cup in 2018.
2. Put up all the URLs of one kind in a single csv file.
3. Used resnet34 because pretrained neural networks that already know a lot of things do a great job at learning new things.
4. Used fastai's cnn_learner for doing transfer learning for 10 epochs, doubled the size of the images, fine-tuned a little. [The italics because it's really not as fancy as it sounds.]
5. Exported the model file and created the webapp on my website. Source code on GitHub!

HOSTING WAS A PAIN!
Aaaaaagh uploading this to my website took me the whole weekend! Worked on my machine. Thought it'd be a 10-minute job on Heroku. 😠
PyTorch, Numpy and Scipy together take up 450MB, leaving me no space to host the web app on Heroku.* I ended up doing this:
1. Compressing all images using tinypng because it just does such a great job. I made a simple commandline tool for it.
2. Compressing all videos using ffmpeg. It does such a great job at it.
3. Used the CPU only version of PyTorch and made sure not to freeze my dependencies into the requirements.txt, and used

Aaaand why it fails:
xD couldn't be more precise.

- Technically, this isn't a regular classifier. You're not looking for cars in an image. You're looking at the image on the whole. The cnn_learner is looking for patterns/similarities/common shapes in all the images, but my data set didn't exactly have the same shapes/objects in the images.
- I'd say this problem is similar to trying to classify black and white images from color images. If the network doesn't realize you're asking it to observe the colors, it'll most likely end up finding other patterns in your dataset.
- Which is what led me to trying to classify thermal images from visible light images, and it failed miserably too. But I'm going to stick at it and hopefully by the end of the course I'll be able to come up with something I'm happy with!

-

* In a good world Heroku should just have Docker images for regularly used dependencies and they shouldn't count in my Heroku hosting space. 

Comments

Popular posts from this blog

Firebase Auth | The Debug vs Release Signature Problem

I'm now an Estonian eResident!