DaskDelayedJSONStore¶
- class DaskDelayedJSONStore(contours, processed_predictions)[source]¶
Compute and write TIAToolbox annotations using batched Dask Delayed tasks.
This class parallelizes annotation construction using Dask Delayed while avoiding serialization overhead by storing contours and prediction arrays as instance attributes. Annotations are computed in batches and written directly to a TIAToolbox SQLiteStore via append_many().
Initialize
DaskDelayedAnnotationStore.- Parameters:
contours (np.ndarray) – A sequence of polygon contours. Each element is an array-like of shape
(N_i, 2)representing the coordinates of a single object contour.processed_predictions (dict) – A dictionary of per-object prediction fields. Each key maps to an array-like of length
len(contours). Example keys include"type","prob","centroid", etc. May also contain a global field"geom_type".
Methods
Compute annotations in batches and write them to a SQLiteStore.
Compute annotations in batches and return/save QuPath JSON.
- compute_annotations(store, class_dict, origin=(0, 0), scale_factor=(1, 1), batch_size=100, num_workers=0, *, verbose=True)[source]¶
Compute annotations in batches and write them to a SQLiteStore.
This method creates Dask Delayed tasks in batches to reduce scheduler overhead. Each batch is computed and written immediately using
store.append_many().- Parameters:
store (SQLiteStore) – A TIAToolbox SQLiteStore instance used to write annotations.
class_dict (dict[int, str] | None) – Optional mapping from integer class IDs to string labels.
origin (tuple[float, float], optional) – Translation offset
(x, y)applied after scaling. Defaults to(0, 0).scale_factor (tuple[float, float], optional) – Scaling factors
(sx, sy)applied to contour coordinates. Defaults to(1, 1).batch_size (int, optional) – Number of annotations to compute per batch. Larger batches reduce Dask scheduler overhead. Defaults to
100.num_workers (int, optional) – Number of Dask workers to use.
0means auto-detect. Passed through to the progress bar helper. Defaults to0.verbose (bool, optional) – Whether to display progress bars. Defaults to
True.self (DaskDelayedJSONStore)
- Returns:
The same store instance, after all annotations have been written.
- Return type: