A lightweight C++ library for performing high-performance inference on MNIST handwritten digits using a modified AlexNet architecture. Designed for efficiency and educational purposes, this project demonstrates how classic CNNs can be optimized for small-scale tasks in native environments.
-
C++17 implementation for bare-metal performance
-
Simplified AlexNet for 28×28 grayscale images
-
Parallel computing via Intel OneTBB (Threading Building Blocks)
-
Pre-trained model: AlexNet-model.h5 included
You need to download Alexnet-model.h5 to the folder docs
- Make sure you install the project dependencies by running: pip install -r requirements.txt
- You need to run the script parser.py that is located in app/AlexNet to read weights from a model Alexnet-model.h5 and the json file with the weights will be stored in the docs folder.
- Then put the test images in png format in the folder docs/input
- After building the project, which is described below, run Graph_build in folder build/bin
To build and run this project locally on Windows, follow these steps:
-
Clone the repository:
Clone this repository to your local machine using the following command:git clone https://github.com/embedded-dev-research/itlab_2023.git
-
Update submodules: Navigate to the project directory and update the submodules:
git submodule update --init --recursive
-
Configure the project: Create a separate directory for configure the project and compile it:
mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release
If you want to build in a Debug, change the Release to Debug
Note: Make sure you have CMake installed to build the project.
-
Build the project: Next, to build the project, we will need to enter the command
cmake --build . --config Release
-
Run the project After building the project, you can find the executable file in the following path from the build folder
cd build/bin
and run the file
Graph_Build.exe
To build and run this project locally on Linux or macOS, follow these steps:
- Clone the repository:
Clone this repository to your local machine using the following command:git clone https://github.com/embedded-dev-research/itlab_2023.git
- Update submodules:
Navigate to the project directory and update the submodules:
git submodule update --init --recursive
- Install necessary dependencies:
- OpenMP Debian/Ubuntu:
macOS:sudo apt-get install -y libomp-dev
brew install libomp
- Configure the project:
Create a separate directory for configure the project and compile it:
Note: Make sure you have CMake installed to build the project. For macOS need to specify the path to omp.h file:
cmake -S . -B build
cmake -S . -B build -DCMAKE_CXX_FLAGS="-I$(brew --prefix libomp)/include" -DCMAKE_C_FLAGS="-I$(brew --prefix libomp)/include"
- Build the project:
Next, to build the project, we will need to enter the command
If you want to build in a Debug, change the Release to Debug
cmake --build build --config Release
- Run the project
After building the project, you can find the executable file in the following path from the build folder
and run the file
cd build/bin
./Graph_Build
This project contains tests to verify functionality. To test the project, the Google Test Framework is used as a submodule of the project.
Google Test is a powerful framework for unit testing in C++. In this project, Google Test is a submodule. When building the project, you have already updated it, and it is ready for use.
To start the testing process locally, you need to go to the directory
cd build/bin
and run the following files:
run_test.exe
To start the testing process locally, you need to go to the directory
cd build/bin
and run the following files:
chmod +x run_test
./run_test
To run accuracy validation you need to use the MNIST dataset, which you can download here and put it in a folder docs/mnist/mnist/test Now you can run accuracy check - build\bin\ACC_MNIST.exe
- The accuracy should be 98.02%