No project description provided
Project description
vesuvius
From Vesuvius Challenge, a Python library for :
- Accessing CT data of Herculaneum Scrolls
- Training 2d or 3d semantic segmentation models, with support for multi-task and multi-class
- Training 2d or 3d models on regression tasks
- Inferring with models trained with the trainers provided in the package or with pretrained nnUNetv2 models
- Inference can be performed on remote data (http, s3) stored as Zarr arrays
- Rendering .obj segments with local or remote data
- Voxelizing large .obj segmentations for use as 3d labels
- Preprocessing labels of fiber-like structures
- Interactive labeling and model training through a Napari based trainer
- Proofreading large arrays of image/label pairs and saving approved chunks
- Computing structure tensors on large Zarr arrays, and deriving eigenvalues and eigenvectors from them
vesuvius also comes prepackaged with:
- extensive data augmentation
- Dataset orchestrator with streaming adapters for image (tif/png/jpg), zarr, and napari-backed sources
this package is in active development
Entrypoints:
| Name | Script | Description |
|---|---|---|
vesuvius.predict |
models.run.inference |
outputs logits from a pretrained nnUNet-v2 model or one trained within the Vesuvius training framework; currently only works on Zarr data and can be fully distributed with --num_parts and --part_id |
vesuvius.blend_logits |
models.run.blending |
blends the logits from vesuvius.predict using Gaussian blending |
vesuvius.finalize_outputs |
models.run.finalize_outputs |
performs softmax / argmax / none on the blended array and writes a final uint8 volume |
vesuvius.compute_st |
structure_tensor.run_create_st |
computes structure tensors on input data and derives eigen-values/vectors |
vesuvius.napari_trainer |
napari_trainer.main_window |
launches a Napari window for interactive training and inference |
vesuvius.proofreader |
utils.vc_proofreader.main |
opens a Napari window that loads local / remote image-label arrays and extracts training patches |
vesuvius.voxelize_obj |
scripts.voxelize_objs |
converts input .obj meshes to voxel grids and outputs .tif stacks |
vesuvius.refine_labels |
scripts.edt_frangi_label |
refines surface or fibre labels with a custom Frangi-based filter |
vesuvius.render_obj |
rendering.mesh_to_surface |
renders .obj meshes and outputs their surface-volume layers |
vesuvius.flatten_obj |
rendering.slim_uv |
flattens an .obj mesh using slim_uv |
vesuvius.train |
models.run.train |
main entry point for training models |
📓 Introductory notebooks
To get started, we recommend these notebooks that jump right in:
-
📊 Scroll Data Access: an introduction to accessing scroll data using a few lines of Python!
-
✒️ Ink Detection: load and visualize segments with ink labels, and train models to detect ink in CT.
-
🧩 Volumetric instance segmentation cubes: how to access instance-annotated cubes with the
Cubeclass, used for volumetric segmentation approaches.
vesuvius does:
- Data retrieval: Fetches volumetric scroll data, surface volumes of scroll segments, and annotated volumetric instance segmentation labels. Remote repositories and local files are supported.
- Data listing: Lists the available data on our data server.
- Data caching: Caches fetched data to improve performance when accessing remote repositories.
- Normalization: Provides options to normalize data values.
- Multiresolution: Accesses and manages data at multiple image resolutions.
vesuvius doesn't do:
- Remote data modification: The read-only library does not support modifying the original data.
- Complex analysis: While it provides access to data, it does not include built-in tools for complex data analysis or visualization.
Installation
vesuvius can be installed with pip.
Then, before using the library for the first time, accept the license terms:
$ pip install vesuvius
$ vesuvius.accept_terms --yes
Note:
The model framework utilized by vesuvius is heavily inspired by nnUNetv2. The default configuration will use the same blocks and construct the same encoders/decoders as the default nnUNetv2 ResEncUNet. As such, a significant portion of the code from the nnUNetv2 repository is duplicated here, with modifications to enable multi-task support with dynamic decoder branches, as well as other data formats.
Additionally, the augmentations provided within this package are from another of MIC-DKFZ's fantastic array of machine learning libraries, in this case batchgeneratorsv2.
Copying the modules directly into vesuvius was a choice of end-user friendliness, as we were using highly modified branches of both libraries, which created conflicts if an end user were to attempt to run any of our models.
Detailed documentation for training and inference are located in the docs folder
Napari based training
- Run
vesuvius.napari_trainer - Add an image to the viewer
- Add a label layer, with the suffix as the name of your target (ex :
32_ink) - Optionally, add a label layer with the suffix
_mask(ex :32_mask) - Set your training configuration and hit
run training - Infer on the same layer, or another by importing an image, selecting it in the inference widget, and hitting
Run Inference
Proofreading labels
- Update the config in
/utils/vc_proofreader/config.pywith the proper paths - Run
vesuvius.proofreader - Select your desired patch size and min labeled percentage
- Click
run - Approve patches with
aor by checking the box - Skip patches or continue with
spacebarornext pair - Patches are saved in the output dir, and their locations in the .json progress file
Training with vesuvius.train
Supported model types:
- Single task, single class semantic segmentation / regression
- Single task, multi-class semantic segmentation / regression
- Multi-task, single-class semantic segmentation / regression
- Multi-task, multi-class semantic segmentation / regression
By default, when provided with a single channel (binary) input label, the model will output 2 channels (fg/bg), but can adapt to any number of input channels.
Place your data in the following format:
data/
images/
volume1.zarr (or .tif, .png, .jpg)
volume2.zarr
labels/
volume1_ink.zarr (or tif, .png, .jpg)
volume1_hz_fiber.zarr ( if you want an additional task for the same volume )
volume2_ink.zarr
Begin training with:
vesuvius.train -i /path/to/data --batch-size 4 --patch-size 128,128,128 --model-name /path/to/save/checkpoints --config-path /vesuvius/models/configuration/multi-task_config.yaml
There are a number of other optional parameters, which you can find with --help
When this command is run:
-
a ConfigManager class will be instantiated, which will take the arguments given and the configuration file, and store these as properties.
-
The trainer class will execute its class method
__build_model, which will create an instance ofNetworkFromConfig -
NetworkFromConfigwill dynamically determine the number of pooling operations, stages, feature map sizes, operation dimensionality, and other specified parameters -
The trainer class will execute its
_configure_datasetmethod, instantiating theDatasetOrchestratorwith the adapter that matchesdata_format -
The trainer class will execute the rest of the setup required for training, through the following additional class methods:
_build_loss_get_optimizer_get_scheduler_get_scaler_configure_dataloaders
-
The training loop will begin
Training will output the current losses in the tqdm progress bar, and will save a "debug" png or gif (depending on dimensionality) in the checkpoint directory.
By default, the last 10 checkpoints are saved. This is not a smart way to do it, and will be changed to just store the last 3 + last 2 best validation.
Training will run for 1,000 epochs by default, with 200 batches/epoch. This can be modified through the configuration file, which can be optionally provided to vesuvius.train, and some examples are provided in the models folder
Rendering and Flattening objs
Documentation is provided in the rendering folder
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 vesuvius-0.2.4.tar.gz.
File metadata
- Download URL: vesuvius-0.2.4.tar.gz
- Upload date:
- Size: 938.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e683521aac14feb23d07ccc6ce3cca7823df8d90c2d60efbd339830379a2d4e4
|
|
| MD5 |
76cb3cf771092a1bdb8b56018d80ee31
|
|
| BLAKE2b-256 |
1106b65d93b5357db7113e921c7122596c20d4c7b2bbcd48a77f35c617564a0b
|
File details
Details for the file vesuvius-0.2.4-py3-none-any.whl.
File metadata
- Download URL: vesuvius-0.2.4-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d251c81b7b5e0bc1cc91589e9fdb6d795f71c4898161fa3b80e9fe52d27539a1
|
|
| MD5 |
2fac011483b6005e174f3de7edfce89d
|
|
| BLAKE2b-256 |
e5cf7418dff5d22bd7292705654c7aae419436b2ce45522da9192837f48ccf28
|