You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-18Lines changed: 21 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,27 @@ Handwritten digits recognition in C using neural network trained using [MNIST da
17
17
- use `make clean && make release` to generate AppImage binary (you have to install `linuxdeploy` and other dependecies using `make install_tools` first)
-`middle mouse button or Recognise button in the GUI` to run recognition process
27
+
28
+
## Processing of the drawn image
29
+
Preprocessing used in [MNIST](http://yann.lecun.com/exdb/mnist/) database: *The original black and white (bilevel) images from NIST were size normalized to fit in a 20x20 pixel box while preserving their aspect ratio. The resulting images contain grey levels as a result of the anti-aliasing technique used by the normalization algorithm. the images were centered in a 28x28 image by computing the center of mass of the pixels, and translating the image so as to position this point at the center of the 28x28 field.*
30
+
31
+
1.**crop calculation** - crop of the whole draw space is calculated from sides until it reaches non white pixels. After that maximum of the width & height of the cropped image is then taken and `crop_x` & `crop_y` & `crop_w` & `crop_h` is recalculated to preserve image ratio.
32
+
2.**sub image generation** - using previous values and drawn image stored in pixbuf sub image is created
33
+
3.**scaling** - previous cropped image is scaled to the `20x20` image
34
+
4.**conversion into grayscale** - pixbuf is converted into `uint8_t` grayscale image
35
+
5.**adding frame** - `4, 4, 4, 4` frame is added to the `20x20` image resulting into `28x28` image
36
+
6.**computation of the center of mass of the pixels** - is done using mean values accross X & Y
37
+
7.**move of the submatrix** - submatrix (drawn number) is moved in the framed image
38
+
8.**neural network forward propagation** - this preprocessed image is fed to the neural network
39
+
40
+
20
41
# Libraries
21
42
Dependency of the libraries is in this order: `GUI -> ceural -> lag`. For documentation see source code or use IDE (for example vscode).
22
43
@@ -36,25 +57,7 @@ Library supports many operations but more development is needed because currentl
36
57
## Ceural
37
58
Ceural library is created for multi-layer networks trained using MNIST dataset but with small modifications it can be used for other datasets too. See [Accuracy](#Accuracy) for more info.
-`middle mouse button or Recognise button in the GUI` to run recognition process
46
60
47
-
## Processing of the drawn image
48
-
Preprocessing used in [MNIST](http://yann.lecun.com/exdb/mnist/) database: *The original black and white (bilevel) images from NIST were size normalized to fit in a 20x20 pixel box while preserving their aspect ratio. The resulting images contain grey levels as a result of the anti-aliasing technique used by the normalization algorithm. the images were centered in a 28x28 image by computing the center of mass of the pixels, and translating the image so as to position this point at the center of the 28x28 field.*
49
-
50
-
1.**crop calculation** - crop of the whole draw space is calculated from sides until it reaches non white pixels. After that maximum of the width & height of the cropped image is then taken and `crop_x` & `crop_y` & `crop_w` & `crop_h` is recalculated to preserve image ratio.
51
-
2.**sub image generation** - using previous values and drawn image stored in pixbuf sub image is created
52
-
3.**scaling** - previous cropped image is scaled to the `20x20` image
53
-
4.**conversion into grayscale** - pixbuf is converted into `uint8_t` grayscale image
54
-
5.**adding frame** - `4, 4, 4, 4` frame is added to the `20x20` image resulting into `28x28` image
55
-
6.**computation of the center of mass of the pixels** - is done using mean values accross X & Y
56
-
7.**move of the submatrix** - submatrix (drawn number) is moved in the framed image
57
-
8.**neural network forward propagation** - this preprocessed image is fed to the neural network
58
61
59
62
# Accuracy
60
63
After `10` epochs of training with batch size `32` the test set accuracy is `97.47 %` which is not bad considering the test error rate in [MNIST database website](http://yann.lecun.com/exdb/mnist/) of the 2-layer NN. Sadly accuracy is not as good in practice as it's in the test data set 🥺.
0 commit comments