-
Notifications
You must be signed in to change notification settings - Fork 7
/
AllDS2020.py
87 lines (63 loc) · 2.42 KB
/
AllDS2020.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
############################################################################################
#
# Project: Peter Moss Acute Myeloid & Lymphoblastic Leukemia AI Research Project
# Repository: ALL Detection System 2020
# Project: AllDS2020 CNN
#
# Author: Adam Milton-Barker (AdamMiltonBarker.com)
# Contributors:
# Title: AllDS2020 CNN For Raspberry Pi 4 Core
# Description: Core class for the Tensorflow 2.0 AllDS2020 CNN For Raspberry Pi 4.
# License: MIT License
# Last Modified: 2020-06-30
#
############################################################################################
import sys
from Classes.Helpers import Helpers
from Classes.Model import Model
from Classes.Server import Server
class AllDS2020():
""" AllDS2020 CNN For Raspberry Pi 4 Class
Core AllDS2020 CNN For Raspberry Pi 4 Tensorflow 2.0 class.
"""
def __init__(self):
""" Initializes the class. """
self.Helpers = Helpers("Core")
self.Core = Model()
self.Helpers.logger.info("AllDS2020 CNN initialization complete.")
def do_load_model(self):
""" Loads the model """
self.Core.load_model_and_weights()
def do_classify(self):
""" Loads model and classifies test data """
self.do_load_model()
self.Core.test_classifier()
def do_server(self):
""" Loads the API server """
self.do_load_model()
self.Server = Server(self.Core)
self.Server.start()
def do_http_classify(self):
""" Loads model and classifies test data """
self.Core.test_http_classifier()
AllDS2020 = AllDS2020()
def main():
if len(sys.argv) < 2:
AllDS2020.Helpers.logger.info("You must provide an argument")
exit()
elif sys.argv[1] not in AllDS2020.Helpers.confs["cnn"]["core"]:
AllDS2020.Helpers.logger.info(
"Mode not supported! Server, Client or Classify")
exit()
mode = sys.argv[1]
if mode == "Classify":
""" Runs the classifier locally."""
AllDS2020.do_classify()
elif mode == "Server":
""" Runs the classifier in server mode."""
AllDS2020.do_server()
elif mode == "Client":
""" Runs the classifier in client mode. """
AllDS2020.do_http_classify()
if __name__ == "__main__":
main()