Principle:Norrrrrrr lyn WAInjectBench Dynamic Detector Loading Image
| Knowledge Sources | |
|---|---|
| Domains | Software_Architecture, Plugin_Systems, Computer_Vision |
| Last Updated | 2026-02-14 16:00 GMT |
Overview
A plugin architecture pattern that dynamically loads image detector modules at runtime, with special routing for LLaVA model variants.
Description
The image detector loading extends the standard dynamic import pattern with an additional routing layer for LLaVA-based detectors. While most detectors map one-to-one from name to module file, the LLaVA variants (llava-1.5-7b-prompt and llava-1.5-7b-ft) both route to the same detector_image.llava module, with the variant name passed as a parameter to distinguish between zero-shot prompt mode and fine-tuned mode.
This design allows a single LLaVA module to handle both inference modes while maintaining the uniform plugin interface for all other detectors.
Usage
Use this pattern when building the image detection harness. The routing logic is important when extending the system with new detector variants that share a common underlying model but differ in configuration.
Theoretical Basis
# Extended plugin pattern with variant routing
if detector_name in known_variants_of_shared_module:
module = importlib.import_module(shared_module_path)
else:
module = importlib.import_module(f"{package}.{detector_name}")
The key extension over simple dynamic loading is the variant dispatch — multiple logical detectors can map to the same physical module, with the variant name passed through to distinguish behavior.