A computer vision project for classifying hand-drawn symbols using a custom ResNet18 model with transfer learning.
This project implements a deep learning model to classify hand-drawn symbols across 10 different categories. The model uses a modified ResNet18 architecture adapted for grayscale images and achieves approximately 81% accuracy on the test set.
- Anchor
- Balloon
- Bicycle
- Envelope
- Paper boat
- Peace symbol
- Smiley
- Speech bubble
- Spiral
- Thumb
cv-ml-project/
├── data/ # Dataset organized by symbol categories
│ ├── anchor/
│ ├── balloon/
│ ├── bicycle/
│ ├── envelope/
│ ├── paper_boat/
│ ├── peace_symbol/
│ ├── smiley/
│ ├── speech_bubble/
│ ├── spiral/
│ └── thumb/
├── models/ # Trained model weights
│ └── best_model_weights.pth
├── notebooks/ # Jupyter notebooks for analysis
│ └── main_analysis.ipynb
├── src/ # Source code
│ ├── data_loader.py # Custom dataset class
│ ├── model.py # Custom ResNet18 implementation
│ └── __pycache__/
├── requirements.txt # Python dependencies
└── README.md # This file
- Python 3.13 (but earlier versions may work)
- CUDA-compatible GPU (optional, but recommended)
- Clone the repository:
git clone <repository-url>
cd cv-ml-project- Install dependencies:
pip install -r requirements.txt- Download the dataset: link to the dataset
Each symbol category should contain images with the following naming conventions:
digit_*.jpg- Digital/computer-generated imagesdrawn_*.jpg- Hand-drawn imagesstamp_*.jpg- Stamp-like images
- Base Model: Pre-trained ResNet18 from ImageNet
- Modifications:
- First convolutional layer adapted for single-channel (grayscale) input
- Final fully connected layer adjusted for 10 classes
- Transfer learning with frozen layers except first conv and final FC layers
- Input: Grayscale images (single channel)
- Output: 10 classes (symbol categories)
- Training Strategy: Transfer learning with selective layer unfreezing
- Data Augmentation: Random rotation (±10°) and translation (±10%)
- Training: 60% of total data
- Validation: 20% of total data
- Test: 20% of total data
- Epochs: 20
- Batch Size: 64
- Optimizer: Adam (lr=0.001)
- Loss Function: CrossEntropyLoss
- Device: CUDA (if available)
- Convert to grayscale
- Normalize to [-1, 1] range
- Random augmentations for training data
- Best Validation Accuracy: ~81%
- Training Strategy: Early stopping based on validation accuracy
- Best Performance: Anchor class
- Challenging Class: Paper boat (often confused with envelope due to visual similarity)