AI Adapter for Digital Slide Archive

The AI Adapter facilitates the connection of pre-built and custom AI models with the Digital Slide Archive. This integration empowers users to leverage AI models for the analysis of digital histopathology data and for the purpose of prototyping and testing AI models within the DSA environment. The AI Adapter offers four key features:

Access to Pre-built AI Models for Analysis: Directly access AI models such as Nuclick and Segment anything (Facebook) from the platform, enabling seamless analysis of histopathology images.

Connect Custom AI Inference Models: Seamlessly connect custom AI inference models to the DSA platform.

Configure AI Model Parameters: Customize AI model parameters by modifying this repository aiInferenceModel.

Visualize AI Model Output: Easily visualize the results generated by AI models within the DSA interface and save them to specific locations.

Created by Subin Erattakulangara, David Manthey

Contemporary Approaches to AI Model Sharing and Associated Challenges

classical ai models

Advantages Offered by the DSA AI Adapter

  1. Eliminates the Need for Extension Development

  2. Seamlessly Connect Custom AI Models via FastAPI Deployment

  3. Expanded Data Output Capabilities:

    • Image Tiles with Optional Pre-processing Using HistomicsTK Modules in the UI
    • Nuclei Maps
    • Segmentations
  4. Built-in Functionality for Streamlined Processing:

    • Single Nuclei Analysis (via onClick Method)
    • Region of Interest Evaluation
    • Whole Slide Image Handling
  5. Versatile Output Formats:

    • Easily Save Results as Annotations or CSV Files

DSA Adapter in a nutshell

DSA adapter screen

Installation instructions

Step 1 - Install DSA adapater for AI models

Help users to deploy and run the AI applications with Digital slide archive

Here are the cleaned-up instructions for downloading and deploying the AI adapter:

  1. Choose a folder of your preference.
  2. Open a terminal within the selected folder.
  3. Execute the following steps in the terminal at the root:
git init
git pull https://github.com/DigitalSlideArchive/dsa-run-custom-ai-models.git
docker build --force-rm -t dsarchive/runcustomaimodels .

check if the docker image is present using the command

docker images

You should be able to locate the Docker image named dsarchive/runcustomaimodels in order to proceed. Once you've successfully confirmed its presence, proceed to add the AI adapter to the DSA platform by following the provided tutorial.

Add AI adapter

Once you receive a success message from the platform confirming that the Docker has been successfully added, you can validate this by navigating to the Digital Slide Archive platform and performing the following steps.

Varify AI adapter

Step 2 - Deploying the AI Models

Deploys AI models seperately as a service. Users can add or remove AI models from this codebase. Following are the steps needed to setup the API  

Method 1 - Using Docker

To run the AI model using Docker, follow these steps:

  1. Navigate to the aiInferenceModel directory:

    cd aiInferenceModel
  2. Build the Docker image:

    docker build -t dsarchive/aimodels .
*Note This stage may take longer to run
  1. Run the Docker container:

    docker run -t -d -p 8000:80 --name aimodels dsarchive/aimodels
  2. Verify the status of the Docker image:

    docker images
  3. To ensure that the API is running, open the following URL in your web browser:

    http://localhost:8000/docs

    If you can see the API documentation, it means the AI models are successfully running in your environment.  

Method 2 - Using Conda

Alternatively, you can run the AI models without Docker by creating a Conda environment and installing all the requirements:

  1. Create a Conda environment:

    conda create -n dsaAiModels python=3.11
  2. Activate the Conda environment:

    conda activate dsaAiModels
  3. Navigate to the aiInferenceModel folder:

    cd aiInferenceModel
  4. Install all the requirements:

    pip install -r requirements.txt
  5. Run the main.py file:

    python main.py

    This will start the FAST API interface for the AI applications.

How to use pre-build AI models

Until today, we have successfully integrated five distinct AI models designed for the comprehensive analysis of histopathology images, encompassing both segmentation and classification tasks. Below, you will find detailed tutorials for utilizing each of these individual models.

OnClick Models
Whole slide models