// OTHERS

Product Image Classification II

A computer vision project for classifying e-commerce product images using PyTorch and pre-trained ResNet models as part of the Shopee Code League.

ROLEParticipant / Developer
TEAMSolo project
CONTEXTShopee Code League
CREATED2020
PythonPyTorchTorchvisionResNet18PILNumPyPandastqdm

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 product images from an e-commerce dataset into their corresponding product categories.

The project uses PyTorch and pre-trained ResNet models to apply transfer learning to the image classification problem.

Technical approach

The project focuses on:

  • Preparing and augmenting product images for training
  • Using PIL for image loading and preprocessing
  • Using PyTorch and Torchvision for model development and training
  • Applying a pre-trained ResNet18 model through transfer learning
  • Training the model to classify products into 42 categories
  • Evaluating the model using Top-1 accuracy
  • Generating predictions for unseen product images
  • Processing CSV files and predictions using Pandas

Machine learning approach

The project uses supervised image classification to predict the category of each product image.

A pre-trained ResNet model is used as the foundation for the classifier, allowing the project to leverage features learned from a larger image dataset rather than training an image classification model entirely from scratch.

Dataset

The challenge provides separate training and testing data consisting of product images and their associated labels.

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
  • PyTorch
  • PIL
  • NumPy
  • Pandas
  • tqdm

Running the project

After downloading and placing the required dataset files in the project directory:

  1. Run pytorch.py to perform the model-related processing.
  2. Run run.py to generate the final predictions.

Lessons learned

This project gave me practical experience with computer vision and supervised machine learning using PyTorch.

It also introduced me to transfer learning with pre-trained neural network architectures and the process of preparing image datasets for classification tasks.