https://github.com/digitalslidearchive/dsa-run-custom-ai-models
https://github.com/digitalslidearchive/dsa-run-custom-ai-models
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/digitalslidearchive/dsa-run-custom-ai-models
- Owner: DigitalSlideArchive
- Created: 2023-08-25T15:15:35.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T00:49:14.000Z (over 2 years ago)
- Last Synced: 2025-03-26T13:54:09.912Z (over 1 year ago)
- Language: Python
- Size: 69.4 MB
- Stars: 2
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## AI Adapter for Digital Slide Archive
The AI Adapter facilitates the connection of pre-built and custom AI models with the [Digital Slide Archive](https://github.com/DigitalSlideArchive/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](https://subinek.com/), [David Manthey](https://www.kitware.com/david-manthey/)*
### Contemporary Approaches to AI Model Sharing and Associated Challenges

### 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

#### [Click here for Developer Documentation](./docs/tutorials/developerDocs.md)
### 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:
```shell
git init
```
```shell
git pull https://github.com/DigitalSlideArchive/dsa-run-custom-ai-models.git
```
```shell
docker build --force-rm -t dsarchive/runcustomaimodels .
```
check if the docker image is present using the command
```shell
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.

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.

#### 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:
```shell
cd aiInferenceModel
```
2. Build the Docker image:
```shell
docker build -t dsarchive/aimodels .
```
###### *Note This stage may take longer to run
3. Run the Docker container:
```shell
docker run -t -d -p 8000:80 --name aimodels dsarchive/aimodels
```
4. Verify the status of the Docker image:
```shell
docker images
```
5. To ensure that the API is running, open the following URL in your web browser:
```shell
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:
```shell
conda create -n dsaAiModels python=3.11
```
2. Activate the Conda environment:
```shell
conda activate dsaAiModels
```
3. Navigate to the `aiInferenceModel` folder:
```shell
cd aiInferenceModel
```
4. Install all the requirements:
```shell
pip install -r requirements.txt
```
5. Run the `main.py` file:
```shell
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
- **[Nuclick nuclei segmentation](docs/tutorials/nuclickSegmentation.md)**
- **[Segment anything (Facebook)](docs/tutorials/segmentAnythingSegmentation.md)**
- **[Mobile Segment anything](docs/tutorials/mobileSegmentAnything.md)**
##### Whole slide models
- **[Nuclick nuclei classification](./docs/tutorials/nuclickClassification.md)**
- **[StarDist nuclei segmentation](docs/tutorials/stardistSegmentation.md)**
- **[Segment anything (Facebook)](docs/tutorials/segmentAnythingSegmentation.md)**