Giter Club home page Giter Club logo

iviewer_copilot's Introduction

I-Viewer Copilot for Digital Pathology

Introduction

I-viewer copilot is a comprehensive online framework designed to address the needs of collaborative pathology analysis while harnessing the power of AI. I-viewer deployed advanced real-time AI-agents for different tasks and relies on MLLM for information integration and Human-AI collaboration.

Installation

  1. Clone the repo
git clone https://github.com/impromptuRong/iviewer_copilot.git
cd iviewer_copilot
  1. Install ollama from https://ollama.com/download, and start ollama server

For Image Captioning:

export OLLAMA_HOST="0.0.0.0:11434"
export OLLAMA_ORIGINS="*"

ollama pull llava
ollama serve

For LLM Copilot:

export OLLAMA_HOST="0.0.0.0:11435"
export OLLAMA_ORIGINS="*"

ollama pull llama3
ollama serve
  1. Create an .env file with the following contents to specify MLLM service.
SLIDES_DIR=input_slides_folder
DATABASE_DIR=./databases
OLLAMA_HOST_LLM=localhost
OLLAMA_PORT_LLM=11434
OLLAMA_HOST_MLLM=localhost
OLLAMA_PORT_MLLM=11435
OPENAI_API_KEY=openai_api_key

I-Viewer rely on ollama or openai API to enable chatbot and captioning service. For GPT user, put openai_api_key into the .env file as above. For ollama user, we recommend to host ollama service on a separate server. (Instructions about how to set up ollama and LLM models can be found here: https://github.com/ollama/ollama)

  1. Start server with docker
docker compose up -d

Then you can connect the backend API with frontend server. Or view a demo by opening the ./templates/index.html

Adding Agents to I-Viewer Copilot

User can integrate additional agent into the RAG system through function registration. The function registration requires the following parameters:

  1. name: the name of this agent, must be unique.
  2. type: the type of this agent, one of FunctionTool or QueryEngineTool or None. (More llama_index tool will be supported in future)
  3. input_mapping: this will map function args with RAG memory.
  4. output_mapping: this will map the agent output to the RAG memory, results in RAG memory can be further used by other functions for chain of thoughts and hierarchical agent calling.
  5. description: the detail description about the agent, what can the agent do, what types of results the agent can provide. The RAG system will heavily rely on the description to determine answering logic.
  6. return_direct: whether to directly return function results, or wrap the results into language template.

The following example registered a basic function to summarize nuclei composition in annotation databases. In the I-Viewer, image, annotations, roi, description information will be auto-loaded when the copilot window start.

## Basic nuclei summary function
description = f"""\
    Summarize the nuclei information from a given dataframe. \
    This tool calculates the statistical summary of nuclei for each different type. 
    Use this tool to answer user questions about percentage, count about nuclei.
"""
@register_agent(
    name='nuclei_composition',
    type='FunctionTool',
    input_mapping={'entries': 'annotations',},
    output_mapping='nuclei_composition_statistics',
    description=description,
    return_direct=False,
)
def nuclei_composition_summary(entries):
    df = pd.DataFrame(entries)
    if not df.empty:
        res = df['label'].value_counts().to_dict()
    else:
        res = {}
    
    return res

License

The software package is licensed. For commercial use, please contact Ruichen Rong, Xiaowei Zhan and Guanghua Xiao.

iviewer_copilot's People

Contributors

imprompturong avatar zhanxw avatar dannicq avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.