Skip to content

keenu01/KMNIST_CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 KMNIST CNN Classifier

A simple convolutional neural network built with PyTorch to classify Japanese Hiragana characters from the KMNIST dataset. This project demonstrates basic image classification on a non-Latin dataset using a custom CNN.


πŸ“Œ Project Overview

  • πŸ”€ 10-class classification task (Hiragana characters)
  • πŸ“ˆ Trained with PyTorch on CPU
  • πŸ§ͺ Evaluates accuracy and visualizes correct vs. incorrect predictions
  • πŸ–ΌοΈ Uses Matplotlib to plot prediction results

🧱 Model Summary

The CNN model is defined in model.py and includes:

  • 5 convolutional layers with ReLU activation
  • Max pooling after each conv layer
  • Fully connected layers with ReLU
  • nn.LazyLinear used for dynamic input sizing

Example:

model = CNN(input_layer=1, hidden_layer=200, output_layer=10)

πŸ§ͺ Example Output

After training, a 5Γ—5 grid shows predictions:

  • βœ… Green titles: Correct predictions
  • ❌ Red titles: Incorrect predictions

Prediction Grid


πŸš€ Getting Started

1. Clone this repository

git clone https://github.com/your-username/kmnist-cnn-classifier.git
cd kmnist-cnn-classifier

2. Install requirements

pip install -r requirements.txt

On Windows, if you encounter SSL certificate issues with KMNIST, add this in your code:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

3. Run training

python main.py

🧾 Requirements

Listed in requirements.txt:

  • torch>=2.0.0
  • torchvision>=0.15.0
  • matplotlib>=3.5.0

πŸ“ Project Structure

β”œβ”€β”€ main.py              # Training and evaluation loop  
β”œβ”€β”€ model.py             # CNN model definition  
β”œβ”€β”€ images/              # (Optional) folder for output plots  
β”œβ”€β”€ data/                # Auto-downloaded KMNIST dataset  
β”œβ”€β”€ requirements.txt     # Package dependencies  
└── README.md

🧠 Credits

  • KMNIST dataset from ROIS-DS Center for Open Data in the Humanities
  • Built using PyTorch and Matplotlib

πŸ“œ License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages