Skip to content
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

Fix bug with primitive types parsing in Worklfows #825

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/workflows/blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ hide:
<p class="card block-card" data-url="lmm" data-name="LMM" data-desc="Run a large multimodal model such as ChatGPT-4v or CogVLM." data-labels="MODEL, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="lmm_for_classification" data-name="LMM For Classification" data-desc="Run a large multimodal model such as ChatGPT-4v or CogVLM for classification." data-labels="MODEL, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="label_visualization" data-name="Label Visualization" data-desc="Draws labels on an image at specific coordinates based on provided detections." data-labels="VISUALIZATION, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="classification_label_visualization" data-name="Classification Label Visualization" data-desc="Visualizes both single-label and multi-label classification predictions with customizable display options." data-labels="VISUALIZATION, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="line_counter" data-name="Line Counter" data-desc="Count detections passing line" data-labels="ANALYTICS, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="line_counter_visualization" data-name="Line Counter Visualization" data-desc="Paints a mask over line zone in an image." data-labels="VISUALIZATION, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="mask_visualization" data-name="Mask Visualization" data-desc="Paints a mask over detected objects in an image." data-labels="VISUALIZATION, APACHE-2.0" data-author="dummy"></p>
Expand Down
41 changes: 21 additions & 20 deletions docs/workflows/kinds.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,38 @@ providing compile-time verification of Workflows definitions.

## Kinds declared in Roboflow plugins
<!--- AUTOGENERATED_KINDS_LIST -->
* [`image`](/workflows/kinds/image): Image in workflows
* [`object_detection_prediction`](/workflows/kinds/object_detection_prediction): Prediction with detected bounding boxes in form of sv.Detections(...) object
* [`float`](/workflows/kinds/float): Float value
* [`numpy_array`](/workflows/kinds/numpy_array): Numpy array
* [`prediction_type`](/workflows/kinds/prediction_type): String value with type of prediction
* [`language_model_output`](/workflows/kinds/language_model_output): LLM / VLM output
* [`image_metadata`](/workflows/kinds/image_metadata): Dictionary with image metadata required by supervision
* [`keypoint_detection_prediction`](/workflows/kinds/keypoint_detection_prediction): Prediction with detected bounding boxes and detected keypoints in form of sv.Detections(...) object
* [`top_class`](/workflows/kinds/top_class): String value representing top class predicted by classification model
* [`prediction_type`](/workflows/kinds/prediction_type): String value with type of prediction
* [`*`](/workflows/kinds/*): Equivalent of any element
* [`dictionary`](/workflows/kinds/dictionary): Dictionary
* [`roboflow_api_key`](/workflows/kinds/roboflow_api_key): Roboflow API key
* [`classification_prediction`](/workflows/kinds/classification_prediction): Predictions from classifier
* [`video_metadata`](/workflows/kinds/video_metadata): Video image metadata
* [`detection`](/workflows/kinds/detection): Single element of detections-based prediction (like `object_detection_prediction`)
* [`boolean`](/workflows/kinds/boolean): Boolean flag
* [`bytes`](/workflows/kinds/bytes): This kind represent bytes
* [`qr_code_detection`](/workflows/kinds/qr_code_detection): Prediction with QR code detection
* [`contours`](/workflows/kinds/contours): List of numpy arrays where each array represents contour points
* [`roboflow_model_id`](/workflows/kinds/roboflow_model_id): Roboflow model id
* [`object_detection_prediction`](/workflows/kinds/object_detection_prediction): Prediction with detected bounding boxes in form of sv.Detections(...) object
* [`language_model_output`](/workflows/kinds/language_model_output): LLM / VLM output
* [`inference_id`](/workflows/kinds/inference_id): Inference identifier
* [`serialised_payloads`](/workflows/kinds/serialised_payloads): Serialised element that is usually accepted by sink
* [`string`](/workflows/kinds/string): String value
* [`float_zero_to_one`](/workflows/kinds/float_zero_to_one): `float` value in range `[0.0, 1.0]`
* [`rgb_color`](/workflows/kinds/rgb_color): RGB color
* [`image`](/workflows/kinds/image): Image in workflows
* [`roboflow_project`](/workflows/kinds/roboflow_project): Roboflow project name
* [`top_class`](/workflows/kinds/top_class): String value representing top class predicted by classification model
* [`image_keypoints`](/workflows/kinds/image_keypoints): Image keypoints detected by classical Computer Vision method
* [`list_of_values`](/workflows/kinds/list_of_values): List of values of any type
* [`float_zero_to_one`](/workflows/kinds/float_zero_to_one): `float` value in range `[0.0, 1.0]`
* [`instance_segmentation_prediction`](/workflows/kinds/instance_segmentation_prediction): Prediction with detected bounding boxes and segmentation masks in form of sv.Detections(...) object
* [`rgb_color`](/workflows/kinds/rgb_color): RGB color
* [`boolean`](/workflows/kinds/boolean): Boolean flag
* [`keypoint_detection_prediction`](/workflows/kinds/keypoint_detection_prediction): Prediction with detected bounding boxes and detected keypoints in form of sv.Detections(...) object
* [`numpy_array`](/workflows/kinds/numpy_array): Numpy array
* [`bar_code_detection`](/workflows/kinds/bar_code_detection): Prediction with barcode detection
* [`classification_prediction`](/workflows/kinds/classification_prediction): Predictions from classifier
* [`string`](/workflows/kinds/string): String value
* [`roboflow_model_id`](/workflows/kinds/roboflow_model_id): Roboflow model id
* [`integer`](/workflows/kinds/integer): Integer value
* [`parent_id`](/workflows/kinds/parent_id): Identifier of parent for step output
* [`point`](/workflows/kinds/point): Single point in 2D
* [`bytes`](/workflows/kinds/bytes): This kind represent bytes
* [`serialised_payloads`](/workflows/kinds/serialised_payloads): Serialised element that is usually accepted by sink
* [`dictionary`](/workflows/kinds/dictionary): Dictionary
* [`*`](/workflows/kinds/*): Equivalent of any element
* [`detection`](/workflows/kinds/detection): Single element of detections-based prediction (like `object_detection_prediction`)
* [`integer`](/workflows/kinds/integer): Integer value
* [`zone`](/workflows/kinds/zone): Definition of polygon zone
* [`roboflow_api_key`](/workflows/kinds/roboflow_api_key): Roboflow API key
<!--- AUTOGENERATED_KINDS_LIST -->
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

ITEMS_KEY = "items"
UNIQUE_ITEMS_KEY = "uniqueItems"
TUPLE_ITEMS_KEY = "prefixItems"
TYPE_KEY = "type"
REF_KEY = "$ref"
ADDITIONAL_PROPERTIES_KEY = "additionalProperties"
Expand Down Expand Up @@ -134,6 +135,21 @@ def retrieve_primitive_type_from_property(
return replace(
result, type_annotation=f"{high_level_type}[{result.type_annotation}]"
)
if TUPLE_ITEMS_KEY in property_definition:
nested_annotations = [
retrieve_primitive_type_from_property(
property_name=property_name,
property_description=property_description,
property_definition=nested_definition,
)
for nested_definition in property_definition[TUPLE_ITEMS_KEY]
]
inner_types = ", ".join(a.type_annotation for a in nested_annotations)
return PrimitiveTypeDefinition(
property_name=property_name,
property_description=property_description,
type_annotation=f"Tuple[{inner_types}]",
)
if property_definition.get(TYPE_KEY) in TYPE_MAPPING:
type_name = TYPE_MAPPING[property_definition[TYPE_KEY]]
return PrimitiveTypeDefinition(
Expand Down