Skip to content

Commit 61b0e3b

Browse files
committed
updates
1 parent d8f5776 commit 61b0e3b

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ Handwritten digits recognition in C using neural network trained using [MNIST da
1717
- use `make clean && make release` to generate AppImage binary (you have to install `linuxdeploy` and other dependecies using `make install_tools` first)
1818

1919

20+
# GUI
21+
![GUI](./data/assets/C-digit-recognition-example-of-usage.jpg)
22+
23+
## Control
24+
- `left mouse button & drag` to draw
25+
- `right mouse button` to clear the draw space
26+
- `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+
2041
# Libraries
2142
Dependency of the libraries is in this order: `GUI -> ceural -> lag`. For documentation see source code or use IDE (for example vscode).
2243

@@ -36,25 +57,7 @@ Library supports many operations but more development is needed because currentl
3657
## Ceural
3758
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.
3859

39-
# GUI
40-
![GUI](./data/assets/C-digit-recognition-example-of-usage.jpg)
41-
42-
## Control
43-
- `left mouse button & drag` to draw
44-
- `right mouse button` to clear the draw space
45-
- `middle mouse button or Recognise button in the GUI` to run recognition process
4660

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
5861

5962
# Accuracy
6063
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

Comments
 (0)