Evalutation API Flow#
This gives the rough flow of data from one function to the next, neccessary to perform instance segmentation with SKOOTS. Each image is expected to be a 5D tensor with shape (B, C, X, Y, Z).
- skoots.lib.flood_fill.efficient_flood_fill(skeleton)[source]
Efficiently floods a binary skeleton mask in place by first flood filling small regions, then merging connected components later. Avoids memory copies when possible. Returns a skeleton mask where each connected component has a unique label, however these labels may not be sequential. I.e. unique(skeleton) -> [4, 16, 23, 24, 96]
- Parameters:
skeleton (
Tensor) – binary skeleton mask to flood fill- Return type:
Tensor- Returns:
Flood filled tensor
- skoots.lib.vector_to_embedding.vector_to_embedding(scale, vector, N=1, decay=1.0)[source]
Converts a 2D or 3D vector field to a spatial embedding by adding the vector at any position to its own position.
vector is a 2D or 3D vector field of shape \((B, 2, X, Y)\) for 2D or \((B, 3, X, Y, Z)\) for 3D. Each vector “\(v\)” lies within the range -1 and 1 and is scaled by scale “\(s\)”. The scaled vector is then added to its own position to form a spatial embedding “\(\phi\)”:
- Formally:
- \[ \begin{align}\begin{aligned}i,j,k \in \mathbb{Z}_{≥0} \\v_{i,j,k} \in [-1, 1] \\s = [s_i, s_j, s_k]\\\phi_{i,j,k} = v_{i,j,k} * s + [i, j, k]\end{aligned}\end{align} \]
- Shapes:
scale: \((2)\) or \((3)\)
vector: \((B_{in}, 2, X_{in}, Y_{in})\) or \((B_{in}, 3, X_{in}, Y_{in}, Z_{in})\)
Returns: \((B_{in}, 2, X_{in}, Y_{in})\) or \((B_{in}, 3, X_{in}, Y_{in}, Z_{in})\)
- Parameters:
scale (
Tensor) – Scaling factors for each vector spatial dimensionvector (
Tensor) – Vector field predicted by a neural networkN (
int) – Number of iterations to apply the vectors.decay (
float) – vector strength decay after each iteration. Default 1.0
- Return type:
Tensor- Returns:
Pixel spatial embeddings
- skoots.lib.skeleton.index_skeleton_by_embed(skeleton, embed)[source]
Returns an instance mask by indexing skeleton with an embedding tensor For memory efficiency, skeleton is only ever Referenced! Never copied (I hope)
- Shapes:
skeleton: \((B_{in}=1, 1, X_{in}, Y_{in}, Z_{in})\)
embed: \((B_{in}=1, 3, X_{in}, Y_{in}, Z_{in})\)
- Parameters:
skeleton (
Tensor) – Skeleton of a single instanceembed (
Tensor) – Embedding
- Return type:
Tensor- Returns:
torch.int instance mask