Learn practical skills, build real-world projects, and advance your career

Image Classification with Logistic Regression on American Sign Language (MNIST Dataset)

This is python script is made using PyTorch and logistic regression to solve the problem of image classification. The Sign Language MNIST dataset is used for training and testing the model.
alt
Image Source

The standardized MNIST image dataset of handwritten digits is well known for image-based machine learning methods used but researchers have renewed efforts to update it and developed drop-in replacements. One of them is the Sign Language MNIST whcih is basically a American sign Language letter Database of Hand gestures with 24 classes of letters excluding J and Z which require motion.

Each training and test case represents a label (0-25) as a one-to-one map for each alphabetic letter A-Z (and no cases for 9=J or 25=Z because of gesture motions). The training data (27,455 cases) and test data (7172 cases) are approximately half the size of the standard MNIST but otherwise similar with a header row of label, pixel1,pixel2….pixel784 which represent a single 28x28 pixel image with grayscale values between 0-255.

The original hand gesture image data represented multiple users repeating the gesture against different backgrounds.

The most powerful tools used are the packages `Numpy` and `Pandas`, and to visualize and explore the data: `Matplotlib`, to use the machine learning function: `PyTorch` and `Torchvision`

Table of Contents (Overview)

1. Hyperparameters and other constants.

2. Reading the Datasets

3. Converting the Pandas DataFrame to Numpy Arrays.

4. Conversion of Numpy Arrays to Pytorch tensors Datasets.

5. Training, Validation,Testing Datasets and DataLoaders.

6. Model.

7. Traning.

8. Predictions.

# Uncomment and run the commands below if imports fail
# !conda install numpy pytorch torchvision cpuonly -c pytorch -y
# !pip install matplotlib --upgrade --quiet
!pip install jovian --upgrade --quiet

Importing all the Packages required!