deepcontrail-segmentation
Semantic segmentation of contrails, part of DeepContrail: the segmentation dataset, transforms, model factory (segmentation-models-pytorch with timm encoders), losses, a Lightning module, D4 test-time augmentation, a training entry point, and pretrained models.
It reads datasets in the DeepContrail format (see deepcontrail-core).
import deepcontrail.segmentation stays light; torch is loaded by the parts that need it.
pip install deepcontrail-segmentation # installs deepcontrail-core too
pip install "deepcontrail-segmentation[mlflow]" # with the optional MLflow logger
Unet++ also works with transformer-style encoders such as CAFormer, which have no feature map at
half the input resolution: build_model adds a small convolutional stem for that level (two 3×3
convolutions, 64 channels), which segmentation-models-pytorch's Unet++ needs and cannot build itself.
Pretrained models
A pretrained model is a folder (or Hugging Face Hub repository) with model.safetensors and a
config.json holding everything needed to run it: architecture, composite recipe by band key,
normalisation, input size, decision threshold and whether test-time augmentation is recommended.
The reference model is published as
eurocontrol-asu/deepcontrail-segmentation;
load_pretrained also takes a local folder.
from deepcontrail.core import false_color_from_spectral, read_band_manifest
from deepcontrail.segmentation import load_pretrained, predict
model = load_pretrained("eurocontrol-asu/deepcontrail-segmentation", revision="v0.1.0")
composite = false_color_from_spectral(bands, model.config.false_color, read_band_manifest(root))
probabilities = predict(model, composite, tta=model.config.tta)
mask = probabilities > model.config.threshold
predict takes one (H, W, 3) composite or a batch (N, H, W, 3) of scenes the size the model
was trained on (config.native_size, 256 for the reference model) and returns probabilities at
that resolution; other sizes are refused, as resizing them would change the pixel scale (tiling is
not supported yet). It applies exactly the training preprocessing (resize, normalisation);
pixel_shift= aligns inputs that follow another label convention (0.5 for Kaggle data with a
20250305 model).
A bundle may also carry the instance step tuned for its model (instance_pipeline.yaml,
score_model.json): deepcontrail.instance.load_instance_step(model.directory) reads it, and
scripts/export_pretrained.py --instance-pipeline ... --score-model ... adds it.
Training
Lightning's Trainer runs the training; the entry point builds it from an experiment YAML
(data, model, loss, training sections). The reference one,
configs/experiment.yaml, is in the repository, not in the installed
package: copy it as a starting point.
deepcontrail-train experiment.yaml --data-root /path/to/dataset --output-dir runs \
[--run-name NAME] [--logger csv|mlflow] [--epochs N] [--accelerator gpu]
from deepcontrail.segmentation import train
run = train("experiment.yaml", output_dir="runs")
print(run.best_checkpoint, run.best_val_dice)
Each run writes into runs/<run-name>/: the best checkpoint by validation Dice and the last
one, split/train.txt and split/val.txt (the exact records used), and the logger's files. The
logger is training.logger in the config: csv (default, no extra package) or mlflow (install
deepcontrail-segmentation[mlflow]; tracking URI from MLFLOW_TRACKING_URI, else
<output-dir>/mlflow.db). Metrics: train and validation loss, Dice and IoU per epoch, the
per-step loss and the learning rate.
prepare_training(...), in deepcontrail.segmentation.training, builds the same run without
training it.
Repository scripts (not installed with the package)
-
scripts/train.py: the project's experiment workflow on top of the entry point: MLflow tracking (parameters, curves figure, dataset metadata, split lists, best checkpoint), then a threshold search on validation and evaluation on the test split, with and without D4 TTA. Where runs go is set once in a.envat the repository root (cp .env.example .env):DEEPCONTRAIL_CHECKPOINT_ROOTandMLFLOW_TRACKING_URI.uv run python packages/segmentation/scripts/train.py --data-root /path/to/dataset --run-name my-run
-
scripts/evaluate.py: evaluate a checkpoint (--checkpoint) or an ensemble (--checkpoints a.ckpt b.ckpt ...) on validation and test, with--ttaand--threshold. -
scripts/export_pretrained.py: turn a checkpoint into a pretrained bundle, check that it reproduces the checkpoint exactly, and write a draft model card:uv run python packages/segmentation/scripts/export_pretrained.py \ --checkpoint run/best.ckpt --config configs/experiment.yaml --output-dir bundle \ --metric test_dice_tta_at_0.5=0.6974
The reference configuration is configs/experiment.yaml.
Metadata
Release files for deepcontrail-segmentation 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deepcontrail_segmentation-0.3.0.tar.gz | 36.2 kB | With provenance | Details for deepcontrail_segmentation-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deepcontrail_segmentation-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for deepcontrail_segmentation-0.3.0-py3-none-any.whl |
Total release size: 81.7 kB
Release files / deepcontrail_segmentation-0.3.0.tar.gz
| Download URL | deepcontrail_segmentation-0.3.0.tar.gz |
|---|---|
| Size | 36.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81b03e5b9d03500f25f1d4186765e4cfbf7fd199d505a3d29b1633675c0f055e
|
|
BLAKE2b-256 checksum How to use checksums |
4771316adc5293dc23ce268fa9eec22baf05ccadb694c200cc3973e6ead19fa8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / deepcontrail_segmentation-0.3.0-py3-none-any.whl
| Download URL | deepcontrail_segmentation-0.3.0-py3-none-any.whl |
|---|---|
| Size | 45.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb5a3502b8adc578516c4c2c2ee5acd091d71f8d7cd9e70afc5050eae0b752ee
|
|
BLAKE2b-256 checksum How to use checksums |
7098809b047ebb43d02a0b2a8cf3db3e47a29da735f1fb88eade7543726090d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for deepcontrail-segmentation 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for deepcontrail_segmentation-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.