AssetAnalyzer#
- class rapidtools.processing.AssetAnalyzer(model: BaseInferenceModel, prompt: str | Path = '', attribute_prefix: str | None = None, max_workers: int | None = None, batch_size: int = 4, max_images_per_asset: int | None = None, image_filter: Callable[[ImageAsset], bool] | None = None, cancel_event: Event | None = None, rate_limit: RateLimitPolicy | None = None, generation: GenerationConfig | None = None, mode: str | None = None)[source]#
Bases:
objectDescribe every asset in a collection with a vision-language model.
- Parameters:
model (BaseInferenceModel) – Any rapidtools model wrapper (see
rapidtools.models.load()).prompt (str | Path) – Prompt text or path to a prompt file applied to every asset.
attribute_prefix (str | None) – Prefix of the attributes written to each asset. Defaults to the provider’s prefix (
'gemini','qwen_vl', …).max_workers (int | None) – Concurrent requests for hosted models. Defaults to 5 for APIs and 1 for local models (local inference is never threaded).
batch_size (int) – Assets per batch when the model offers
run_inference_batch. Defaults to 4.max_images_per_asset (int | None) – Cap on the images sent per asset;
Nonesends them all.image_filter (Callable[[ImageAsset], bool] | None) – Optional predicate selecting which images to analyze.
cancel_event (Event | None) – Cooperative cancellation flag checked between assets/batches.
rate_limit (RateLimitPolicy | None) – Back-off and retry policy for hosted models;
Noneuses a 30-second cooldown with two retry passes for APIs and no cooldown for local models.generation (GenerationConfig | None) – Per-call generation options (
json_mode,temperature, …) forwarded to the model.mode (str | None) – Force
'api'(threaded) or'local'(sequential/batched) execution; inferred from the model whenNone.
Example
>>> from rapidtools.models import GenerationConfig, load >>> from rapidtools.processing import AssetAnalyzer >>> analyzer = AssetAnalyzer( ... load('qwen_vl', model_id='Qwen/Qwen3.5-9B', load_in_4bit=True), ... prompt='Return JSON with a damage_level key.', ... batch_size=4, ... generation=GenerationConfig(json_mode=True, temperature=0.0), ... ) >>> collection = analyzer(collection) >>> collection.get('bldg_01').attributes['qwen_vl_damage_level'] 'moderate'