💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Add workers parameter to objects pipeline
davidmezzettid5fc5c31e4ab
diff --git a/src/python/txtai/pipeline/image/objects.py b/src/python/txtai/pipeline/image/objects.pyindex 6da62d8b..098d1525 100644--- a/src/python/txtai/pipeline/image/objects.py+++ b/src/python/txtai/pipeline/image/objects.py@@ -16,7 +16,7 @@ class Objects(HFPipeline):self.classification = classificationself.threshold = threshold- def __call__(self, images):+ def __call__(self, images, workers=0):"""Applies object detection/image classification models to images. Returns a list of (label, score).@@ -26,6 +26,7 @@ class Objects(HFPipeline):Args:images: image|list+ workers: number of parallel workers to use for processing data, defaults to noneReturns:list of (label, score)@@ -35,7 +36,11 @@ class Objects(HFPipeline):values = [images] if not isinstance(images, list) else images# Run pipeline- results = self.pipeline(values) if self.classification else self.pipeline(values, threshold=self.threshold)+ results = (+ self.pipeline(values, num_workers=workers)+ if self.classification+ else self.pipeline(values, threshold=self.threshold, num_workers=workers)+ )# Build list of (id, score)scores = []