This source code file contains our implementation of a CNN class, which consist of methods to interact with our implemented Convolutional Neural Network for the image recognition task. We had 2 implementations of the CNN used, one of which accepts grayscale images as input and the other accepts coloured images as input. The final CNN architecture we went with was the one that accepts coloured images as input, and its architecture are documented on this page.
Convolutional Neural Network Architecture Diagram
CNN Class Methods
- __init__(self, version) – Constructor of the CNN object. Based on the given type of CNN we want to use (grayscale or coloured), it looks up the corresponding weights. The coloured version of CNN were trained on 1781 images that we had collected.
- predict(self, graph, frame) – This method returns the class prediction based on the given image, along with its probability. The class labels are as follows.
['a', 'b', 'c', 'circle', 'd', 'down', 'e', 'five', 'four', 'left', 'one', 'right', 'three', 'two', 'up']
- getLabelBinarizer(self) – Returns the object that maps the one-hot labels to its corresponding class labels.
- getArchitecture(self) – Returns the graph architecture of the CNN.