This project aims to compare the performance of hand-written digit classification Convolutional Neural Network (CNN) models in parallel and sequential modes. Two scripts, classify_parallel.py and classify_sequential.py, are provided for this purpose. The CNN model itself is implemented in the CNN_MNIST.py script.
Make sure you have the following dependencies installed:
- Python (>=3.6)
- NumPy
- PyTorch
- TorchVision
- Matplotlib
- Clone this repository to your local machine using:
git clone https://github.com/kcrmin/CNN_Hardware_Comparison.git
- Install the required Python packages:
pip install -r requirements.txt
- Run the program in sequential mode:
python classify_sequential.py
- Run the program in parallel mode:
python classify_parallel.py
- Defines a CNN model for MNIST digit classification.
- Provides functions for data loading and model initialization.
- Demonstrates parallel processing for predicting MNIST digits using the CNN model defined in
CNN_MNIST.py. - Utilizes the
multiprocessingmodule to parallelize the prediction process, improving efficiency.
- Demonstrates sequential processing for predicting MNIST digits using the CNN model defined in
CNN_MNIST.py. - Does not use parallelization and processes predictions sequentially.
- Pre-trained model weights saved in PyTorch format.
- Although model was trained using CNN_MNIST, had to delete the training functions due to the readability.
- Contains the required Python packages to run the scripts.
- Enhance the usability as it simplifies the setup process.
Before running the scripts, you can configure the meta_data to adjust the parameters according to your requirements. Here's a brief overview of the meta_data configuration:
# Define meta_data
meta_data["batch_size"] = 1
meta_data["num_rows"] = 200
meta_data["num_columns"] = 300
meta_data["num_cells"] = meta_data["num_rows"] * meta_data["num_columns"]
meta_data["threads"] = 2After running each script, the following information will be printed:
- Number of threads used (only applicable for parallel mode)
- Total number of items classified
- Total runtime
- Accuracy
Additionally, the visualization of the mask image representing the classification results will be displayed.