Skip to content

Commit 01df0b5

Browse files
author
AdamMiltonBarker
committed
Resolves #8 Data Processing/Analysis / Training / Converting and Documentation
1 parent c4c6c00 commit 01df0b5

36 files changed

+6761
-386
lines changed

classifier.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def train(self):
5757
self.model.prepare_network()
5858
self.model.train()
5959
self.model.evaluate()
60-
self.mqtt.disconnect()
6160

6261
def set_model(self):
6362
""" Loads the model class """
@@ -116,11 +115,11 @@ def main():
116115
classifier.inference()
117116

118117
elif mode == "server":
119-
classifier.set_model("CNN")
118+
classifier.set_model()
120119
classifier.server()
121120

122121
elif mode == "classify_http":
123-
classifier.set_model("CNN")
122+
classifier.set_model()
124123
classifier.inference_http()
125124

126125

configuration/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"agent": {
33
"cores": 8,
4-
"server": "",
4+
"ip": "",
55
"port": 1234,
66
"params": [
77
"train",
@@ -16,7 +16,7 @@
1616
"labels": [0, 1],
1717
"rotations": 10,
1818
"seed": 2,
19-
"split": 0.3,
19+
"split": 0.255,
2020
"test": "model/data/test",
2121
"test_data": [
2222
"Im006_1.jpg",

docs/img/plots/accuracy.png

22.8 KB
Loading

docs/img/plots/auc.png

28.5 KB
Loading
8.86 KB
Loading

docs/img/plots/loss.png

28.2 KB
Loading

docs/img/plots/precision.png

31.3 KB
Loading

docs/img/plots/recall.png

30.6 KB
Loading

docs/installation/ubuntu.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,34 @@
33
![ALL Arduino Nano 33 BLE Sense Classifier](../img/project-banner.jpg)
44

55
# Introduction
6-
This guide will guide you through the installation process for the **ALL Arduino Nano 33 BLE Sense Classifier** Project.
7-
8-
<font color='red'>DEVELOPER TO EXPLAIN/UPDATE THE PROJECT DETAILS</font>
9-
10-
&nbsp;
11-
12-
# Prerequisites
13-
You will need to ensure you have the following prerequisites installed and setup.
14-
15-
<font color='red'>DEVELOPER TO EXPLAIN/UPDATE THE PREQUISITE DETAILS</font>
6+
This guide will take you through the installation process for the **ALL Arduino Nano 33 BLE Sense Classifier** trainer.
167

178
&nbsp;
189

1910
# Operating System
20-
The ALL Arduino Nano 33 BLE Sense Classifier Jupyter Notebook supports the following operating system(s).
11+
This project supports the following operating system(s), but may work as described on other OS.
2112

22-
<font color='red'>DEVELOPER TO LIST COMPATIBLE OPERATING SYSTEM(S). MUST BE TESTED BEFORE LISTING</font>
13+
- [Ubuntu 20.04](https://releases.ubuntu.com/20.04/)
2314

2415
&nbsp;
2516

2617
# Software
27-
The ALL Arduino Nano 33 BLE Sense Classifier Jupyter Notebook project uses the following libraries.
28-
29-
<font color='red'>DEVELOPER TO LIST SOFTWARE LIBRARIES USED</font>
18+
This project uses the following libraries.
19+
20+
- Conda
21+
- Intel® oneAPI AI Analytics Toolkit
22+
- Jupyter Notebooks
23+
- NBConda
24+
- Mlxtend
25+
- Pillow
26+
- Opencv
27+
- Scipy
28+
- Scikit Image
29+
- Scikit Learn
3030

3131
&nbsp;
3232

33-
# Installation
34-
You are now ready to install the ALL Arduino Nano 33 BLE Sense Classifier Project.
35-
36-
## Clone the repository
33+
# Clone the repository
3734

3835
Clone the [ALL Arduino Nano 33 BLE Sense Classifier](https://github.com/AMLResearchProject/ALL-Arduino-Nano-33-BLE-Sense-Classifier " ALL Arduino Nano 33 BLE Sense Classifier") repository from the [Peter Moss Acute Myeloid & Lymphoblastic Leukemia AI Research Project](https://github.com/AMLResearchProject "Peter Moss Acute Myeloid & Lymphoblastic Leukemia AI Research Project") Github Organization.
3936

@@ -57,7 +54,7 @@ Using the ls command in your home directory should show you the following.
5754

5855
Navigate to the **ALL-Arduino-Nano-33-BLE-Sense-Classifier** directory, this is your project root directory for this tutorial.
5956

60-
### Developer forks
57+
## Developer forks
6158

6259
Developers from the Github community that would like to contribute to the development of this project should first create a fork, and clone that repository. For detailed information please view the [CONTRIBUTING](https://github.com/AMLResearchProject/ALL-Arduino-Nano-33-BLE-Sense-Classifier/blob/master/CONTRIBUTING.md "CONTRIBUTING") guide. You should pull the latest code from the development branch.
6360

@@ -67,20 +64,33 @@ Developers from the Github community that would like to contribute to the develo
6764

6865
The **-b "1.0.0"** parameter ensures you get the code from the latest master branch. Before using the below command please check our latest master branch in the button at the top of the project README.
6966

70-
## Installation script
71-
All software requirements are included in **scripts/install.sh**. You can run this file on your machine from the project root in terminal. Use the following command:
67+
&nbsp;
7268

69+
# Installation
70+
You are now ready to install the ALL Arduino Nano 33 BLE Sense Classifier trainer. All software requirements are included in **scripts/install.sh**. You can run this file on your machine from the project root in terminal. Use the following command:
71+
72+
``` bash
7373
sh scripts/install.sh
74+
```
75+
76+
**WARNING:** This script assumes you have not already installed the oneAPI Basekit.
77+
78+
**WARNING:** This script assumes you have not already installed the oneAPI AI Analytics Toolkit.
79+
80+
**WARNING:** This script assumes you have an Intel GPU.
81+
82+
**WARNING:** This script assumes you have already installed the Intel GPU drivers.
7483

75-
<font color='red'>DEVELOPER TO PROVIDE FULL INSTALLATION INSTRUCTIONS</font>
84+
**HINT:** If any of the above are not relevant to you, please comment out the relevant sections below before running this installation script.
7685

7786
&nbsp;
7887

79-
## Configuration
88+
# Continue
8089

81-
All configuration can be found in the **configuration/config.json** file.
90+
Choose one of the following usage guides to train your model:
8291

83-
<font color='red'>DEVELOPER TO EDIT CONFIG FILE AND PROVIDE FULL DESCRIPTION OF CONFIGURATION</font>
92+
- [Python Usage Guide](../usage/python.md)
93+
- [Jupyter Notebooks Usage Guide](../usage/notebooks.md)
8494

8595
&nbsp;
8696

docs/usage/notebooks.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Notebooks Usage
2+
3+
![ALL Arduino Nano 33 BLE Sense Classifier](../img/project-banner.jpg)
4+
5+
# Introduction
6+
This guide will take you through using the **ALL Arduino Nano 33 BLE Sense Classifier** Jupyter Notebook to train and test your classifier.
7+
8+
&nbsp;
9+
10+
# Installation
11+
First you need to install the required software for training the model. Below are the available installation guides:
12+
13+
- [Ubuntu installation guide](../installation/ubuntu.md).
14+
15+
&nbsp;
16+
17+
# Network Architecture
18+
We will build a Convolutional Neural Network with the following architecture:
19+
20+
- Average pooling layer
21+
- Conv layer
22+
- Depthwise conv layer
23+
- Flatten layer
24+
- Fully connected layer
25+
- Softmax layer
26+
27+
&nbsp;
28+
29+
# Data
30+
You need to be granted access to use the Acute Lymphoblastic Leukemia Image Database for Image Processing dataset. You can find the application form and information about getting access to the dataset on [this page](https://homes.di.unimi.it/scotti/all/#download) as well as information on how to contribute back to the project [here](https://homes.di.unimi.it/scotti/all/results.php).
31+
32+
_If you are not able to obtain a copy of the dataset please feel free to try this tutorial on your own dataset._
33+
34+
Once you have your data you need to add it to the project filesystem. You will notice the data folder in the Model directory, **model/data**, inside you have **train** & **test**. Add all of the images from the ALL_IDB1 dataset to the **model/data/train** folder.
35+
36+
## Data Augmentation
37+
38+
We will create an augmented dataset based on the [Leukemia Blood Cell Image Classification Using Convolutional Neural Network](http://www.ijcte.org/vol10/1198-H0012.pdf "Leukemia Blood Cell Image Classification Using Convolutional Neural Network") by T. T. P. Thanh, Caleb Vununu, Sukhrob Atoev, Suk-Hwan Lee, and Ki-Ryong Kwon.
39+
40+
## Application testing data
41+
42+
In the data processing stage, ten negative images and ten positive images are removed from the dataset and moved to the **model/data/test/** directory. This data is not seen by the network during the training process, and is used to test the performance of the model.
43+
44+
To ensure your model gets the same results, you should use the same test images. You can also try with your own image selection, however results may vary.
45+
46+
&nbsp;
47+
48+
# Start Jupyter Notebooks
49+
Now you need to start Jupyter Notebooks. In your project root execute the following command, replacing the IP and port as desired.
50+
51+
``` bash
52+
jupyter notebook --ip YourIP --port 8888
53+
```
54+
55+
&nbsp;
56+
57+
# Open The Training Notebook
58+
59+
Navigate to the URL provided when starting Jupyter Notebooks and you should be in the project root. Now navigate to **notebooks/classifier.ipynb**. With everything set up you can now begin training. Run the Jupyter Notebook and wait for it to finish.
60+
61+
&nbsp;
62+
63+
# Preparing For Arduino
64+
65+
During training the model was converted to TFLite and optimized with full integer quantization. The TFLite model was then converted to C array ready to be deployed to our Arduino Nano 33 BLE Sense. The test data that was removed before training was converted to 100px x 100px so as not to require additional resizing on the Arduino.
66+
67+
&nbsp;
68+
69+
# Conclusion
70+
71+
Here we trained a deep learning model for Acute Lymphoblastic Leukemia detection utilizing Intel® Optimization for Tensorflow* from the Intel® oneAPI AI Analytics Toolkit to optimize and accelarate training. We introduced a 6 layer deep learning model and applied data augmentation to increase the training data.
72+
73+
We trained our model with a target of 150 epochs and used early stopping to avoid overfitting. The model trained for 27 epochs resulting in a fairly good fit, and accuracy/precision/recall and AUC are satisfying. In addition the model reacts well during testing classifying each of the twenty unseen test images correctly.
74+
75+
&nbsp;
76+
77+
# Continue
78+
79+
Now you are ready to set up your Arduino Nano 33 BLE Sense. Head over to the [Arduino Installation Guide](../installation/arduino.md) to prepare your Arduino.
80+
81+
&nbsp;
82+
83+
# Contributing
84+
Asociación de Investigacion en Inteligencia Artificial Para la Leucemia Peter Moss encourages and welcomes code contributions, bug fixes and enhancements from the Github community.
85+
86+
Please read the [CONTRIBUTING](https://github.com/AMLResearchProject/ALL-Arduino-Nano-33-BLE-Sense-Classifier/blob/main/CONTRIBUTING.md "CONTRIBUTING") document for a full guide to forking our repositories and submitting your pull requests. You will also find our code of conduct in the [Code of Conduct](https://github.com/AMLResearchProject/ALL-Arduino-Nano-33-BLE-Sense-Classifier/blob/main/CODE-OF-CONDUCT.md) document.
87+
88+
## Contributors
89+
- [Adam Milton-Barker](https://www.leukemiaairesearch.com/association/volunteers/adam-milton-barker "Adam Milton-Barker") - [Asociación de Investigacion en Inteligencia Artificial Para la Leucemia Peter Moss](https://www.leukemiaresearchassociation.ai "Asociación de Investigacion en Inteligencia Artificial Para la Leucemia Peter Moss") President/Founder & Lead Developer, Sabadell, Spain
90+
91+
&nbsp;
92+
93+
# Versioning
94+
We use [SemVer](https://semver.org/) for versioning.
95+
96+
&nbsp;
97+
98+
# License
99+
This project is licensed under the **MIT License** - see the [LICENSE](https://github.com/AMLResearchProject/ALL-Arduino-Nano-33-BLE-Sense-Classifier/blob/main/LICENSE "LICENSE") file for details.
100+
101+
&nbsp;
102+
103+
# Bugs/Issues
104+
We use the [repo issues](https://github.com/AMLResearchProject/ALL-Arduino-Nano-33-BLE-Sense-Classifier/issues "repo issues") to track bugs and general requests related to using this project. See [CONTRIBUTING](https://github.com/AMLResearchProject/ALL-Arduino-Nano-33-BLE-Sense-Classifier/blob/main/CONTRIBUTING.md "CONTRIBUTING") for more info on how to submit bugs, feature requests and proposals.

0 commit comments

Comments
 (0)