// OTHERS
Product Image Classification I
A computer vision project for classifying e-commerce product images using TensorFlow, Keras, and convolutional neural networks.
Overview
Product Image Classification is a computer vision project created as a solution to a machine learning challenge from the Shopee Code League.
The goal was to classify e-commerce product images into their corresponding product categories using supervised machine learning.
The project uses TensorFlow and Keras to build a Convolutional Neural Network (CNN) for image classification.
Technical approach
The project focuses on:
- Processing and resizing images using OpenCV
- Preparing and normalising image data for training
- Building a CNN using TensorFlow and Keras
- Using convolutional, pooling, batch normalization, and dropout layers
- Training the model on labelled product images
- Splitting the dataset into training and test sets using Scikit-learn
- Evaluating the model using classification accuracy
- Saving the prepared data using Pickle
- Generating predictions for unseen product images
- Processing prediction results using Pandas
Machine learning approach
The project uses a Convolutional Neural Network (CNN) for supervised image classification. The model learns visual patterns from labelled product images and uses them to distinguish between different product categories.
The model was trained on a 90/10 train-test split and evaluated using classification accuracy. Once trained, it was used to generate predictions for the challenge’s unseen test images.
Dataset
The challenge provides labelled training images and a separate set of test images. The training data is organised into category folders, while the test data is provided separately along with a CSV file used to create the final submission.
The required dataset files need to be placed in the expected shopee-product-detection-dataset directory before running the project.
Requirements
The project requires:
- Python 3.x
- TensorFlow
- Keras
- OpenCV
- NumPy
- Pandas
- Scikit-learn
Running the project
After downloading and placing the required dataset files in the project directory:
- Run
data_preparation.pyto load, resize, shuffle, and save the training images as Pickle files. - Run
training.pyto train and evaluate the CNN model and save the trained model. - Run
testing.pyto load the trained model and generate predictions for the test images. - Run
transfer.pyto match the predictions with the provided test CSV and create the final submission file.
Lessons learned
This was my first real experience with image classification and CNNs. I got to work with image data, train a model, and see how well it could recognise different e-commerce products.
It also showed me how much trial and error goes into machine learning. Sometimes the model worked well, sometimes it didn’t, and I had to experiment with the data and tune the model to improve the results.