Switch to unified view

a/README.md b/README.md
1
<h2 align="center">Automatic Identification and Counting of Blood Cells<h2>
1
<h2 align="center">Automatic Identification and Counting of Blood Cells</h2>
2
2
3
[![GitHub stars](https://img.shields.io/github/stars/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/stargazers)
3
[![GitHub stars](https://img.shields.io/github/stars/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/stargazers)
4
[![GitHub forks](https://img.shields.io/github/forks/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/network)
4
[![GitHub forks](https://img.shields.io/github/forks/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/network)
5
[![GitHub issues](https://img.shields.io/github/issues/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/issues)
5
[![GitHub issues](https://img.shields.io/github/issues/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/issues)
6
[![Version](https://img.shields.io/badge/version-2.1-green.svg?longCache=true&style=flat)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)
6
[![Version](https://img.shields.io/badge/version-2.1-green.svg?longCache=true&style=flat)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)
7
[![GitHub license](https://img.shields.io/github/license/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/blob/master/LICENSE)
7
[![GitHub license](https://img.shields.io/github/license/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells)](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/blob/master/LICENSE)
8
<!--<img src="https://user-images.githubusercontent.com/37298971/123714340-f8d70800-d82a-11eb-9742-042a5d9334a1.png" width="28">-->
8
<!--<img src="https://user-images.githubusercontent.com/37298971/123714340-f8d70800-d82a-11eb-9742-042a5d9334a1.png" width="28">-->
9
9
10
## Dataset
10
## Dataset
11
11
12
The [```Complete Blood Count (CBC) Dataset```](https://github.com/MahmudulAlam/Complete-Blood-Cell-Count-Dataset) has
12
The [```Complete Blood Count (CBC) Dataset```](https://github.com/MahmudulAlam/Complete-Blood-Cell-Count-Dataset) has
13
been used for automatic identification and counting of blood cells. Download the dataset, unzip and put
13
been used for automatic identification and counting of blood cells. Download the dataset, unzip and put
14
the ```Training```, ```Testing```, and ```Validation```folders in the working directory.
14
the ```Training```, ```Testing```, and ```Validation```folders in the working directory.
15
15
16
## Requirements
16
## Requirements
17
17
18
![requirements](https://img.shields.io/badge/Python-3.6-3480eb.svg?longCache=true&style=flat&logo=python)
18
![requirements](https://img.shields.io/badge/Python-3.6-3480eb.svg?longCache=true&style=flat&logo=python)
19
![requirements](https://img.shields.io/badge/Python-3.7-3480eb.svg?longCache=true&style=flat&logo=python)
19
![requirements](https://img.shields.io/badge/Python-3.7-3480eb.svg?longCache=true&style=flat&logo=python)
20
20
21
- Tensorflow-GPU==2.2.0 (tested on 2.1.0, 2.2.0, and 2.3.0) ```conda install tensorflow-gpu```
21
- Tensorflow-GPU==2.2.0 (tested on 2.1.0, 2.2.0, and 2.3.0) ```conda install tensorflow-gpu```
22
- TF-slim==1.1.0 ```pip install tf-slim==1.1.0```
22
- TF-slim==1.1.0 ```pip install tf-slim==1.1.0```
23
- Weights: [```download```](https://1drv.ms/u/s!AlXVRhh1rUKThlxTievX0X1CpXd0?e=9cKxYb) the trained weights file for
23
- Weights: [```download```](https://1drv.ms/u/s!AlXVRhh1rUKThlxTievX0X1CpXd0?e=9cKxYb) the trained weights file for
24
  blood cell detection and put the ```weights``` folder in the working directory.
24
  blood cell detection and put the ```weights``` folder in the working directory.
25
25
26
[![Download](https://img.shields.io/badge/download-weights-blue.svg?longCache=true&style=flat&logo=microsoft-onedrive)](https://1drv.ms/u/s!AlXVRhh1rUKThlxTievX0X1CpXd0?e=9cKxYb)
26
[![Download](https://img.shields.io/badge/download-weights-blue.svg?longCache=true&style=flat&logo=microsoft-onedrive)](https://1drv.ms/u/s!AlXVRhh1rUKThlxTievX0X1CpXd0?e=9cKxYb)
27
[![Download](https://img.shields.io/badge/download-weights-ff160a.svg?longCache=true&style=flat&logo=mega)](https://mega.nz/#F!2kVUnKjS!z15tM9WLfga3l1gCNSLNGw)
27
[![Download](https://img.shields.io/badge/download-weights-ff160a.svg?longCache=true&style=flat&logo=mega)](https://mega.nz/#F!2kVUnKjS!z15tM9WLfga3l1gCNSLNGw)
28
28
29
## Getting Started 
29
## Getting Started 
30
30
31
1. Build the cython extension in place 
31
1. Build the cython extension in place 
32
```python setup.py build_ext --inplace```
32
```python setup.py build_ext --inplace```
33
2. Run detect.py 
33
2. Run detect.py 
34
```python detect.py```
34
```python detect.py```
35
35
36
## Update
36
## Update
37
The ```darkflow.cython_utils.cy_yolo_findboxes``` problem has been fixed. Make sure to build the cython extension in place before running the code. 
37
The ```darkflow.cython_utils.cy_yolo_findboxes``` problem has been fixed. Make sure to build the cython extension in place before running the code. 
38
38
39
[![Paper](https://img.shields.io/badge/TensorFlow-2.x-f57418.svg?longCache=true&style=flat&logo=tensorflow)](https://www.tensorflow.org/install)
39
[![Paper](https://img.shields.io/badge/TensorFlow-2.x-f57418.svg?longCache=true&style=flat&logo=tensorflow)](https://www.tensorflow.org/install)
40
40
41
The code was originally written and developed with `TensorFlow v1.x`. The new updated version `v2.0`
41
The code was originally written and developed with `TensorFlow v1.x`. The new updated version `v2.0`
42
included `TensorFlow v2.x` support, tested on both TensorFlow `v2.1.0` and `v2.2.0`. You can download the previous
42
included `TensorFlow v2.x` support, tested on both TensorFlow `v2.1.0` and `v2.2.0`. You can download the previous
43
version
43
version
44
from **[`here`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/releases/tag/v1.0)**
44
from **[`here`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/releases/tag/v1.0)**
45
.
45
.
46
46
47
## How to Run the Code  :runner:
47
## How to Run the Code  :runner:
48
48
49
To detect the blood cells, simply run the `detect.py` file in the terminal or use an IDE. A step-by-step guideline of
49
To detect the blood cells, simply run the `detect.py` file in the terminal or use an IDE. A step-by-step guideline of
50
how to run the blood cell detection code in your computer is provided in
50
how to run the blood cell detection code in your computer is provided in
51
this **[`wiki`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/wiki/A-Step-by-Step-Guide-of-How-to-Run-the-Code)**
51
this **[`wiki`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/wiki/A-Step-by-Step-Guide-of-How-to-Run-the-Code)**
52
.
52
.
53
If you have any trouble running the code and facing any errors please feel free to create
53
If you have any trouble running the code and facing any errors please feel free to create
54
an **[`issue`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/issues)**
54
an **[`issue`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/issues)**
55
or **[`contact me`](https://mahmudulalam.github.io/#contact)**.
55
or **[`contact me`](https://mahmudulalam.github.io/#contact)**.
56
56
57
## How to Train on Your Dataset  :bullettrain_side:
57
## How to Train on Your Dataset  :bullettrain_side:
58
58
59
A seven-step guideline of how to train on your own dataset is provided in
59
A seven-step guideline of how to train on your own dataset is provided in
60
this **[`wiki`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/wiki/How-to-Train-on-Your-Dataset)**
60
this **[`wiki`](https://github.com/MahmudulAlam/Automatic-Identification-and-Counting-of-Blood-Cells/wiki/How-to-Train-on-Your-Dataset)**
61
.
61
.
62
62
63
## Paper
63
## Paper
64
64
65
[![Paper](https://img.shields.io/badge/paper-IETDigiLib-830ceb.svg?longCache=true&style=flat)](http://ietdl.org/t/kmgztb) [![Paper](https://img.shields.io/badge/paper-Wiley-282829.svg?longCache=true&style=flat)](https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/htl.2018.5098)
65
[![Paper](https://img.shields.io/badge/paper-IETDigiLib-830ceb.svg?longCache=true&style=flat)](http://ietdl.org/t/kmgztb) [![Paper](https://img.shields.io/badge/paper-Wiley-282829.svg?longCache=true&style=flat)](https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/htl.2018.5098)
66
66
67
The code was developed for the following blood cell detection paper. For a more detailed explanation of the proposed
67
The code was developed for the following blood cell detection paper. For a more detailed explanation of the proposed
68
method, please go through the pdf of the [```paper```][1]. If you use this code or associated dataset, please cite this
68
method, please go through the pdf of the [```paper```][1]. If you use this code or associated dataset, please cite this
69
paper as:
69
paper as:
70
70
71
[***```Machine learning approach of automatic identification and counting of blood cells```***](https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/htl.2018.5098)
71
[***```Machine learning approach of automatic identification and counting of blood cells```***](https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/htl.2018.5098)
72
72
73
```bibtex
73
```bibtex
74
@article{alam2019machine,
74
@article{alam2019machine,
75
  title={Machine learning approach of automatic identification and counting of blood cells},
75
  title={Machine learning approach of automatic identification and counting of blood cells},
76
  author={Alam, Mohammad Mahmudul and Islam, Mohammad Tariqul},
76
  author={Alam, Mohammad Mahmudul and Islam, Mohammad Tariqul},
77
  journal={Healthcare Technology Letters},
77
  journal={Healthcare Technology Letters},
78
  volume={6},
78
  volume={6},
79
  number={4},
79
  number={4},
80
  pages={103--108},
80
  pages={103--108},
81
  year={2019},
81
  year={2019},
82
  publisher={IET}
82
  publisher={IET}
83
}
83
}
84
```
84
```
85
85
86
## Blood Cell Detection Output
86
## Blood Cell Detection Output
87
87
88
<p align="center">
88
<p align="center">
89
  <img src="https://user-images.githubusercontent.com/37298971/44617785-17eb0980-a88b-11e8-9018-c84f8be5cefa.png" width="500">
89
  <img src="https://user-images.githubusercontent.com/37298971/44617785-17eb0980-a88b-11e8-9018-c84f8be5cefa.png" width="500">
90
</p>
90
</p>
91
91
92
## KNN and IOU Based Verification
92
## KNN and IOU Based Verification
93
93
94
In some cases, our model predicts the same platelet twice. To solve this problem we propose a k-nearest neighbor (KNN)
94
In some cases, our model predicts the same platelet twice. To solve this problem we propose a k-nearest neighbor (KNN)
95
and intersection over union (IOU) based verification system where we find the nearest platelet of a selected platelet
95
and intersection over union (IOU) based verification system where we find the nearest platelet of a selected platelet
96
and calculate their overlap. We are allowing only a 10% overlap between two platelets. If the overlap is more than that
96
and calculate their overlap. We are allowing only a 10% overlap between two platelets. If the overlap is more than that
97
then it will be a spurious prediction and we will ignore the prediction.
97
then it will be a spurious prediction and we will ignore the prediction.
98
98
99
| Before Verification  | After Verification  |
99
| Before Verification  | After Verification  |
100
|:-:|:-:|
100
|:-:|:-:|
101
| <p align="center"> <img src="https://user-images.githubusercontent.com/37298971/46260207-b27ede00-c504-11e8-9d00-7d7be151ee5d.jpg"> </p>  | <p align="center"> <img src="https://user-images.githubusercontent.com/37298971/46260504-a268fd80-c508-11e8-9ef0-5230d00f47a3.jpg">  |
101
| <p align="center"> <img src="https://user-images.githubusercontent.com/37298971/46260207-b27ede00-c504-11e8-9d00-7d7be151ee5d.jpg"> </p>  | <p align="center"> <img src="https://user-images.githubusercontent.com/37298971/46260504-a268fd80-c508-11e8-9ef0-5230d00f47a3.jpg">  |
102
102
103
## Prediction on High-Resolution Image (HRI)
103
## Prediction on High-Resolution Image (HRI)
104
104
105
We have used our model to detect and count blood cells from high-resolution blood cell smear images. These test images
105
We have used our model to detect and count blood cells from high-resolution blood cell smear images. These test images
106
are of the size of ```3872 x 2592``` way higher than the size of our trained images of ```640 x 480```. So, to match the
106
are of the size of ```3872 x 2592``` way higher than the size of our trained images of ```640 x 480```. So, to match the
107
cell size of our trained images we divide those images into grid cells and run prediction in each grid cell and then
107
cell size of our trained images we divide those images into grid cells and run prediction in each grid cell and then
108
combine all the prediction results.
108
combine all the prediction results.
109
109
110
<h3 align="center">Dividing Image into Grid/Patch</h3>
110
<h3 align="center">Dividing Image into Grid/Patch</h3>
111
<p align="center">
111
<p align="center">
112
  <img src="https://user-images.githubusercontent.com/37298971/45962420-a39ab600-c042-11e8-975f-9b0a077f0e0f.jpg" width="700">
112
  <img src="https://user-images.githubusercontent.com/37298971/45962420-a39ab600-c042-11e8-975f-9b0a077f0e0f.jpg" width="700">
113
</p>
113
</p>
114
114
115
<h3 align="center">Combined Output</h3>
115
<h3 align="center">Combined Output</h3>
116
<p align="center">
116
<p align="center">
117
  <img src="https://user-images.githubusercontent.com/37298971/45961699-055a2080-c041-11e8-95b0-1c8ac3c8875b.jpg" width="700">
117
  <img src="https://user-images.githubusercontent.com/37298971/45961699-055a2080-c041-11e8-95b0-1c8ac3c8875b.jpg" width="700">
118
</p>
118
</p>
119
119
120
[1]: https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/htl.2018.5098
120
[1]: https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/htl.2018.5098