# google-health/medgemma architecture

> Architecture diagram of the GitHub repository google-health/medgemma, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google-health/medgemma
- Repository: https://github.com/google-health/medgemma

## Overview

MedGemma is a family of medical-language and image-comprehension models; this tree contains Python serving and image-data access code, not model weights or training/evaluation pipelines. The apparent request path is a serving predictor using data accessors to turn inline, remote, or medical-image inputs into data for inference. The README documents 4B multimodal and 27B text-only variants, but their model execution wiring is not fully visible in the supplied excerpts. Arrows are limited to relationships shown by excerpts or the SOURCE INDEX.

Main entry points: [`python/data_accessors/local_file_handlers/generic_dicom_handler.py`](https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/generic_dicom_handler.py) (Generic DICOM handler), [`python/serving/predictor.py`](https://github.com/google-health/medgemma/blob/main/python/serving/predictor.py) (Predictor), [`python/data_accessors/dicom_wsi/data_accessor.py`](https://github.com/google-health/medgemma/blob/main/python/data_accessors/dicom_wsi/data_accessor.py) (DICOM WSI accessor), [`python/data_accessors/local_file_handlers/abstract_handler.py`](https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/abstract_handler.py) (Handler dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["Serving"]
  node_predictor["Predictor<br/>[predictor.py]"]
  node_cloud_logging["Cloud logging"]
end

subgraph group_access["Data access"]
  node_accessor_base["Accessor contract"]
  node_generic_dicom["DICOM accessor<br/>[data_accessor.py]"]
  node_wsi["DICOM WSI accessor<br/>[data_accessor.py]"]
  node_wsi_config["WSI settings<br/>[configuration.py]"]
  node_gcs["GCS accessor<br/>[data_accessor.py]"]
  node_http["HTTP image accessor<br/>[data_accessor.py]"]
  node_inline_bytes["Inline bytes accessor<br/>[data_accessor.py]"]
  node_inline_text["Inline text accessor<br/>[data_accessor.py]"]
end

subgraph group_handlers["Image handlers"]
  node_file_handlers["Handler dispatch"]
  node_generic_handler["Generic DICOM handler"]
  node_wsi_handler["WSI DICOM handler"]
  node_openslide["OpenSlide handler"]
  node_traditional["Traditional images"]
end

subgraph group_utils["Image utilities"]
  node_patches["Patch coordinates"]
  node_dimensions["Image dimensions"]
  node_dicom_utils["DICOM sources"]
  node_icc["ICC transforms"]
  node_validation["Request validation"]
end

subgraph group_runtime["Inference runtime"]
  node_model_runner["Model runner<br/>[model_runner.py]"]
  node_triton_runner["Triton runner"]
  node_stream_runner["Triton streaming runner"]
end

node_client(("Request client"))

node_client -.->|"submits request"| node_predictor
node_predictor -->|"uses accessor"| node_generic_dicom
node_predictor -->|"uses accessor"| node_wsi
node_predictor -->|"uses accessor"| node_gcs
node_predictor -->|"uses accessor"| node_http
node_predictor -->|"uses accessor"| node_inline_bytes
node_predictor -->|"uses accessor"| node_inline_text
node_generic_dicom -->|"implements"| node_accessor_base
node_wsi -->|"implements"| node_accessor_base
node_gcs -->|"implements"| node_accessor_base
node_http -->|"implements"| node_accessor_base
node_inline_text -->|"implements"| node_accessor_base
node_generic_dicom -->|"dispatches to"| node_generic_handler
node_generic_dicom -->|"uses handlers"| node_file_handlers
node_wsi -->|"uses settings"| node_wsi_config
node_gcs -->|"uses handlers"| node_file_handlers
node_http -->|"uses handlers"| node_file_handlers
node_file_handlers -->|"dispatches to"| node_generic_handler
node_wsi_handler -->|"uses"| node_generic_handler
node_generic_handler -->|"implements"| node_file_handlers
node_wsi_handler -->|"implements"| node_file_handlers
node_openslide -->|"implements"| node_file_handlers
node_traditional -->|"implements"| node_file_handlers
node_generic_handler -->|"uses"| node_dicom_utils
node_generic_handler -->|"uses"| node_icc
node_generic_handler -->|"uses"| node_dimensions
node_generic_handler -->|"uses"| node_patches
node_openslide -->|"uses"| node_icc
node_openslide -->|"uses"| node_dimensions
node_openslide -->|"uses"| node_patches
node_wsi_handler -->|"uses"| node_dicom_utils
node_wsi_handler -->|"uses"| node_icc
node_wsi_handler -->|"uses"| node_dimensions
node_wsi_handler -->|"uses"| node_patches
node_wsi -->|"uses"| node_icc
node_wsi -->|"uses"| node_dimensions
node_wsi -->|"uses"| node_patches
node_wsi -->|"validates with"| node_validation
node_openslide -->|"validates with"| node_validation
node_triton_runner -->|"extends"| node_model_runner
node_stream_runner -->|"extends"| node_model_runner

click node_predictor "https://github.com/google-health/medgemma/blob/main/python/serving/predictor.py"
click node_accessor_base "https://github.com/google-health/medgemma/blob/main/python/data_accessors/abstract_data_accessor.py"
click node_generic_dicom "https://github.com/google-health/medgemma/blob/main/python/data_accessors/dicom_generic/data_accessor.py"
click node_wsi "https://github.com/google-health/medgemma/blob/main/python/data_accessors/dicom_wsi/data_accessor.py"
click node_wsi_config "https://github.com/google-health/medgemma/blob/main/python/data_accessors/dicom_wsi/configuration.py"
click node_gcs "https://github.com/google-health/medgemma/blob/main/python/data_accessors/gcs_generic/data_accessor.py"
click node_http "https://github.com/google-health/medgemma/blob/main/python/data_accessors/http_image/data_accessor.py"
click node_inline_bytes "https://github.com/google-health/medgemma/blob/main/python/data_accessors/inline_bytes/data_accessor.py"
click node_inline_text "https://github.com/google-health/medgemma/blob/main/python/data_accessors/inline_text/data_accessor.py"
click node_file_handlers "https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/abstract_handler.py"
click node_generic_handler "https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/generic_dicom_handler.py"
click node_wsi_handler "https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/wsi_dicom_handler.py"
click node_openslide "https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/openslide_handler.py"
click node_traditional "https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/traditional_image_handler.py"
click node_patches "https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/patch_coordinate.py"
click node_dimensions "https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/image_dimension_utils.py"
click node_dicom_utils "https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/dicom_source_utils.py"
click node_icc "https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/icc_profile_utils.py"
click node_validation "https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/json_validation_utils.py"
click node_model_runner "https://github.com/google-health/medgemma/blob/main/python/serving/serving_framework/model_runner.py"
click node_triton_runner "https://github.com/google-health/medgemma/blob/main/python/serving/serving_framework/triton/triton_server_model_runner.py"
click node_stream_runner "https://github.com/google-health/medgemma/blob/main/python/serving/serving_framework/triton/triton_streaming_server_model_runner.py"
click node_cloud_logging "https://github.com/google-health/medgemma/blob/main/python/serving/logging_lib/cloud_logging_client.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_predictor,node_cloud_logging,node_client toneBlue
class node_accessor_base,node_generic_dicom,node_wsi,node_wsi_config,node_gcs,node_http,node_inline_bytes,node_inline_text toneAmber
class node_file_handlers,node_generic_handler,node_wsi_handler,node_openslide,node_traditional toneMint
class node_patches,node_dimensions,node_dicom_utils,node_icc,node_validation toneRose
class node_model_runner,node_triton_runner,node_stream_runner toneIndigo
```

## Components

### Serving

- [Predictor](https://github.com/google-health/medgemma/blob/main/python/serving/predictor.py): `python/serving/predictor.py`
- [Cloud logging](https://github.com/google-health/medgemma/blob/main/python/serving/logging_lib/cloud_logging_client.py): `python/serving/logging_lib/cloud_logging_client.py`

### Data access

- [Accessor contract](https://github.com/google-health/medgemma/blob/main/python/data_accessors/abstract_data_accessor.py): `python/data_accessors/abstract_data_accessor.py`
- [DICOM accessor](https://github.com/google-health/medgemma/blob/main/python/data_accessors/dicom_generic/data_accessor.py): `python/data_accessors/dicom_generic/data_accessor.py`
- [DICOM WSI accessor](https://github.com/google-health/medgemma/blob/main/python/data_accessors/dicom_wsi/data_accessor.py): `python/data_accessors/dicom_wsi/data_accessor.py`
- [WSI settings](https://github.com/google-health/medgemma/blob/main/python/data_accessors/dicom_wsi/configuration.py): `python/data_accessors/dicom_wsi/configuration.py`
- [GCS accessor](https://github.com/google-health/medgemma/blob/main/python/data_accessors/gcs_generic/data_accessor.py): `python/data_accessors/gcs_generic/data_accessor.py`
- [HTTP image accessor](https://github.com/google-health/medgemma/blob/main/python/data_accessors/http_image/data_accessor.py): `python/data_accessors/http_image/data_accessor.py`
- [Inline bytes accessor](https://github.com/google-health/medgemma/blob/main/python/data_accessors/inline_bytes/data_accessor.py): `python/data_accessors/inline_bytes/data_accessor.py`
- [Inline text accessor](https://github.com/google-health/medgemma/blob/main/python/data_accessors/inline_text/data_accessor.py): `python/data_accessors/inline_text/data_accessor.py`

### Image handlers

- [Handler dispatch](https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/abstract_handler.py): `python/data_accessors/local_file_handlers/abstract_handler.py`
- [Generic DICOM handler](https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/generic_dicom_handler.py): `python/data_accessors/local_file_handlers/generic_dicom_handler.py`
- [WSI DICOM handler](https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/wsi_dicom_handler.py): `python/data_accessors/local_file_handlers/wsi_dicom_handler.py`
- [OpenSlide handler](https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/openslide_handler.py): `python/data_accessors/local_file_handlers/openslide_handler.py`
- [Traditional images](https://github.com/google-health/medgemma/blob/main/python/data_accessors/local_file_handlers/traditional_image_handler.py): `python/data_accessors/local_file_handlers/traditional_image_handler.py`

### Image utilities

- [Patch coordinates](https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/patch_coordinate.py): `python/data_accessors/utils/patch_coordinate.py`
- [Image dimensions](https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/image_dimension_utils.py): `python/data_accessors/utils/image_dimension_utils.py`
- [DICOM sources](https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/dicom_source_utils.py): `python/data_accessors/utils/dicom_source_utils.py`
- [ICC transforms](https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/icc_profile_utils.py): `python/data_accessors/utils/icc_profile_utils.py`
- [Request validation](https://github.com/google-health/medgemma/blob/main/python/data_accessors/utils/json_validation_utils.py): `python/data_accessors/utils/json_validation_utils.py`

### Inference runtime

- [Model runner](https://github.com/google-health/medgemma/blob/main/python/serving/serving_framework/model_runner.py): `python/serving/serving_framework/model_runner.py`
- [Triton runner](https://github.com/google-health/medgemma/blob/main/python/serving/serving_framework/triton/triton_server_model_runner.py): `python/serving/serving_framework/triton/triton_server_model_runner.py`
- [Triton streaming runner](https://github.com/google-health/medgemma/blob/main/python/serving/serving_framework/triton/triton_streaming_server_model_runner.py): `python/serving/serving_framework/triton/triton_streaming_server_model_runner.py`

### Other components

- **Request client**

## Connections

- Request client → Predictor: submits request
- Predictor → DICOM accessor: uses accessor (evidence: `python/serving/predictor.py`)
- Predictor → DICOM WSI accessor: uses accessor (evidence: `python/serving/predictor.py`)
- Predictor → GCS accessor: uses accessor (evidence: `python/serving/predictor.py`)
- Predictor → HTTP image accessor: uses accessor (evidence: `python/serving/predictor.py`)
- Predictor → Inline bytes accessor: uses accessor (evidence: `python/serving/predictor.py`)
- Predictor → Inline text accessor: uses accessor (evidence: `python/serving/predictor.py`)
- DICOM accessor → Accessor contract: implements (evidence: `python/data_accessors/dicom_generic/data_accessor.py`)
- DICOM WSI accessor → Accessor contract: implements (evidence: `python/data_accessors/dicom_wsi/data_accessor.py`)
- GCS accessor → Accessor contract: implements (evidence: `python/data_accessors/gcs_generic/data_accessor.py`)
- HTTP image accessor → Accessor contract: implements (evidence: `python/data_accessors/http_image/data_accessor.py`)
- Inline text accessor → Accessor contract: implements (evidence: `python/data_accessors/inline_text/data_accessor.py`)
- DICOM accessor → Generic DICOM handler: dispatches to (evidence: `python/data_accessors/dicom_generic/data_accessor.py`)
- DICOM accessor → Handler dispatch: uses handlers (evidence: `python/data_accessors/dicom_generic/data_accessor.py`)
- DICOM WSI accessor → WSI settings: uses settings (evidence: `python/data_accessors/dicom_wsi/data_accessor.py`)
- GCS accessor → Handler dispatch: uses handlers (evidence: `python/data_accessors/gcs_generic/data_accessor.py`)
- HTTP image accessor → Handler dispatch: uses handlers (evidence: `python/data_accessors/http_image/data_accessor.py`)
- Handler dispatch → Generic DICOM handler: dispatches to (evidence: `python/data_accessors/local_file_handlers/abstract_handler.py`)
- WSI DICOM handler → Generic DICOM handler: uses (evidence: `python/data_accessors/local_file_handlers/wsi_dicom_handler.py`)
- Generic DICOM handler → Handler dispatch: implements (evidence: `python/data_accessors/local_file_handlers/generic_dicom_handler.py`)
- WSI DICOM handler → Handler dispatch: implements (evidence: `python/data_accessors/local_file_handlers/wsi_dicom_handler.py`)
- OpenSlide handler → Handler dispatch: implements (evidence: `python/data_accessors/local_file_handlers/openslide_handler.py`)
- Traditional images → Handler dispatch: implements (evidence: `python/data_accessors/local_file_handlers/traditional_image_handler.py`)
- Generic DICOM handler → DICOM sources: uses (evidence: `python/data_accessors/local_file_handlers/generic_dicom_handler.py`)
- Generic DICOM handler → ICC transforms: uses (evidence: `python/data_accessors/local_file_handlers/generic_dicom_handler.py`)
- Generic DICOM handler → Image dimensions: uses (evidence: `python/data_accessors/local_file_handlers/generic_dicom_handler.py`)
- Generic DICOM handler → Patch coordinates: uses (evidence: `python/data_accessors/local_file_handlers/generic_dicom_handler.py`)
- OpenSlide handler → ICC transforms: uses (evidence: `python/data_accessors/local_file_handlers/openslide_handler.py`)
- OpenSlide handler → Image dimensions: uses (evidence: `python/data_accessors/local_file_handlers/openslide_handler.py`)
- OpenSlide handler → Patch coordinates: uses (evidence: `python/data_accessors/local_file_handlers/openslide_handler.py`)
- WSI DICOM handler → DICOM sources: uses (evidence: `python/data_accessors/local_file_handlers/wsi_dicom_handler.py`)
- WSI DICOM handler → ICC transforms: uses (evidence: `python/data_accessors/local_file_handlers/wsi_dicom_handler.py`)
- WSI DICOM handler → Image dimensions: uses (evidence: `python/data_accessors/local_file_handlers/wsi_dicom_handler.py`)
- WSI DICOM handler → Patch coordinates: uses (evidence: `python/data_accessors/local_file_handlers/wsi_dicom_handler.py`)
- DICOM WSI accessor → ICC transforms: uses (evidence: `python/data_accessors/dicom_wsi/data_accessor.py`)
- DICOM WSI accessor → Image dimensions: uses (evidence: `python/data_accessors/dicom_wsi/data_accessor.py`)
- DICOM WSI accessor → Patch coordinates: uses (evidence: `python/data_accessors/dicom_wsi/data_accessor.py`)
- DICOM WSI accessor → Request validation: validates with (evidence: `python/data_accessors/dicom_wsi/data_accessor.py`)
- OpenSlide handler → Request validation: validates with (evidence: `python/data_accessors/local_file_handlers/openslide_handler.py`)
- Triton runner → Model runner: extends (evidence: `python/serving/serving_framework/triton/triton_server_model_runner.py`)
- Triton streaming runner → Model runner: extends (evidence: `python/serving/serving_framework/triton/triton_streaming_server_model_runner.py`)
