Skip to main content

Programmatically generate semi-realistic synthetic scribble annotations based on statistics from existing scribble datasets

Project description

Scribble Annotation Generator

Programmatically generate semi-realistic scribble annotations for segmentation-style tasks. The project exposes a single CLI entrypoint for two workflows: synthetic crop-field generation and training/inference of the neural scribble generator.

Installation

pip install -e .
# or
pip install scribble-annotation-generator

After installation, the CLI command scribble-annotation-generator becomes available.

Colour Map Specification

Many commands require a colour map that links RGB tuples to class IDs. Provide it in either form:

  • Inline string: R,G,B=class;R,G,B=class (also accepts R,G,B:class)
    • Example: 0,0,0=0;0,128,255=1;124,255,121=2
  • File path: a text file with one entry per line. Each line is R,G,B,class. If the class column is omitted, class IDs are assigned by line order starting at 0.

CLI

1) Crop-field synthesis

Generate synthetic crop-field scribble images using a procedural model.

scribble-annotation-generator crop-field \
  --colour-map "0,0,0=0;0,128,255=1;124,255,121=2" \
  --output-dir ./path/to/output \
  --num-samples 50 \
  --min-rows 4 \
  --max-rows 6

Key flags:

  • --colour-map (required): inline or file as described above
  • --output-dir: where PNGs are written (default ./local/crop_field)
  • --num-samples: number of images to create (default 200)
  • --min-rows, --max-rows: range for rows per sample

2) Train and run neural generator

Train the transformer-based object generator on a dataset of scribble annotations, then render model predictions on the validation set.

scribble-annotation-generator train-nn \
  --train-dir ./local/soybean1/train \
  --val-dir ./local/soybean1/val \
  --colour-map ./colour_map.csv \
  --checkpoint-dir ./local/nn-checkpoints \
  --inference-dir ./local/nn-inference \
  --batch-size 8 \
  --num-workers 4 \
  --max-epochs 50

Key flags:

  • --train-dir, --val-dir (required): directories containing training and validation data
  • --colour-map (required): inline or file form
  • --checkpoint-dir: where PyTorch Lightning checkpoints are stored (default ./local/nn-checkpoints)
  • --inference-dir: where rendered scribbles from validation samples are saved (default ./local/nn-inference)
  • --batch-size, --num-workers, --max-epochs: training configuration
  • --num-classes: override number of classes; by default derived from the colour map

Python API

Instead of calling the CLI, you can call the main functions directly:

  • scribble_annotation_generator.crop_field.generate_crop_field_dataset(output_dir, colour_map, num_samples=..., min_rows=..., max_rows=...)
  • scribble_annotation_generator.nn.train_and_infer(train_dir, val_dir, colour_map, checkpoint_dir=..., inference_dir=..., batch_size=..., num_workers=..., max_epochs=..., num_classes=None)
  • scribble_annotation_generator.bbox_random_generator.BBoxRandomGenerator(num_classes, num_components=..., class_names=..., colour_map=...).fit(dataset)

The bbox generator learns per-class object size distributions from existing annotation masks, then samples a class uniformly at inference time and places one fully contained bounding box at a random location.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scribble_annotation_generator-0.3.1.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scribble_annotation_generator-0.3.1-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file scribble_annotation_generator-0.3.1.tar.gz.

File metadata

File hashes

Hashes for scribble_annotation_generator-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c33c618d6e93116bd412cfe211a515d28fdc3db757bbab54ba3a3842c5f3a1a5
MD5 424863f1641ea9016b87f6b6c665046e
BLAKE2b-256 5d9bc992da0f7adc676f4802bac792e802648e5bae3c1f4bc6ef52ce64f03a3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribble_annotation_generator-0.3.1.tar.gz:

Publisher: pypi-publish.yml on alexsenden/scribble-annotation-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scribble_annotation_generator-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for scribble_annotation_generator-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba32941a8dd98ad1bb70a4b986a6ec411370b36c6ea287865f1864616dc4118d
MD5 3a33515bbd7abdf2b82e30aeb8b60784
BLAKE2b-256 9dcf53881df20ed82826ea02348a7920534ed4cb79a7336bab682307f15b79f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribble_annotation_generator-0.3.1-py3-none-any.whl:

Publisher: pypi-publish.yml on alexsenden/scribble-annotation-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page