Skip to content

Commit

Permalink
Merge pull request #2 from AdamMiltonBarker/main
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
AdamMiltonBarker authored May 23, 2021
2 parents 2660a31 + d63d926 commit a9fbe3d
Show file tree
Hide file tree
Showing 34 changed files with 2,966 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [Introduction](#introduction)
- [DISCLAIMER](#disclaimer)
- [Motivation](#motivation)
- [GETTING STARTED](#getting-started)
- [Contributing](#contributing)
- [Contributors](#contributors)
- [Versioning](#versioning)
Expand Down Expand Up @@ -73,13 +74,19 @@ Developers that have contributed to this repository have experience in using Art

 

# GETTING STARTED

Ready to get started ? Head over to the [Getting Started guide](documentation/getting-started.md) for instructions on how to download/install and setup the SARS=CoV-2 Classifier 2021.

 

# Contributing
The Asociación de Investigacion en Inteligencia Artificial Para la Leucemia Peter Moss encourages and welcomes code contributions, bug fixes and enhancements from the Github community.

Please read the [CONTRIBUTING](CONTRIBUTING.md "CONTRIBUTING") document for a full guide to forking our repositories and submitting your pull requests. You will also find information about our code of conduct on this page.

## Contributors
- [Nitin Mane](https://www.leukemiaairesearch.com/association/volunteers/nitin-mane "Nitin Mane") - [Asociacion De Investigatcion En Inteligencia Artificial Para La Leucemia Peter Moss](https://www.leukemiaresearchassociation.ai "Asociacion De Investigacion En Inteligencia Artificial Para La Leucemia Peter Moss") Deep Learning, Aurangabad, India
- [Nitin Mane](https://www.leukemiaairesearch.com/association/volunteers/nitin-mane "Nitin Mane") - [Asociación de Investigacion en Inteligencia Artificial Para la Leucemia Peter Moss](https://www.leukemiaresearchassociation.ai "Asociación de Investigacion en Inteligencia Artificial Para la Leucemia Peter Moss") Deep Learning, Aurangabad, India

 

Expand Down
130 changes: 130 additions & 0 deletions agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env python
""" HIAS AI Agent.
HIAS AI Agents process data using local AI models and communicate
with HIAS IoT Agents using the MQTT protocol.
MIT License
Copyright (c) 2021 Asociación de Investigacion en Inteligencia Artificial
Para la Leucemia Peter Moss
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Contributors:
- Adam Milton-Barker - First version - 2021-5-1
"""

import sys

from abc import ABC, abstractmethod

from modules.AbstractAgent import AbstractAgent

from modules.helpers import helpers
from modules.server import server
from modules.model import model


class agent(AbstractAgent):
""" ALL oneAPI Classifier 2021 HIAS AI Agent
Represents a HIAS AI Agent that processes data
using the ALL oneAPI Classifier 2021 model.
"""

def train(self):
""" Creates & trains the model. """

self.mqtt_start()

self.model.prepare_data()
self.model.prepare_network()
self.model.train()
self.model.evaluate()

def set_model(self, mtype):

self.model = model(self.helpers)

def load_model(self):
""" Loads the trained model """

self.model.load()

def server(self):
""" Loads the API server """

self.mqtt_start()

self.load_model()
self.server = server(self.helpers, self.model, self.mqtt)
self.server.start()

def inference(self):
""" Loads model and classifies test data locally """

self.load_model()
self.model.test()

def inference_http(self):
""" Loads model and classifies test data via HTTP requests """

self.model.test_http()

def signal_handler(self, signal, frame):
self.helpers.logger.info("Disconnecting")
self.mqtt.disconnect()
sys.exit(1)


agent = agent()


def main():

if len(sys.argv) < 2:
print("You must provide an argument")
exit()
elif sys.argv[1] not in agent.helpers.confs["agent"]["params"]:
print("Mode not supported! server, train or inference")
exit()

mode = sys.argv[1]

if mode == "train":
agent.set_model("xDNN")
agent.train()

elif mode == "classify":
agent.set_model("xDNN")
agent.inference()

elif mode == "server":
agent.set_model("xDNN")
agent.server()

elif mode == "classify_http":
agent.set_model("xDNN")
agent.inference_http()


if __name__ == "__main__":
main()
Binary file removed assets/images/all-oneapi-classifier-2020.png
Binary file not shown.
Binary file added assets/images/hias-ai-agent-edit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/hias-ai-agent.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/hias-ai-inference-endpoint.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/hias-ai-inference.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/hias-ai-model-edit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/hias-ai-model.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/repo-issues.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions configuration/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"agent": {
"cores": 8,
"server": "",
"port": 1234,
"params": [
"train",
"classify",
"server",
"classify_http"
]
},
"data": {
"dim": 224,
"file_type": ".png",
"labels": [0, 1],
"test": "model/data/test",
"test_data": [
"Covid (1128).png",
"Covid (1183).png",
"Covid (1239).png",
"Covid (329).png",
"Covid (371).png",
"Covid (55).png",
"Covid (552).png",
"Covid (7).png",
"Covid (842).png",
"Covid (89).png",
"Non-Covid (1114).png",
"Non-Covid (1164).png",
"Non-Covid (1205).png",
"Non-Covid (217).png",
"Non-Covid (457).png",
"Non-Covid (56).png",
"Non-Covid (6).png",
"Non-Covid (715).png",
"Non-Covid (822).png",
"Non-Covid (955).png"

],
"train_dir": "model/data/train",
"valid_types": [
".JPG",
".JPEG",
".PNG",
".GIF",
".jpg",
".jpeg",
".png",
".gif"
]
},
"model": {
"features": "model/features",
"x_feature": "model/features/data_df_X_train_lite.csv",
"y_feature": "model/features/data_df_y_train_lite.csv"
}
}
1 change: 1 addition & 0 deletions configuration/credentials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit a9fbe3d

Please sign in to comment.