-
Notifications
You must be signed in to change notification settings - Fork 7
User Defined Function Usage
This query will execute objects model over metadata and return the inference results.
async def async_objects_inference(blob_id):
for service in aidb_engine._config.inference_bindings:
if service.service.name == 'objects00':
inference_service = service
# replaced by your own ML inference
outputs = await inference_service.infer(blob_id)
return outputs[0]
def objects_inference(blob_id):
df = pd.DataFrame({'blob_id': [blob_id]})
return asyncio_run(async_objects_inference(df))
This query will return matched text, img pair.
# Pseudo code
def is_match(img, text, threshold):
match_pro = CLIP_model(img, text)
if match_pro > threshold:
return True
else:
return False
You can directly filter data by sql query, which can avoid writing logical operations and changing filtering conditions in code frequently after getting function results.
If the UDF has multiple output columns. You can still do filter directly on specific UDF output by assigning aliases for UDF outputs. # User Defined Function
# Pseudo code
def function1(col):
return x, y, z
-
No output: we will drop that input row.
-
Single value, like integer or float number
-
Multiple rows outputs, using a list of elements (e.g. [1, 2, 3]) or dataframe (e.g. pd.Dataframe({'x': [1, 2, 3]})).
-
Multiple columns outputs, using a list of tuple (e.g. [(1, 2, 3)] or dataframe (e.g. pd.Dataframe({'x': [1], 'y':[2], 'z':[3]}))