Skip to main content

Medical-AI is a AI framework specifically for Medical Applications

Project description

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


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 

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.2.9.2rc0.tar.gz (47.8 kB view details)

Uploaded Source

Built Distribution

medicalai-1.2.9.2rc0-py3-none-any.whl (67.3 kB view details)

Uploaded Python 3

File details

Details for the file medicalai-1.2.9.2rc0.tar.gz.

File metadata

  • Download URL: medicalai-1.2.9.2rc0.tar.gz
  • Upload date:
  • Size: 47.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for medicalai-1.2.9.2rc0.tar.gz
Algorithm Hash digest
SHA256 2e19392208350ff0e60ad16cceac826a007f214e57b42ce03bc3b6f3b6bfd997
MD5 1654274e1a4b767d0e97eefcd5094085
BLAKE2b-256 ff8e5d9f005b5f1f16adbf8d972b523179553dbbbc853836bdf3d86695582a6e

See more details on using hashes here.

File details

Details for the file medicalai-1.2.9.2rc0-py3-none-any.whl.

File metadata

  • Download URL: medicalai-1.2.9.2rc0-py3-none-any.whl
  • Upload date:
  • Size: 67.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for medicalai-1.2.9.2rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 93ff84942b707f2011a256fe3c1a8318659af4bdc03898f289d464c8c4a7df6b
MD5 51930143cd541beed62936d1cf87cbff
BLAKE2b-256 64687b5b64893ff7aad1d1fdd7ea34e53bc1097a4f0867e71d0dc8305c059db5

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