Skip to content

Resize the object feature embeddings with torch to optimize feature computation time - #1392

Merged
anwai98 merged 2 commits into
computational-cell-analytics:devfrom
titusgriebel:torch-embedding-resize
Oct 19, 2026
Merged

anwai98 merged 2 commits into
computational-cell-analytics:devfrom
titusgriebel:torch-embedding-resize

Conversation

@titusgriebel

Copy link
Copy Markdown
Contributor

@anwai98

Motivation: In a scenario where a user wants to locally annotate a series of images using object classification, object features are not cached right now between sessions. This means that if the annotation process is split into several portions, significant waiting times occur, especially in data with larger object counts.

'skimage.transform.resize' took 94% of the object feature computation time: about 0.5 s per tile, so 8 s for a 2048 px field with the default tiling. 'torch.nn.functional.interpolate' takes about 0.01 s per tile. The values match, except in the 2 px edge of the resized embedding, where torch repeats the edge pixel and skimage mirrors it.

Thus, even without feature caching, recomputing features would become much less of a burden.

'skimage.transform.resize' took 94% of the object feature time: about
0.5 s per tile, so 8 s for a 2048 px field with the default tiling.
'torch.nn.functional.interpolate' takes about 0.01 s per tile. The
values match, except in the 2 px edge of the resized embedding, where
torch repeats the edge pixel and skimage mirrors it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@anwai98

anwai98 commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks @titusgriebel. I'll check this later today too (could also port this to bioimage_cpp's resampling function -- will review later anyways)

@anwai98 anwai98 self-assigned this Oct 16, 2026

@constantinpape constantinpape left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense from my end. @anwai98 feel free to merge later. We can use torch; as long as the results are numerically the same (2 px edge artifacts don't matter) . We don't need to check for alternatives.

@anwai98 anwai98 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @titusgriebel. Looks good to me and CP. I"ll go ahead and merge this once the CIs pass!

@anwai98
anwai98 merged commit d0b6ec3 into computational-cell-analytics:dev Oct 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants