Skip to main content

MedicalAI

Medical-AI is a AI framework for rapid protyping for Medical Applications


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

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

Youtube Tutorial: https://www.youtube.com/V4nCX-kLACg


Downloads Downloads Documentation Status Gitter

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

Installation

pip install medicalai
## 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 ai

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 =ai.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 = ai.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()

Generate a comprehensive evaluation PDF report

trainer.generate_evaluation_report()

PDF report will be generated with model sensitivity, specificity, accuracy, confidence intervals, ROC Curve Plot, Precision Recall Curve Plot, and Confusion Matrix Plot for each class. This function can be used when evaluating a model with Test or Validation Data Set.

Explain the Model on a sample

trainer.explain(testSet.data[0:1], layer_to_explain='CNN3')

Loading Model for Prediction

infEngine = ai.INFERENCE_ENGINE(modelName = 'PATH_WHERE_MODEL_IS_SAVED_TO')

Predict With Labels

infEngine.predict_with_labels(testSet.data[0:2], top_preds=3)

Get Just Values of Prediction without postprocessing

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

Alternatively, use a faster prediction method in production

infEngine.predict_pipeline(testSet.data[0:1])

Advanced Usage

Code snippet for Training Using Medical-AI

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

# Start Training
result = ai.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
ai.plot_training_metrics(result)

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

Automated Tests

To Check the tests

    pytest

To See Output of Print Statements

    pytest -s 

Release files for medicalai 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for medicalai 1.3.1
File Size Uploaded
medicalai-1.3.1.tar.gz 48.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for medicalai 1.3.1
File Interpreter ABI Platform
medicalai-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 115.6 kB

Release files / medicalai-1.3.1.tar.gz

Download URL medicalai-1.3.1.tar.gz
Size 48.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fa05a95d7d6c423cc9a6ce2554303d8b8dd5e26f724fd59a288e11811ff611bb
BLAKE2b-256 checksum
How to use checksums
bfcd886e2158262e1ede8a57a86316f50292ab35a5da079b018ec04625ac042e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.7

Release files / medicalai-1.3.1-py3-none-any.whl

Download URL medicalai-1.3.1-py3-none-any.whl
Size 67.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ef28dd358cb579b893337dc389fc47519fd04a13600ca5fa08e622a59025e3e
BLAKE2b-256 checksum
How to use checksums
8446baaa81a40c6d962e90d2152f2437fb21b6c7e3eb54a38c01ece40b817cd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page