Skip to main content

Deep learning histopathology classification with Keras

Project description

README.md


Capricorn AI

Deep-learning based histopathology image classifier built with TensorFlow Keras.

Overview

Capricorn AI provides pre-trained Keras models for classifying H&E–stained tissue patches into diagnostic categories. It offers a simple Python API to load different model versions, run inference on images, and integrate into larger pipelines.

Installation

# Clone the repo
git clone https://github.com/SigMoses/Capricorn.git
cd capricorn

# Install dependencies
pip install -r requirements.txt

# Install as a package
pip install .

Alternatively, install directly from GitHub:

pip install git+https://github.com/SigMoses/Capricorn.git

Quickstart

from capricorn import list_models, load_model, load_image, predict

# List available models
print(list_models())  # ['capricorn0.1']

# Load an image
img = load_image('path/to/slide_patch.png')

# Run prediction
detections = predict('capricorn0.1', img)
print(detections)

Example Usage

from capricorn import load_image, predict, ALL_LABELS, label_confidences

# Load and preprocess an image patch
img = load_image("path/to/patch.png")

# Run inference (returns shape (1, NUM_CLASSES))
probs = predict("capricorn0.1", img)[0]

# Print all label confidences in descending order
for label, confidence in label_confidences(probs):
    print(f"{label:30s} {confidence*100:5.1f}%")

Available Models

  • capricorn0.1: Initial version trained on PathMNIST subsets.

Add your own retrained models by placing the .keras file in capricorn/ai_models/ and updating capricorn/ai_models.py.

Development & Testing

  • Dependencies are in requirements.txt.

  • Run tests with:

    pytest
    

Contributing

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/my-model).
  3. Add your .keras model in capricorn/ai_models/ and register it in capricorn/models.py.
  4. Update docs and add tests.
  5. Submit a pull request.

Credits

  • Original Progenitor
    Capricorn AI was conceived and developed by Moshe Newman.

  • Dataset
    This project relies on the MedMNIST dataset. Please credit the MedMNIST team as follows:

    Jiancheng Yang, Rui Shi, Donglai Wei, Zequan Liu, Lin Zhao, Bilian Ke, Hanspeter Pfister, Bingbing Ni.
    “MedMNIST v2—A large-scale lightweight benchmark for 2D and 3D biomedical image classification.” Scientific Data, 2023.

    Jiancheng Yang, Rui Shi, Bingbing Ni.
    “MedMNIST Classification Decathlon: A Lightweight AutoML Benchmark for Medical Image Analysis.” IEEE 18th International Symposium on Biomedical Imaging (ISBI), 2021.

  • Usage & Modification
    You are free to modify or use this code as you please, provided that you retain proper credit to Moshe Newman as the original progenitor of Capricorn AI, and credit the MedMNIST team for the dataset as cited above.

License

MIT License

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

capricorn_ai-0.1.0.tar.gz (26.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

capricorn_ai-0.1.0-py3-none-any.whl (26.7 MB view details)

Uploaded Python 3

File details

Details for the file capricorn_ai-0.1.0.tar.gz.

File metadata

  • Download URL: capricorn_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 26.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for capricorn_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8505b6076a7ff34b1a9d2dba7cb6f26598f78488780e2c95c9ceb77ce4c9a664
MD5 872d7389a18362764faf5e3507ecd13f
BLAKE2b-256 aefa8e6648da021e85bdbe1c2dd0df27a575cdad31592297dd7da83d5c536b85

See more details on using hashes here.

File details

Details for the file capricorn_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: capricorn_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for capricorn_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a92a0b873b698ef77653eef5ea224cfa957af09f99d0ae7c3a566a1ae3edbd4
MD5 5fdc2cea0d0ea698703e69b4d1b8253c
BLAKE2b-256 7b407563d551ff813f4a92ff4a47c546fcdf6a0641f2340a2154b20adabcfa0d

See more details on using hashes here.

Supported by

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