-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Universal Query Language #400
Create Universal Query Language #400
Conversation
… having dangling outputs
…_universal_query_operation_language
class ExtractDetectionProperty(OperationDefinition): | ||
model_config = ConfigDict( | ||
json_schema_extra={ | ||
"description": "Extracts property from single detection", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is to handle sv.Detections then we might want to think if we want to promote operating on single detection instances. It is possible to get individual detections from sv.Detections object like this:
for i in range(len(detections)):
yield detections[i]
Though above will create a copy of data, might be costly to execute.
type: Literal["!="] | ||
|
||
|
||
class NumerGreater(BinaryOperator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numer
-> Number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
type: Literal["(Number) >"] | ||
|
||
|
||
class NumerGreaterEqual(BinaryOperator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numer
-> Number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
["barcode-detection" for _ in range(len(detections))] | ||
) | ||
detections["data"] = ( | ||
np.array(extracted_data) if len(extracted_data) > 0 else np.empty(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted_data
is defined as list, so we can simplify to detections["data"] = np.array(extracted_data) if extracted_data else np.empty(0)
Also:
>>> np.array([])
array([], dtype=float64)
>>> np.empty(0)
array([], dtype=float64)
So we could further simplify to detections["data"] = np.array(extracted_data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
) | ||
detections["data"] = ( | ||
np.array(extracted_data) if len(extracted_data) > 0 else np.empty(0) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to detections["data"] = np.array(extracted_data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
detections[DETECTION_ID_KEY] = np.array([uuid4() for _ in range(len(detections))]) | ||
detections[PREDICTION_TYPE_KEY] = np.array( | ||
["qrcode-detection" for _ in range(len(detections))] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loop can be avoided: detections[PREDICTION_TYPE_KEY] = np.array(["qrcode-detection"] * len(detections))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
) | ||
|
||
LONG_DESCRIPTION = """ | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -15,6 +19,9 @@ def construct_workflow_output( | |||
workflow_outputs: List[JsonField], | |||
execution_cache: ExecutionCache, | |||
) -> Dict[str, List[Any]]: | |||
# TODO: figure out if we needed generic "to-root coordinates" transformation? | |||
# Maybe output constructor should never touch this? Maybe it's better to | |||
# have steps transforming to specific coordinates systems? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we extract this to separate task? It seems we are already handling this by calling sv_detections_to_root_coordinates
below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue submitted
inference/core/workflows/execution_engine/executor/runtime_input_assembler.py
Fixed
Show fixed
Hide fixed
inference/core/workflows/execution_engine/executor/runtime_input_assembler.py
Fixed
Show fixed
Hide fixed
inference/core/workflows/execution_engine/executor/runtime_input_assembler.py
Dismissed
Show dismissed
Hide dismissed
15d821e
into
feature/sv_detections_in_workflows
Description
In this PR I ship extension to core block in form of universal query / operation language.
The idea is the following:
sv.Detections
we support filtering, offseting and getting detections metadata - like size or location) and evaluation of unary and binary operations that are useful for conditional logicworkflows
EE, apart from quality of life improvements - selectors embedded in blocks manifests dicts (so far we supported only singular references and lists of references, now we would like to be able to provide Dict[str, reference] as input - as this is very useful for providing parametrisation of UQL execution engine - let's say that u want to filter detections, but threshold of confidence is provided in runtime, not hardcoded in definition)Downsides of the idea:
predictions
parameter)Here are the examples:
As u see, they all operate on the very similar definitions and in general this extension bring a lot of expression power.
Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
Any specific deployment considerations
sv.Detections
as main data format to proceed with this PR (requires merging Sv detections in core blocks #392)Docs