Hello Everyone. I am currently in the third lecture of “Practical Deep Learning for Coders” and I am happy to present you a simple application that upon a given front-faced human image, can detect the age of the person in the image. This is based on this Hackathon by Analytics Vidhya. You can find the web app’s demo here: https://www.loom.com/share/587a722d8a644ceeb80748a28356109f. The code for the webapp is taken from Lecture 2 of “Practical Deep Learning for Coders” where @jeremy discusses how to take models to production.
This project is special to me for a number of reasons:
- I started out with this problem statement about two years ago with a basic understanding of convolutions. Upon seeing the scores, I feel glad that I have improved over time. I have pushed all of my notebooks here in this repo.
- The training dataset has got a number of problems, the worst of which is label noise. I addressed some of these issues in the latest notebook (removing images with wrong labels, relabeling images, removing duplicates, removing extremely hazy images). Below you can see a very small sample of the dataset:
I am glad that I could utilize the lessons learned in the fastai deep learning course (just till the third video). - Wrote a small utility for using the
learner
object to predict on the entire test-set:
import pandas as pd
import os
def predict_test(test_id_path):
labels = []
# '/home/jupyter/Age-Detection-of-Indian-Actors/sub/sub02.csv'
# test_id_path contains the file names of the test images
test_csv = pd.read_csv(test_id_path)
for img_name in test_csv.ID:
img_path = os.path.join('/home/jupyter/Age-Detection-of-Indian-Actors', 'Test', img_name)
img = open_image(img_path)
pred_class, _, _ = learn.predict(img)
labels.append(pred_class)
# Replace the 'Category' word
labels = list(map(lambda x: str(x).replace('Category', ''), labels))
return labels
- I was able to climb up the leaderboard from 82 to 41 with just an hour of fiddling around (this is secondary but I wanted to share this).
Most importantly I got to learn so much in much less amount of time and this has given me a decent amount of confidence. With more deliberate practice and study, I wish to present you with more sensible projects. Thank you @jeremy thank you fastai community. I am truly grateful
Bonus: I made a quick REST API of my model as well. Used the load_learner()
function for the model loading. Used FloydHub serving jobs for deploying the model as a REST API. The process was extremely seamless. Here’s the repo link and it contains a demo of the REST API in Postman as well.