This project aims to train two Convolutional Neural Networks (CNNs): 'Hand Digit Recognition' and 'Cats and Dogs Classification.' The models will then be deployed on a Raspberry Pi to perform inference through PiCamera.
The Hand Digit Classifier was required to have an accuracy of
Both models were deployed on the same device. The products and their specifications are:
- Raspberry Pi 4 - Model B - 2GB RAM - 64-bit quad-core Cortex-A72 Processor
- Raspberry Pi Camera Module - imx219
The software specifications along with the Python libraries are:
- Raspbian 32-bit OS, Bookworm
- Python 3.7.12
- TensorFlow 2.4.0
- Keras Preprocessing
- OpenCV
- Pyenv for creating a local environment for Python
The dataset used for training the model MNIST. The dataset was split into training and testing, with 60000 images for training and 10000 for testing. The size of the input images was
The model was trained using TensorFlow and Keras on Google Colab. It's a custom model consisting of 4 convolutional layers and 3 dense layers. Max pooling was also used after every convolutional layer.
The dataset used for training consisted of images of cats and dogs. It was split into training, validation, and test subsets with a ratio of 60%-15%-25% using sklearn.model_selection.train_test_split()
function. A total of 10,000 images were used, with 5000 images of cats and 5000 images of dogs. After splitting the data, there were
- 6500 images in the training set
- 1506 images in the validation set
- 1994 images in the testing set
The model was created using TensorFlow and Keras on Google Colab. Ensemble learning was used to get more accurate results. VGG-16 was used and on top of that, 2 fully connected layers were added along with a Dropout layer of
To use the Raspberry Pi for image classification, a virtual environment with an older version of Python was used. The instructions are provided here.
After setting up the environment, run this command in the virtual environment.
pip install -r setup/requirements.txt
Contributions: All of the code was written by Samiya Ali Zaidi.
Took help from this video to set up the environment.