-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathALLoneAPI.py
85 lines (63 loc) · 2.26 KB
/
ALLoneAPI.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
#########################################################################################################
#
# Organization: Asociacion De Investigacion En Inteligencia Artificial Para La Leucemia Peter Moss
# Research Project: Peter Moss Acute Myeloid & Lymphoblastic Leukemia AI Research Project
# Repository: oneAPI Acute Lymphoblastic Leukemia Classifier
# Project: OneAPI OpenVINO Raspberry Pi 4 Acute Lymphoblastic Leukemia Classifier
#
# Author: Adam Milton-Barker (AdamMiltonBarker.com)
#
# Title: ALLoneAPI RPI4 CNN Core
# Description: Core class for the oneAPI RPI4 Acute Lymphoblastic Leukemia Classifier.
# License: MIT License
# Last Modified: 2020-10-02
#
#########################################################################################################
import sys
from Classes.Helpers import Helpers
from Classes.Model import Model
from Classes.Server import Server
class ALLoneAPI():
""" ALLoneAPI RPI4 CNN Core Class
Core class for the oneAPI RPI4 Acute Lymphoblastic Leukemia Classifier.
"""
def __init__(self):
""" Initializes the class. """
self.Helpers = Helpers("Core")
self.Core = Model()
self.Helpers.logger.info("ALLoneAPI RPI4 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()
ALLoneAPI = ALLoneAPI()
def main():
if len(sys.argv) < 2:
print("You must provide an argument")
exit()
elif sys.argv[1] not in ALLoneAPI.Helpers.confs["cnn"]["core"]:
print("Mode not supported! Server, Train or Classify")
exit()
mode = sys.argv[1]
if mode == "Classify":
""" Runs the classifier locally."""
ALLoneAPI.do_classify()
elif mode == "Server":
""" Runs the classifier in server mode."""
ALLoneAPI.do_server()
elif mode == "Client":
""" Runs the classifier in client mode. """
ALLoneAPI.do_http_classify()
if __name__ == "__main__":
main()