|
a |
|
b/Projects/Caffe/allCNN/Data.py |
|
|
1 |
############################################################################################ |
|
|
2 |
# |
|
|
3 |
# The MIT License (MIT) |
|
|
4 |
# |
|
|
5 |
# Peter Moss Acute Myeloid/Lymphoblastic Leukemia AI Research Project |
|
|
6 |
# Copyright (C) 2018 Adam Milton-Barker (AdamMiltonBarker.com) |
|
|
7 |
# |
|
|
8 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
9 |
# of this software and associated documentation files (the "Software"), to deal |
|
|
10 |
# in the Software without restriction, including without limitation the rights |
|
|
11 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
|
12 |
# copies of the Software, and to permit persons to whom the Software is |
|
|
13 |
# furnished to do so, subject to the following conditions: |
|
|
14 |
# |
|
|
15 |
# The above copyright notice and this permission notice shall be included in |
|
|
16 |
# all copies or substantial portions of the Software. |
|
|
17 |
# |
|
|
18 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
|
19 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
|
20 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
|
21 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
|
22 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
|
23 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
|
24 |
# THE SOFTWARE. |
|
|
25 |
# |
|
|
26 |
# Title: Caffe Acute Lymphoblastic Leukemia CNN |
|
|
27 |
# Description: Used to create the dataset for the Caffe Acute Lymphoblastic Leukemia CNN |
|
|
28 |
# Configuration: Required/Confs.json |
|
|
29 |
# Last Modified: 2019-03-16 |
|
|
30 |
# References: Based on: ACUTE LEUKEMIA CLASSIFICATION USING CONVOLUTION NEURAL NETWORK |
|
|
31 |
# IN CLINICAL DECISION SUPPORT SYSTEM |
|
|
32 |
# https://airccj.org/CSCP/vol7/csit77505.pdf |
|
|
33 |
# |
|
|
34 |
############################################################################################ |
|
|
35 |
|
|
|
36 |
from Classes.Helpers import Helpers |
|
|
37 |
from Classes.CaffeHelpers import CaffeHelpers |
|
|
38 |
|
|
|
39 |
class Data(): |
|
|
40 |
|
|
|
41 |
def __init__(self): |
|
|
42 |
|
|
|
43 |
""" |
|
|
44 |
Sets up all default requirements and placeholders |
|
|
45 |
needed for the Caffe Acute Lymphoblastic Leukemia CNN data script. |
|
|
46 |
""" |
|
|
47 |
|
|
|
48 |
self.Helpers = Helpers() |
|
|
49 |
self.confs = self.Helpers.loadConfs() |
|
|
50 |
self.logFile = self.Helpers.setLogFile(self.confs["Settings"]["Logs"]["allCNN"]) |
|
|
51 |
|
|
|
52 |
self.CaffeHelpers = CaffeHelpers(self.confs, self.Helpers, self.logFile) |
|
|
53 |
|
|
|
54 |
self.Helpers.logMessage(self.logFile, "allCNN", "Status", "Data init complete") |
|
|
55 |
|
|
|
56 |
def sortData(self): |
|
|
57 |
|
|
|
58 |
""" |
|
|
59 |
Prepares the data ready for training. |
|
|
60 |
""" |
|
|
61 |
|
|
|
62 |
self.CaffeHelpers.deleteLMDB() |
|
|
63 |
self.CaffeHelpers.sortLabels() |
|
|
64 |
self.CaffeHelpers.sortTrainingData() |
|
|
65 |
self.CaffeHelpers.recreatePaperData() |
|
|
66 |
self.CaffeHelpers.createTrainingLMDB() |
|
|
67 |
self.CaffeHelpers.createValidationLMDB() |
|
|
68 |
self.CaffeHelpers.computeMean() |
|
|
69 |
|
|
|
70 |
self.Helpers.logMessage(self.logFile, "allCNN", "Status", "Data sorting complete") |
|
|
71 |
|
|
|
72 |
Data = Data() |
|
|
73 |
Data.sortData() |