$ show Google-Health/medsiglip
This repository provides the serving infrastructure and fine-tuning examples for MedSigLIP, a medical vision-language model (SigLIP variant) that encodes medical images and text into a shared embedding space. The codebase is dominated by a production-grade serving system: a Triton Inference Server backend wrapped in a Gunicorn application, deployed on Google Cloud Vertex AI. It includes modular data accessors for DICOM (whole-slide and generic), GCS, HTTP images, and inline bytes, with modality-specific preprocessing (ICC profile correction, windowing, dynamic range rescaling). The serving layer handles batch prediction, authentication, structured logging, and health checks. While notebooks demonstrate fine-tuning and data-efficient classifier training using Hugging Face, the core of the repository is the serving stack, making it primarily an application with strong data-research hybridity. The code is well-structured with clear abstractions (abstract data accessors, model runner, predictor), thorough unit tests, and reusable patterns like three-tier ICC profile caching and thread-safe logging. However, it is tightly coupled to Google Cloud and medical imaging standards, and some complexity arises from forking and dependency management.
The LLM identified 3 files worth highlighting for reuse:
Provides a three-tier cache for ICC color profiles: in-memory dictionary, Redis, and GCS blob storage, with SHA3‑512 content hashing. The cache is thread-safe and designed for high-throughput DICOM WSI processing. This component can be extracted and reused in any imaging pipeline that requires ICC profile retrieval with fallback, independent of the MedSigLIP model.
An abstract base class that defines a uniform interface for loading images from various sources (DICOM, GCS, HTTP, inline bytes). It implements the `json_to_instance` factory method and a data iterator pattern with pre-load hooks. The abstraction is clean, extensible, and demonstrates good software engineering principles. It can be reused as a pattern for any system needing to support multiple data source types.
A thread-safe structured logging client that integrates with Google Cloud Logging. It supports per-thread signatures, source location injection, trace IDs, and log clipping. It handles fork-safety for Gunicorn-style worker processes. This component can be extracted and reused in any Python web service deploying on GCP, independent of the MedSigLIP model.