Documentation
Version: 2.22.0
A comprehensive Python SDK for interacting with the Datamint platform, providing seamless integration for medical imaging workflows, dataset management, and machine learning experiments.
From inception to completion, Datamint is your reliable partner. It assists from the very first day when you make your data available to your team, right up to the moment you’re set to launch your model.
Datamint
For Developers
Beginner
Install the package, configure your API key, and make your first calls.
Beginner
Run the unified datamint <command> CLI for uploads, config, training, and inference.
Intermediate
Use the Api class directly for full control over resources, projects, and annotations.
Intermediate
Plug Datamint datasets into PyTorch and Lightning training loops.
Intermediate
Train models with built-in one-line trainers – no training loop to write.
Browse runnable example notebooks, from getting started through full end-to-end pipelines.
Advanced
Side-by-side comparison of raw PyTorch/Lightning code vs the Datamint equivalent.
Fix SSLCertVerificationError issues when connecting to the API.
For Non-Developers
Just need to upload images and segmentations, no coding? Start here.
Beginner
No coding required. Set up your computer, get an API key, and upload your files from a terminal, step by step.
Quick Start
pip install datamint
datamint config
from datamint import Api
api = Api()
all_projects = api.projects.get_all()
See the full Quick Start guide for installing in a virtual
environment, configuring your API key, and scaffolding a project with datamint init.
Architecture Overview
The Datamint Python API is organized into several key modules:
Module |
Purpose |
Key Classes |
|---|---|---|
|
HTTP client and endpoint handlers for the API |
|
|
Pydantic data models representing platform objects |
|
|
PyTorch dataset classes for medical imaging |
|
|
PyTorch Lightning integration for training workflows |
|
|
MLflow integration for experiment tracking and model registration |
|
Key Concepts
The SDK is built around a few core concepts that make data ingestion, annotation, training, and deployment work together smoothly.
Manage source data.
Upload medical images, videos, and other files. Organize resources into channels and projects, then tag and annotate them.
Capture labels and geometry.
Add segmentations, bounding boxes, classifications, and other geometry to resources, with support for both 2D images and 3D volumes.
Group data for workflows.
Collect resources for annotation and ML training. Projects support split assignments (train/val/test) to keep experiments reproducible.
Train with PyTorch-ready data.
Use dataset classes that load data from Datamint projects and automatically handle DICOM, NIfTI, image, and video formats.
Accelerate common training loops.
Rely on high-level trainers to streamline dataset setup, model configuration, MLflow logging, and checkpointing.
Package models for deployment.
Register ML models for inference on the Datamint platform, including segmentation, classification, and other custom use cases.
Common Workflows
Uploading Data
from datamint import Api
api = Api()
# Upload a single file
resource = api.resources.upload_resource("/path/to/image.dcm")
# Upload with options
api.resources.upload_resource(
"/path/to/image.dcm",
channel="CT Scans",
tags=["baseline", "ct"],
anonymize=True,
)
# Upload multiple files
api.resources.upload_resources(["/path/to/a.dcm", "/path/to/b.dcm"])
Creating a Training Project
from datamint import Api
from datamint.dataset import ImageDataset
api = Api()
# Create project
project = api.projects.create(
name="Liver Segmentation",
description="CT liver segmentation dataset",
)
# Add resources
resources = api.resources.get_list(channel="CT Scans")
api.projects.add_resources(resources, project)
# Load dataset
dataset = ImageDataset(project="Liver Segmentation")
Training a Model
from datamint.lightning import UNetPPTrainer
trainer = UNetPPTrainer(
project="Liver Segmentation",
image_size=256,
batch_size=16,
max_epochs=50,
accelerator="gpu",
)
results = trainer.fit()
print(results["test_results"])
Deploying a Model
from datamint import Api
api = Api()
# Deploy a registered model
deploy_job = api.deploy.start(
model_name="liver-segmentation-model",
model_alias="latest",
)
print(deploy_job.status)
Community & Support
Python Modules Reference