Skip to content

Example AIDB Usage

Akash Mittal edited this page Oct 6, 2023 · 5 revisions
from aidb.datasources import AwsS3DataSource
from aidb.blobindex import ImageBlobIndex
from aidb.embedding import CohereEmbedding
from aidb.vector_store import PineCone
from aidb.engine import AidbEngine
from aidb.services import GoogleObjectDetectionService, ColorDetectionService

RDBMS_URL = "postgres://localhost:///"

# setup phase
data_source = AwsS3DataSource("s3://inspection-images/", extension_filter=[".jpg", ".png"])

image_blob_index = ImageBlobIndex(data_source)
"""
auto populate the blob table with

<file_name, file_path, created_at, ...>

populate the blob table 

"""
image_blob_index.create_index(RDBMS_URL)

"""
embedding model 
"""
embedding_model = CohereEmbedding()


vector_store = PineCone(image_blob_index, embedding_model)
"""
each blob entry is embedded and inserted in the vector store
"""
vector_store.create_index()

# inference phase

aidb_engine = AidbEngine(RDBMS_URL, vector_store)

object_detection_service = GoogleObjectDetectionService(api_key="", url="")
aidb_engine.register_inference_service(object_detection_services)
aidb_engine.bind_inference_service(
  "object_detection",
  InferenceBinding(
    input_cols1,
    output_cols1,
  )
)

color_detection_service = ColorDetectionService(api_key="", url="")
aidb_engine.register_inference_service(object_detection_services)
aidb_engine.bind_inference_service(
  "color_detection",
  InferenceBinding(
    input_cols2,
    output_cols2,
  )
)

aidb_engine.execute_query("SELECT * FROM objects where created_at > 22-01-2013")