pyplatypus

The engine behind rplatypus: semantic segmentation and object detection in PyTorch, described by one specification and run from it.

NoteWorking in R?

Read the R package’s documentation instead. It is the same engine with an R surface on top, and its pages are written for that - it installs this package for you and you never import it.

A run, in five lines

import pyplatypus

spec = pyplatypus.from_yaml("run.yaml")
engine = pyplatypus.build_engine(spec)
engine.fit()
engine.evaluate("validation")

from_yaml and from_dict build the same object, so a specification written by hand and one read from a file are the same thing. build_engine returns the engine the specification’s task asks for.

The same run as a configuration file

task: semantic_segmentation
data:
  train_path: train/
  validation_path: valid/
  colormap: [[0, 0, 0], [255, 255, 255]]
models:
  - name: unet
    architecture: u_net
    input_shape: [256, 256]
    loss: {name: dice}
    metrics: [{name: iou}]

Everything not written down has a default, and the defaults live here rather than in the caller - so a short configuration is a complete one.

Where to start reading

If you want to Read
write a configuration file Writing a configuration, then every field
have your editor check that file as you type the JSON Schema
train and score something Engine.fit, Engine.evaluate, Engine.evaluate_cases
detect objects rather than segment DetectionEngine and its report
not train at all, and use published weights available_weights
split data without a patient on both sides split_samples, split_dataset

What the reference is generated from

The pages under Reference come from the docstrings through quartodoc, so they cannot describe a function this package does not have. The >>> examples in them are run by pytest --doctest-modules, which means the site cannot publish an example that does not work - five claims written into Args: and Returns: were false when they were first written, and the doctests caught every one.

The configuration fields are documented on the models themselves, so the YAML reference and the validation messages say the same thing because they are the same text.