Add 3D volume modality#57
Open
HarshaSatyavardhan wants to merge 9 commits into
Open
Conversation
added 8 commits
May 19, 2026 12:23
Author
|
Hi @MichelDucartier, I have implemented the changes you suggested and updated this PR accordingly. Could you please take a look when you get a chance and let me know if this direction looks good, or if any further changes are needed? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds native 3D medical volume support for Stage-1 alignment experiments.
fs-volumefor loading.npyvolumes from filesystem paths.raw-volumefor loading in-memory / Arrow-style volume payloads.VolumeProcessorfor 3D medical volume preprocessing:.npyvolume arrays.[0, 1].(1, 32, 256, 256)contract.VolumeConfig:GoodBaiBai88/M3D-CLIP.volume_size=(32,256,256).patch_size=(4,16,16).pool_factor=(2,2,2).2048 -> 256.volume_3dmodality:encode_image()orvision_model(...).last_hidden_state.2048patch tokens to256visual tokens.MLPProjectorfor mapping encoder features to LLM hidden size.Validation
(32,256,256)with patch(4,16,16)produces(8,16,16) -> (4,8,8).proj_out_num=256.(2,2048,768).(2,256,768).(1,256,4096).Training with a Dataset Status
The original M3D alignment dataset, M3D-Cap, currently shows disabled access due to a DMCA/licensing discussion: M3D-Cap discussion #4.
For follow-up alignment experiments, CT-RATE is a practical open alternative because it provides 3D chest CT volumes paired with radiology text reports. CT-RATE is suitable for projector alignment experiments where the LLM and vision encoder are frozen and only the projector is trained.
Spatial pooling
after the 3D encoder:
Then 3D spatial pooling reduces the spatial grid:
So token count becomes:
After spatial pooling:
M3D-CLIP outputs:
But Llama-3.1-8B uses:
So the MLP projector converts each visual token from M3D-CLIP space into Llama embedding space:
References