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()
class COVID19DN(): """ COVID19DN Class Core COVID-19 Tensorflow DenseNet Classifier wrapper class using Tensroflow 2. """ def __init__(self): """ Initializes the class. """ self.Helpers = Helpers("Core") self.Model = Model() self.Helpers.logger.info( "COVID19DN Tensorflow initialization complete.") def do_data(self): """ Sorts the training data. """ self.Data = Data() self.Data.process_data( self.Data.paths_n_labels()) def do_train(self): """ Creates & trains the model. """ self.Model.do_model(self.Data) self.Model.do_train() self.Model.do_evaluate() def do_load_model(self): """ Loads the model """ self.Model.load_model_and_weights() def do_classify(self): """ Loads model and classifies test data """ self.do_load_model() self.Model.test_classifier() def do_server(self): """ Loads the API server """ self.do_load_model() self.Server = Server(self.Model) self.Server.start() def do_http_classify(self): """ Loads model and classifies test data """ self.Model.test_http_classifier()
class AllDS2020(): """ AllDS2020 CNN Class Core AllDS2020 CNN 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_train(self): """ Creates & trains the model. """ self.Core.do_data() self.Core.do_network() self.Core.do_train() self.Core.do_evaluate() 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()
class ALLoneAPI(): """ ALLoneAPI CNN Core class for the OneAPI Acute Lymphoblastic Leukemia Classifier CNN. """ def __init__(self): """ Initializes the class. """ self.Helpers = Helpers("Core") self.Core = Model() self.Helpers.logger.info("Class initialization complete.") def do_train(self): """ Creates & trains the model. """ self.Core.do_data() self.Core.do_network() self.Core.do_train() self.Core.do_evaluate() 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()
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()
class AllDS2020(): """ AllDS2020 Wrapper Class Core wrapper class for the Tensorflow 2.0 AllDS2020 classifier. """ def __init__(self): self.Helpers = Helpers("Core") self.optimizer = "Adam" self.mode = "Local" self.do_augmentation = True def do_data(self): """ Creates/sorts dataset. """ self.Data = Data(self.optimizer, self.do_augmentation) self.Data.data_and_labels_sort() if self.do_augmentation == False: self.Data.data_and_labels_prepare() else: self.Data.data_and_labels_augmentation_prepare() self.Data.shuffle() self.Data.get_split() def do_model(self): """ Creates & trains the model. Replicates the networked and data splits outlined in the Acute Leukemia Classification Using Convolution Neural Network In Clinical Decision Support System paper using Tensorflow 2.0. https://airccj.org/CSCP/vol7/csit77505.pdf """ self.Model = Model(self.optimizer, self.do_augmentation) self.Model.build_network(self.Data.X_train, self.Data.X_test, self.Data.y_train, self.Data.y_test) self.Model.compile_and_train() self.Model.save_model_as_json() self.Model.save_weights() def do_evaluate(self): """ Predictions & Evaluation """ self.Model.predictions() self.Model.evaluate_model() def do_metrics(self): """ Predictions & Evaluation """ self.Model.visualize_metrics() self.Model.confusion_matrix() self.Model.figures_of_merit() def do_create_model(self): """ Loads the model """ self.Model = Model(self.optimizer, self.do_augmentation) def do_load_model(self): """ Loads the model """ self.Model.load_model_and_weights() def do_classify(self): """ Loads model and classifies test data """ self.do_create_model() self.do_load_model() self.Model.test_classifier() def do_http_classify(self): """ Loads model and classifies test data """ self.do_create_model() self.Model.test_http_classifier()
class COVID19DN(): """ COVID19DN Class Core COVID-19 Tensorflow DenseNet Classifier wrapper class using Tensroflow 2. """ def __init__(self): """ Initializes the class. """ self.Helpers = Helpers("Core") self.Helpers.logger.info( "COVID-19 Tensorflow DenseNet Classifier initialization complete.") def life(self): """ Sends vital statistics to HIAS """ cpu = psutil.cpu_percent() mem = psutil.virtual_memory()[2] hdd = psutil.disk_usage('/').percent tmp = psutil.sensors_temperatures()['cpu-thermal'][0].current r = requests.get('http://ipinfo.io/json?token=' + self.Helpers.confs["iotJumpWay"]["key"]) data = r.json() location = data["loc"].split(',') self.Helpers.logger.info("COVID19DN Life (TEMPERATURE): " + str(tmp) + "\u00b0") self.Helpers.logger.info("COVID19DN Life (CPU): " + str(cpu) + "%") self.Helpers.logger.info("COVID19DN Life (Memory): " + str(mem) + "%") self.Helpers.logger.info("COVID19DN Life (HDD): " + str(hdd) + "%") self.Helpers.logger.info("COVID19DN Life (LAT): " + str(location[0])) self.Helpers.logger.info("COVID19DN Life (LNG): " + str(location[1])) # Send iotJumpWay notification self.iotJumpWayDevice.devicePub( "Life", { "CPU": cpu, "Memory": mem, "Diskspace": hdd, "Temperature": tmp, "Latitude": location[0], "Longitude": location[1] }) threading.Timer(60.0, self.life).start() def iotjumpway_client(self): """ Starts iotJumpWay Client. """ # Initiates the iotJumpWay connection class self.iotJumpWayDevice = iotJumpWay({ "host": self.Helpers.confs["iotJumpWay"]["host"], "port": self.Helpers.confs["iotJumpWay"]["port"], "lid": self.Helpers.confs["iotJumpWay"]["loc"], "zid": self.Helpers.confs["iotJumpWay"]["zne"], "did": self.Helpers.confs["iotJumpWay"]["id"], "dn": self.Helpers.confs["iotJumpWay"]["name"], "un": self.Helpers.confs["iotJumpWay"]["mqtt"]["username"], "pw": self.Helpers.confs["iotJumpWay"]["mqtt"]["password"] }) self.iotJumpWayDevice.connect() def threading(self): """ Creates required module threads. """ # Life thread Thread(target=self.life, args=()).start() threading.Timer(60.0, self.life).start() def do_train(self): """ Creates & trains the model. """ # Load the model class self.Model = Model() # Create the model self.Model.do_model() # Train the model self.Model.do_train() # Validate the model self.Model.do_evaluate() def do_load_model(self): """ Loads the model """ # Load the model and weights self.Model.load_model_and_weights() def do_classify(self): """ Loads model and classifies test data """ # Load the model class self.Model = Model() # Load the model self.do_load_model() # Classify the test data self.Model.test_classifier() def do_server(self): """ Loads the API server """ # Load the model class self.Model = Model() # Load the model self.do_load_model() # Load the server class self.Server = Server(self.Model) # Start the server self.Server.start() def do_http_classify(self): """ Loads model and classifies test data """ # Load the model class self.Model = Model() # Classify the test data via the server self.Model.test_http_classifier()