Skip to main content

Medical-AI is a AI framework specifically for Medical Applications

Project description

MedicalAI

Medical-AI is a AI framework specifically for Medical Applications


Documentation: https://aibharata.github.io/medicalAI/

Source Code: https://github.com/aibharata/medicalai


Documentation Status Gitter

Medical-AI is a AI framework for rapid prototyping of AI for Medical Applications.

Installation

$ pip install medicalai

---> 100%
## Requirements Python Version : 3.5-3.7 (Doesn't Work on 3.8 Since Tensorflow does not support 3.8 yet.

Dependencies: Numpy, Tensorflow, Seaborn, Matplotlib, Pandas

NOTE: Dependency libraries are automatically installed. No need for user to install them manually.

Usage

Getting Started Tutorial: Google Colab Google Colab Notebook Link

Importing the Library

import medicalai as mai

Using Templates

You can use the following templates to perform specific Tasks

Load Dataset From Folder

Set the path of the dataset and set the target dimension of image that will be input to AI network.

trainSet,testSet,labelNames =mai.datasetFromFolder(datasetFolderPath, targetDim = (96,96)).load_dataset()
- trainSet contains 'data' and 'labels' accessible by trainSet.data and trainSet.labels
- testSet contains 'data' and 'labels' accessible by testSet.data and testSet.labels
- labelNames contains class names/labels

Check Loaded Dataset Size

print(trainSet.data.shape)
print(trainSet.labels.shape)

Run Training and Save Model

trainer = mai.TRAIN_ENGINE()
trainer.train_and_save_model(AI_NAME= 'tinyMedNet', MODEL_SAVE_NAME='PATH_WHERE_MODEL_IS_SAVED_TO', trainSet, testSet, OUTPUT_CLASSES, RETRAIN_MODEL= True, BATCH_SIZE= 32, EPOCHS= 10, LEARNING_RATE= 0.001)

Plot Training Loss and Accuracy

trainer.plot_train_acc_loss()

Plot Confusion matrix of test data

trainer.plot_confusion_matrix(labelNames,title='Confusion Matrix of Trained Model on Test Dataset')

Loading Model for Prediction

model = mai.load_model_and_weights(modelName = 'PATH_WHERE_MODEL_IS_SAVED_TO')

Predict With Labels

mai.predict_labels(model, testSet.data[0:2], expected_output =testSet.labels[0:2], labelNames=labels, top_preds=3)

Get Just Values of Prediction without postprocessing

model.predict(testSet.data[0:2])

Advanced Usage

Code snippet for Training Using Medical-AI

## Setup AI Model Manager with required AI. 
model = mai.modelManager(AI_NAME= AI_NAME, modelName = MODEL_SAVE_NAME, x_train = train_data, OUTPUT_CLASSES = OUTPUT_CLASSES, RETRAIN_MODEL= RETRAIN_MODEL)

# Start Training
result = mai.train(model, train_data, train_labels, BATCH_SIZE, EPOCHS, LEARNING_RATE, validation_data=(test_data, test_labels), callbacks=['tensorboard'])

# Evaluate Trained Model on Test Data
model.evaluate(test_data, test_labels)

# Plot Accuracy vs Loss for Training
mai.plot_training_metrics(result)

#Save the Trained Model
mai.save_model_and_weights(model, outputName= MODEL_SAVE_NAME)

Automated Tests

To Check the tests

    pytest

To See Output of Print Statements

    pytest -s

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

medicalai-1.1.48.tar.gz (34.2 kB view details)

Uploaded Source

File details

Details for the file medicalai-1.1.48.tar.gz.

File metadata

  • Download URL: medicalai-1.1.48.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for medicalai-1.1.48.tar.gz
Algorithm Hash digest
SHA256 b87d1e50a5e4d201927950317009e52b3cfc796e2f0a72080490e75199682d34
MD5 d461e22fb042748f9c1c9e0ce4f64b86
BLAKE2b-256 b8a396faadcce8038db1229509d5692e2274c437df81d4bb449c14dae6ee7840

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page