How milab-xenos/buvfm works
BUVFM is a breast-ultrasound video foundation-model project. Its principal user workflow screens video for likely lesions, then grades risk with a VJEPA classifier and Grad-CAM; the repository also supports pretraining, fine-tuning, evaluation, and model distillation. The graph preserves those distinct product branches and the shared video-data and model layers. Some branches are documented in the README but their implementation was not sampled, so those links cite the README rather than implying source inspection.
Main entry points: buildmodel.py Model builder · vision_transformer.py Video transformer · data_manager.py Data manager · pipeline_utils.py Risk grading
Components 24
Screening and demo
- Gradio app
app.py - Lesion screening
pipeline_utils.py - Risk grading
pipeline_utils.py - Demo orchestrator
pipeline_utils.py - Risk and heatmaps
- Quality screening
distill/quality_con.py
Video models
- Model builder
buildmodel.py - Video transformer
src/models/vision_transformer.py - Classifier head
src/models/attentive_pooler.py - Transformer blocks
src/models/utils/modules.py - Patch embedding
src/models/utils/patch_embed.py - Position embeddings
src/models/utils/pos_embs.py
Video data
- Video dataset
src/datasets/video_dataset.py - Data manager
src/datasets/data_manager.py - ImageNet dataset
src/datasets/imagenet1k.py - Video transforms
src/datasets/utils/video/transforms.py
Training and evaluation
- Pretraining entry
pretraining/app/main.py - VJEPA trainer
pretraining/app/vjepa/train.py - Frozen evaluation
pretraining/evals/video_classification_frozen/eval.py - Downstream fine-tuning
train.py - Distributed inference
inference_ddp_old.py
Model distillation
- Classification distillation
distill/cls/distill.py - Detection distillation
distill/det/train.py
Other components
- Video user
Connections 24
- Video user → Gradio app: submits video
- Gradio app → Demo orchestrator: invokes pipeline
app.py - Demo orchestrator → Lesion screening: runs screening
pipeline_utils.py - Demo orchestrator → Risk grading: runs grading
pipeline_utils.py - Risk grading → Model builder: builds classifier
pipeline_utils.py - Model builder → Video transformer: constructs backbone
buildmodel.py - Model builder → Classifier head: constructs head
buildmodel.py - Video transformer → Transformer blocks: uses blocks
src/models/vision_transformer.py - Video transformer → Patch embedding: uses embedding
src/models/vision_transformer.py - Video transformer → Position embeddings: uses positions
src/models/vision_transformer.py - Risk grading → Risk and heatmaps: produces grading
- Video user → Quality screening: screens clips
- Data manager → Video dataset: loads videos
src/datasets/data_manager.py - Data manager → ImageNet dataset: loads images
src/datasets/data_manager.py - Pretraining entry → VJEPA trainer: launches training
pretraining/app/main.py - VJEPA trainer → Data manager: requests batches
pretraining/app/vjepa/train.py - VJEPA trainer → Video transforms: uses transforms
- Frozen evaluation → Data manager: requests data
pretraining/evals/video_classification_frozen/eval.py - Frozen evaluation → Classifier head: uses classifier
pretraining/evals/video_classification_frozen/eval.py - Downstream fine-tuning → Model builder: fine-tunes model
- Distributed inference → Model builder: loads model
inference_ddp_old.py - Distributed inference → Video dataset: reads clips
- Classification distillation → Model builder: builds student
distill/cls/distill.py - Detection distillation → Model builder: builds detector
distill/det/train.py