How landing-ai/vision-agent-tools works
Project type and purpose
• This is an open-source Python library (not a deployed web or mobile app) providing a suite of computer-vision “tools” and underlying ML “models.”
• Its primary use case is to let downstream applications (like the Vision Agent web app or your own scripts/notebooks) call high-level tools (e.g., TextToObjectDetection) which in turn dispatch to one of many model implementations (e.g., Florence2, Owlv2).
File structure
• Top-level: configuration files (pyproject.toml, mkdocs.yml, CI workflows), docs, assets, notebooks, scripts, tests.
• Core code in vision_agent_tools/:
• models/: each file wraps a specific ML model class inheriting BaseMLModel.
• tools/: each file implements a high-level task inheriting BaseTool.
• model_registry.py: a dictionary that maps model names to lazy-loader lambdas.
• helpers/: shared utilities and filters.
• shared_types.py: base classes and pydantic types.
• Tests mirror the code structure under tests/ with fixtures, model data, and tool/model unit tests.
README for additional insights
• High-level usage examples show how users load an image, instantiate a model or tool, and call it.
• Sections on “Adding new model code” and “Adding new tool code” emphasize the plugin-style architecture via registration and inheritance.
a. Main components:
• Client code (scripts / notebooks / Vision Agent web app)
• Tools layer (vision_agent_tools.tools)
• Model registry (vision_agent_tools.models.model_registry)
• Models layer (vision_agent_tools.models)
• Helpers/utilities (vision_agent_tools.helpers, vision_agent_tools.shared_types)
• External ML frameworks & runtime (PyTorch / Transformers / PIL)
• Documentation and CI (MkDocs, GitHub Actions)
b. Relationships and interactions:
1. Client calls a Tool class (e.g., TextToObjectDetection).
2. Tool uses get_model_class from the model registry to instantiate the correct BaseMLModel.
3. Model class wraps calls to external frameworks (loads checkpoint, processes image, returns results).
4. Tool post-processes model output into tool-specific output schema.
5. Helpers (filters, utilities) can be invoked by either models or tools.
6. CI pipelines run tests and publish docs from the same repo.
c. Architectural patterns & principles:
• Plugin / registry pattern for dynamic model loading
• Separation of concerns: Tools (high-level tasks) vs. Models (raw ML inference) vs. Helpers
• Lazy import to reduce startup overhead and manage dependencies
• Pydantic for data validation in I/O types
d. Key technologies/frameworks:
• Python 3, Poetry (build & dependency management)
• MkDocs for documentation
• PyTorch & HuggingFace Transformers under the hood in ML model implementations
• PIL for image loading and processing
• pytest for unit testing
• GitHub Actions for CI