Skip to content
Back to skills

Datamodules And Tasks

ASecurity

"Use for TorchGeo Lightning DataModules, CLI/config runs, task

  • 247 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 9, 2026
testingtesting

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill datamodules-and-tasks --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Datamodules And Tasks?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Datamodules And Tasks
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-datamodules-and-tasks/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-datamodules-and-tasks)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: datamodules-and-tasks
description: "Use for TorchGeo Lightning DataModules, CLI/config runs, task
  classes, losses, metrics, prediction/plot hooks, and training workflow
  wiring."
metadata:
  disco-role: operating
disable-model-invocation: true
license: MIT
---

# TorchGeo datamodules and tasks

Use this sub-skill when wiring TorchGeo into Lightning training, validation, testing, prediction, CLI configs, or task modules.

## DataModule operating facts

- `BaseDataModule` wraps a dataset class, `batch_size`, `num_workers`, split datasets, split dataloaders, and Kornia augmentation hooks.
- `prepare_data()` may download data when `download=True`; it must not create split state. `setup(stage)` creates datasets/samplers and is called on every process.
- `GeoDataModule` is for `GeoDataset` classes and sets `collate_fn = stack_samples`. It manages `RandomPatchSampler`, `GriddedPatchSampler`, and batch samplers for split-specific patch extraction.
- `NonGeoDataModule` is for integer-indexed datasets and ordinary PyTorch dataloader shuffle/split semantics.
- `on_after_batch_transfer()` applies the split-specific augmentation after the batch reaches the device. This is where Kornia GPU augmentations belong.

## Task classes

TorchGeo task modules are Lightning modules for common geospatial ML problems:

- `Classification`: timm-backed image classification with `weights`, `in_channels`, task type, class/label counts, losses, and optional frozen backbone.
- `SemanticSegmentation`: SMP or TorchGeo FCN segmentation with `model`, `backbone`, `weights`, `in_channels`, multiclass/multilabel/binary settings, losses, and freeze options.
- Other task modules cover change detection, detection, instance segmentation, regression, temporal/spatiotemporal tasks, MAE, MoCo, BYOL, SimCLR, and IO benchmark workflows.

Before changing a task, inspect its corresponding `tests/tasks/test_<task>.py` for constructor matrix, batch schema, metric expectations, and trainer smoke coverage.

## CLI/config workflow

- The `torchgeo` console script is declared as `torchgeo.main:main`.
- Prefer JSONArgParse/Lightning config files for reproducible training. Explicitly name the datamodule, task/model, trainer, optimizer/scheduler parameters, and paths.
- For smoke checks, use small fake fixtures and `max_epochs=1`, small batch sizes, and no checkpoint downloads.

## Batch and mask handling

- Images are typically tensors shaped `(B, C, H, W)`; some spatiotemporal paths use `(B, T, C, H, W)` and may flatten or route to spatiotemporal tasks.
- Segmentation masks may require dtype conversion for Kornia and restoration before loss/metrics.
- Detection and instance segmentation batches can contain variable-length boxes/masks; use the datamodule utility collate function used by the tests.

## Read next

- [reference](references/datamodules-and-tasks.md) for task-specific examples and verification candidates.
- Root [troubleshooting](../../references/troubleshooting.md) for Lightning, Kornia, and optional dependency failures.

Files in this skill

  • SKILL.md3 KB
  • references/datamodules-and-tasks.md2.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.