torch_world.datasets¶
TrajectoryDataset
¶
Bases: Dataset
Sliding windows of window steps over episodes stored as tensors (N, T, ...) with a shared T.
MedMNIST
¶
MedMNIST(
name: str,
split: str = "train",
size: int = 64,
root: str | Path | None = None,
download: bool = True,
)
Bases: Dataset
A MedMNIST v2 dataset: images (N, 3, size, size) uint8 and labels (N,).
The .npz file is downloaded once from Zenodo into root and checked against its MD5. Grayscale images are
repeated to three channels. Items are {"image", "label"}. The data is licensed CC BY 4.0.
Yang et al., "MedMNIST v2: A large-scale lightweight benchmark for 2D and 3D biomedical image classification", Scientific Data 2023. Paper: https://arxiv.org/abs/2110.14795 Data: https://zenodo.org/records/10519652
MedicalVQA
¶
MedicalVQA(
names: list[str],
split: str = "train",
size: int = 64,
root: str | Path | None = None,
download: bool = True,
seed: int = 0,
)
Bases: Dataset
Templated visual question answering over MedMNIST datasets, in the style of the MMBU challenge.
Every image yields a modality question; datasets with more than two classes add a finding question and a
verification of a named finding (true half of the time, drawn with seed); datasets with malignant classes
add a malignancy question. Items are {"image", "caption", "question", "answer", "kind"}.
images holds every image once as uint8. After encode(encoder), items carry the encoder's cached outputs in
place of the images, so a frozen encoder runs once per image instead of once per question.
MMBU challenge: https://akiranishii.github.io/mmbu-challenge/
texts
property
¶
Every caption, question and answer the templates can produce for these datasets.
answers
property
¶
The candidate answers for retrieval: every answer the templates can produce.
examples
¶
The first per_source images of each source dataset and their findings, for plots.images.
encode
¶
encode(
encoder,
batch_size: int = 512,
dtype=float16,
device=None,
) -> MedicalVQA
Cache encoder(images), run on device (by default the encoder's); items then carry the outputs.
weights
¶
Per-item sampling weights that give each source dataset the same total weight.