Skip to content

model bank initial structure with support for dino v3 and yolo#240

Open
yashasvi-pedireddi-mt wants to merge 3 commits intodevfrom
feature/model_bank_v1
Open

model bank initial structure with support for dino v3 and yolo#240
yashasvi-pedireddi-mt wants to merge 3 commits intodevfrom
feature/model_bank_v1

Conversation

@yashasvi-pedireddi-mt
Copy link

@yashasvi-pedireddi-mt yashasvi-pedireddi-mt commented Oct 21, 2025

🚀 Model Bank v1 - Initial Implementation

Overview

This PR introduces the initial structure for the Mindtrace Model Bank, providing a unified interface for computer vision models with support for YOLO implementations and DINOv3 backbone models.

🏗️ Architecture

Base Classes

  • StandaloneBase (base/model_base.py): Abstract interface for monolithic computer vision models (YOLOv10, YOLOv11, DETR, SAM, etc.)
  • TransformerBackboneBase (base/transformer_backbone_base.py): Abstract interface for backbone models with attention visualization capabilities

Model Implementations

1. YOLO Model (standalone/yolo/)

  • Comprehensive YOLO wrapper using ultralytics library
  • Multi-task support: Detection, Classification, and Segmentation
  • Configuration-driven: YAML config files for each task type
  • Key features:
    • Automatic task detection from model name
    • Configurable visualization settings
    • Training support with custom parameters
    • Model export capabilities (ONNX, TorchScript, TFLite)
    • Custom weight loading

2. DINOv3 Backbone (backbones/dinov3.py)

  • Vision Transformer backbone with attention mechanisms
  • LoRA adapter support for efficient fine-tuning
  • Key Features:
    • Intermediate layer extraction
    • Self-attention visualization
    • Attention map plotting with heatmaps
    • Monkey-patch and hook-based attention extraction

Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove the lockfile

Comment on lines +29 to +34
"transformers>=4.57.0",
"torch>=2.8.0",
"peft>=0.17.1",
"matplotlib>=3.10.7",
"pillow>=11.3.0",
"ultralytics>=8.3.213",
Copy link
Contributor

Choose a reason for hiding this comment

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

let's move these dependencies to mindtrace/models/pyproject.toml

*.caffemodel
*.prototxt
*.params
*.json
Copy link
Contributor

Choose a reason for hiding this comment

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

we might want to include some json config files in the package (and subpackages), so let's not ignore *.json.
Plus if there are some config files related to models that might get downloaded, hopefully they'll all be in some known directory, and that dir can be added to gitignore.

Comment on lines +23 to +25
# Add the project root to the path
project_root = Path(__file__).parent.parent.parent.parent.parent.parent
sys.path.insert(0, str(project_root))
Copy link
Contributor

Choose a reason for hiding this comment

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

what's going on?
let's remove please.

@@ -0,0 +1,7 @@
path: /home/yash/codebase/mindtrace_model_bank/mindtrace/tests/integration/mindtrace/models/standalone/datasets/cls
Copy link
Contributor

Choose a reason for hiding this comment

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

why is there a local absolute path pushed here?

Copy link
Contributor

Choose a reason for hiding this comment

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

i think .cache files should be gitignored, and should automatically get created locally when running tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

let's try to reduce the size for this one.
11 MB for a single image for testing purposes is huge.

Comment on lines +28 to +31
def train(self, **kwargs) -> Any:
"""
Optional: single training step (forward + loss computation + backward).
Can raise NotImplementedError if training is not supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

should be train_step?

Comment on lines +21 to +23
# Add the project root to the path
project_root = Path(__file__).parent.parent.parent.parent.parent.parent
sys.path.insert(0, str(project_root))
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove please. not needed.

Comment on lines +252 to +254
if __name__ == "__main__":
exit_code = main()
sys.exit(exit_code)
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need if __name == "__main__" sections for tests. let's remove please.
they can be run via ds test: path/to/test.py

Comment on lines +231 to +233
print("\n" + "=" * 50)
print("TEST SUMMARY")
print("=" * 50)
Copy link
Contributor

Choose a reason for hiding this comment

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

please let's remove all prints from tests.
if a script is meant to be run on its own to demonstrate or check some behaviour it would be better placed in samples/models/

@vik-rant
Copy link
Contributor

vik-rant commented Nov 4, 2025

For the base classes, let's inherit from mindtrace.core.Mindtrace or mindtrace.core.MindtraceABC as appropriate to get self.logger and self.config. That is the general pattern for top-level classes in sub-packages.
Model config can then be separately placed in self.model_config as is already done in DinoV3 for example.

@vik-rant vik-rant added the mindtrace-models Issues raised from models module in mindtrace package label Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mindtrace-models Issues raised from models module in mindtrace package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants