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 acceptsR,G,B:class)- Example:
0,0,0=0;0,128,255=1;124,255,121=2
- Example:
- 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 (default200)--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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scribble_annotation_generator-0.3.0.tar.gz.
File metadata
- Download URL: scribble_annotation_generator-0.3.0.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8fa73dcd03916f7673814e5d0d7f616462195d2a5637a24f3bcc3eda6267169
|
|
| MD5 |
224fe7ca6226de1adb73354b991c323b
|
|
| BLAKE2b-256 |
1b0fa5318cd0c02af760771a4e721c783820ee43d91610e9fb32cefd56d8f675
|
Provenance
The following attestation bundles were made for scribble_annotation_generator-0.3.0.tar.gz:
Publisher:
pypi-publish.yml on alexsenden/scribble-annotation-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scribble_annotation_generator-0.3.0.tar.gz -
Subject digest:
a8fa73dcd03916f7673814e5d0d7f616462195d2a5637a24f3bcc3eda6267169 - Sigstore transparency entry: 1422286972
- Sigstore integration time:
-
Permalink:
alexsenden/scribble-annotation-generator@ae321473136f4ad795f2a4e00724c28d70084fda -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/alexsenden
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@ae321473136f4ad795f2a4e00724c28d70084fda -
Trigger Event:
push
-
Statement type:
File details
Details for the file scribble_annotation_generator-0.3.0-py3-none-any.whl.
File metadata
- Download URL: scribble_annotation_generator-0.3.0-py3-none-any.whl
- Upload date:
- Size: 34.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24add5695878f6b34720275e30863247ac725bdf02cc68a00bda765bb044f4a2
|
|
| MD5 |
1390a31b00927cbdc135f25774a387b2
|
|
| BLAKE2b-256 |
3ad83ce57766b8fde253d2b9894ce0330da53b510612b64a5223acda2717b27f
|
Provenance
The following attestation bundles were made for scribble_annotation_generator-0.3.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on alexsenden/scribble-annotation-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scribble_annotation_generator-0.3.0-py3-none-any.whl -
Subject digest:
24add5695878f6b34720275e30863247ac725bdf02cc68a00bda765bb044f4a2 - Sigstore transparency entry: 1422287069
- Sigstore integration time:
-
Permalink:
alexsenden/scribble-annotation-generator@ae321473136f4ad795f2a4e00724c28d70084fda -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/alexsenden
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@ae321473136f4ad795f2a4e00724c28d70084fda -
Trigger Event:
push
-
Statement type: