<commit_before>## Smart Stylus™
An offline handwriting recognition pen like hardware and tensorflow based model implementation that will type what you write with it. Right now it supports english alphabets and numbers. That are 62 symbols!


#### Screenshot
##### Smart Stylus™ from scratch
![Hardware](http://i.imgur.com/5clAtPc.png)
##### Trained Model in Action
![Stylus in Action](http://i.imgur.com/U7bQRkW.png)

#### Basic Hardware Concept
The circuitry used by a mouse for recognizing and tracking movement have been embedded in the structure of a pen . Thus ,when you use the pen to write the CNN converts them to letters and produces a typed result.  



#### Model
##### Structure
- Convolution Layer
	- 16 3x3 Filters
- Max Pool
	- 3x3 Same Padding
- Rectified Linear Unit
- Convolution Layer
	- 10 3x3 Filters
- Max Pool
	- 2x2 Same Padding
- Rectified Linear Unit
- Inception 16 filters
- Fully Connected
	- 1 Hidden Layer, 500 Neurons
	- TanH activation
- Softmax Layer
##### Can I edit the model?
Yes, Model structure is stored seperately in ```models/cnn.py```. ```Train.py``` expects following function from a model script

```def create_network(img_height, img_width, num_classes)```

And it should return ```x, y, y_true, optimizer```
##### How can train the new model?
```train.py``` has been designed to aid this by using preconfigured values and training method. You can expect a detailed explanation of different parameters by typing ```train.py --help```.
examples
- ```train.py --show```
	- Show loaded training data
- ```train.py --train```
	- Train model
- ```train.py --restore save/validations```
	- Test model
#### Dataset
##### About
We're using public dataset [Chars74K](http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/)
- It contains 62 classes [A-Za-z0-9]
- It has 55 samples per class
- All images are of fixed resolution 1200x900
##### How to download dataset?
You can download and unzip dataset by running ```dataset.sh``` shell script.
##### Preprocessing
We're are preprocessing dataset because of various reasons
- We can reduce dimensions
- We can eliminate empty spaces
- We don't need 3 channels
- Samples are not properly scaled
- Too big to fit into memory and train on home pc
##### Stages of normalization
- Bounding box calculation
- Samples croping
- Reducing channels
- Scale to fit properly in maximum bounding box
- Dimensions Reduction
##### How to preprocess data ?
You can preprocess data after downloading dataset by executing ```python normalize.py```
- It expects that system has all the dependencies installed
	- ```pip3 install -r requirements.txt```
	- ```bash ./dataset.sh```

It will create two files ```normalized-train.bin``` & ```normalized-val.bin``` under ```dataset``` directory.
##### Normalized dataset
![Normalized dataset](http://i.imgur.com/FwmpAHn.png)

#### Project
This is a part of Academic Project Report under **Practical Training** (COE-320) at [**NSIT**](www.nsit.ac.in).

#### Contributors
- <NAME>
- <NAME>
- [<NAME>](https://twitter.com/amaneureka)

#### License
MIT &copy; <NAME>
<commit_msg>fix #2 making steps more clear as to how you normalize the data<commit_after>## Smart Stylus™
An offline handwriting recognition pen like hardware and tensorflow based model implementation that will type what you write with it. Right now it supports english alphabets and numbers. That are 62 symbols!


#### Screenshot
##### Smart Stylus™ from scratch
![Hardware](http://i.imgur.com/5clAtPc.png)
##### Trained Model in Action
![Stylus in Action](http://i.imgur.com/U7bQRkW.png)

#### Basic Hardware Concept
The circuitry used by a mouse for recognizing and tracking movement have been embedded in the structure of a pen . Thus ,when you use the pen to write the CNN converts them to letters and produces a typed result.  



#### Model
##### Structure
- Convolution Layer
	- 16 3x3 Filters
- Max Pool
	- 3x3 Same Padding
- Rectified Linear Unit
- Convolution Layer
	- 10 3x3 Filters
- Max Pool
	- 2x2 Same Padding
- Rectified Linear Unit
- Inception 16 filters
- Fully Connected
	- 1 Hidden Layer, 500 Neurons
	- TanH activation
- Softmax Layer
##### Can I edit the model?
Yes, Model structure is stored seperately in ```models/cnn.py```. ```Train.py``` expects following function from a model script

```def create_network(img_height, img_width, num_classes)```

And it should return ```x, y, y_true, optimizer```
##### How can train the new model?
```train.py``` has been designed to aid this by using preconfigured values and training method. You can expect a detailed explanation of different parameters by typing ```train.py --help```.
examples
- ```train.py --show```
	- Show loaded training data
- ```train.py --train```
	- Train model
- ```train.py --restore save/validations```
	- Test model
#### Dataset
##### About
We're using public dataset [Chars74K](http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/)
- It contains 62 classes [A-Za-z0-9]
- It has 55 samples per class
- All images are of fixed resolution 1200x900
##### How to download dataset?
You can download and unzip dataset by running ```dataset.sh``` shell script.
##### Preprocessing
We're are preprocessing dataset because of various reasons
- We can reduce dimensions
- We can eliminate empty spaces
- We don't need 3 channels
- Samples are not properly scaled
- Too big to fit into memory and train on home pc
##### Stages of normalization
- Bounding box calculation
- Samples croping
- Reducing channels
- Scale to fit properly in maximum bounding box
- Dimensions Reduction
##### How to preprocess data ?
You can preprocess data after downloading dataset by executing ```python normalize.py```
- It expects that system has all the dependencies installed
	- ```pip3 install -r requirements.txt```
	- ```bash ./dataset.sh```
	- ```python normalize.py```

It will create two files ```normalized-train.bin``` & ```normalized-val.bin``` under ```dataset``` directory.
##### Normalized dataset
![Normalized dataset](http://i.imgur.com/FwmpAHn.png)

#### Project
This is a part of Academic Project Report under **Practical Training** (COE-320) at [**NSIT**](www.nsit.ac.in).

#### Contributors
- <NAME>
- <NAME>
- [<NAME>](https://twitter.com/amaneureka)

#### License
MIT &copy; <NAME>

{'fraction_non_alphanumeric': 0.12205292702485966, 'fraction_numerical': 0.014274258219727345, 'mean_word_length': 4.2624472573839665, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5337928', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1759, 'n_words': 774}