Skip to content

Commit

Permalink
Merge pull request #996 from roboflow/block_copy
Browse files Browse the repository at this point in the history
Update Block Copy
  • Loading branch information
PawelPeczek-Roboflow authored Feb 5, 2025
2 parents 612df6b + fac02c0 commit 0861cd1
Show file tree
Hide file tree
Showing 75 changed files with 452 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class LineCounterManifest(WorkflowBlockManifest):
)

line_segment: Union[list, Selector(kind=[LIST_OF_VALUES_KIND]), Selector(kind=[LIST_OF_VALUES_KIND])] = Field( # type: ignore
description="Line in the format [[x1, y1], [x2, y2]] consisting of exactly two points. For line [[0, 100], [100, 100]] line will count objects entering from the bottom as IN",
description="Line consisting of exactly two points. For line [[0, 100], [100, 100]], objects entering from the bottom will count as IN.",
examples=[[[0, 50], [500, 50]], "$inputs.zones"],
)
triggering_anchor: Union[str, Selector(kind=[STRING_KIND]), Literal[tuple(sv.Position.list())]] = Field( # type: ignore
description=f"Point from the detection for triggering line crossing.",
description=f"The point on the detection that must cross the line to be counted.",
default="CENTER",
examples=["CENTER"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ class LineCounterManifest(WorkflowBlockManifest):
INSTANCE_SEGMENTATION_PREDICTION_KIND,
]
) = Field( # type: ignore
description="Predictions",
description="Model predictions to count line crossings for.",
examples=["$steps.object_detection_model.predictions"],
)

line_segment: Union[list, Selector(kind=[LIST_OF_VALUES_KIND]), Selector(kind=[LIST_OF_VALUES_KIND])] = Field( # type: ignore
description="Line in the format [[x1, y1], [x2, y2]] consisting of exactly two points. For line [[0, 100], [100, 100]] line will count objects entering from the bottom as IN",
description="Line consisting of exactly two points. For line [[0, 100], [100, 100]], objects entering from the bottom will count as IN.",
examples=[[[0, 50], [500, 50]], "$inputs.zones"],
)
triggering_anchor: Union[str, Selector(kind=[STRING_KIND]), Literal[tuple(sv.Position.list())]] = Field( # type: ignore
description=f"Point from the detection for triggering line crossing.",
description=f"The point on the detection that must cross the line to be counted.",
default="CENTER",
examples=["CENTER"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PathDeviationManifest(WorkflowBlockManifest):
examples=["$steps.object_detection_model.predictions"],
)
triggering_anchor: Union[str, Selector(kind=[STRING_KIND]), Literal[tuple(sv.Position.list())]] = Field( # type: ignore
description=f"Triggering anchor. Allowed values: {', '.join(sv.Position.list())}",
description=f"Point on the detection that will be used to calculate the Frechet distance.",
default="CENTER",
examples=["CENTER"],
)
Expand Down
12 changes: 6 additions & 6 deletions inference/core/workflows/core_steps/analytics/time_in_zone/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,25 @@ class TimeInZoneManifest(WorkflowBlockManifest):
INSTANCE_SEGMENTATION_PREDICTION_KIND,
]
) = Field( # type: ignore
description="Predictions",
description="Model predictions to calculate the time spent in zone for.",
examples=["$steps.object_detection_model.predictions"],
)
zone: Union[list, Selector(kind=[LIST_OF_VALUES_KIND]), Selector(kind=[LIST_OF_VALUES_KIND])] = Field( # type: ignore
description="Zones (one for each batch) in a format [(x1, y1), (x2, y2), (x3, y3), ...]",
description="Coordinates of the target zone.",
examples=["$inputs.zones"],
)
triggering_anchor: Union[str, Selector(kind=[STRING_KIND])] = Field( # type: ignore
description=f"Triggering anchor. Allowed values: {', '.join(sv.Position.list())}",
triggering_anchor: Union[str, Selector(kind=[STRING_KIND]), Literal[tuple(sv.Position.list())]] = Field( # type: ignore
description=f"The point on the detection that must be inside the zone.",
default="CENTER",
examples=["CENTER"],
)
remove_out_of_zone_detections: Union[bool, Selector(kind=[BOOLEAN_KIND])] = Field( # type: ignore
description=f"If true, detections found outside of zone will be filtered out",
description=f"If true, detections found outside of zone will be filtered out.",
default=True,
examples=[True, False],
)
reset_out_of_zone_detections: Union[bool, Selector(kind=[BOOLEAN_KIND])] = Field( # type: ignore
description=f"If true, detections found outside of zone will have time reset",
description=f"If true, detections found outside of zone will have time reset.",
default=True,
examples=[True, False],
)
Expand Down
14 changes: 7 additions & 7 deletions inference/core/workflows/core_steps/analytics/time_in_zone/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,25 @@ class TimeInZoneManifest(WorkflowBlockManifest):
INSTANCE_SEGMENTATION_PREDICTION_KIND,
]
) = Field( # type: ignore
description="Predictions",
description="Model predictions to calculate the time spent in zone for.",
examples=["$steps.object_detection_model.predictions"],
)
zone: Union[list, Selector(kind=[LIST_OF_VALUES_KIND]), Selector(kind=[LIST_OF_VALUES_KIND])] = Field( # type: ignore
description="Zones (one for each batch) in a format [(x1, y1), (x2, y2), (x3, y3), ...]",
examples=["$inputs.zones"],
description="Coordinates of the target zone.",
examples=[[(100, 100), (100, 200), (300, 200), (300, 100)], "$inputs.zones"],
)
triggering_anchor: Union[str, Selector(kind=[STRING_KIND])] = Field( # type: ignore
description=f"Triggering anchor. Allowed values: {', '.join(sv.Position.list())}",
triggering_anchor: Union[str, Selector(kind=[STRING_KIND]), Literal[tuple(sv.Position.list())]] = Field( # type: ignore
description=f"The point on the detection that must be inside the zone.",
default="CENTER",
examples=["CENTER"],
)
remove_out_of_zone_detections: Union[bool, Selector(kind=[BOOLEAN_KIND])] = Field( # type: ignore
description=f"If true, detections found outside of zone will be filtered out",
description=f"If true, detections found outside of zone will be filtered out.",
default=True,
examples=[True, False],
)
reset_out_of_zone_detections: Union[bool, Selector(kind=[BOOLEAN_KIND])] = Field( # type: ignore
description=f"If true, detections found outside of zone will have time reset",
description=f"If true, detections found outside of zone will have time reset.",
default=True,
examples=[True, False],
)
Expand Down
7 changes: 6 additions & 1 deletion inference/core/workflows/core_steps/analytics/velocity/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class VelocityManifest(WorkflowBlockManifest):
"long_description": LONG_DESCRIPTION,
"license": "Apache-2.0",
"block_type": "analytics",
"ui_manifest": {
"section": "video",
"icon": "far fa-gauge",
"blockPriority": 2.5,
},
}
)
type: Literal["roboflow_core/velocity@v1"]
Expand All @@ -59,7 +64,7 @@ class VelocityManifest(WorkflowBlockManifest):
INSTANCE_SEGMENTATION_PREDICTION_KIND,
]
) = Field( # type: ignore
description="Predictions",
description="Model predictions to calculate the velocity for.",
examples=["$steps.object_detection_model.predictions"],
)
smoothing_alpha: Union[float, Selector(kind=[FLOAT_KIND])] = Field( # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,24 @@ class SizeMeasurementManifest(WorkflowBlockManifest):
)
type: Literal["roboflow_core/size_measurement@v1"]

reference_predictions: Selector(
object_predictions: Selector(
kind=[
INSTANCE_SEGMENTATION_PREDICTION_KIND,
OBJECT_DETECTION_PREDICTION_KIND,
]
) = Field(
description="Predictions from the reference object model",
examples=["$segmentation.reference_predictions"],
description="Model predictions to measure the dimensions of.",
examples=["$segmentation.object_predictions"],
)
object_predictions: Selector(

reference_predictions: Selector(
kind=[
INSTANCE_SEGMENTATION_PREDICTION_KIND,
OBJECT_DETECTION_PREDICTION_KIND,
]
) = Field(
description="Predictions from the model that detects the object to measure",
examples=["$segmentation.object_predictions"],
description="Reference object used to calculate the dimensions of the specified objects. If multiple objects are provided, the highest confidence prediction will be used.",
examples=["$segmentation.reference_predictions"],
)
reference_dimensions: Union[
str,
Expand All @@ -101,8 +102,8 @@ class SizeMeasurementManifest(WorkflowBlockManifest):
kind=[STRING_KIND, LIST_OF_VALUES_KIND],
),
] = Field(
description="Dimensions of the reference object (width, height) in desired units (e.g., inches) as a string in the format 'width,height' or as a tuple (width, height)",
examples=["5.0,5.0", (5.0, 5.0), "$inputs.reference_dimensions"],
description="Dimensions of the reference object in desired units, (e.g. inches). Will be used to convert the pixel dimensions of the other objects to real-world units.",
examples=[(4.5, 3.0), "5.0,5.0", "$inputs.reference_dimensions"],
)

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,20 @@ class BlockManifest(WorkflowBlockManifest):
)
type: Literal["roboflow_core/continue_if@v1", "ContinueIf"]
condition_statement: StatementGroup = Field(
description="Workflows UQL definition of conditional logic.",
title="Conditional Statement",
description="Define the conditional logic.",
examples=[CONDITION_STATEMENT_EXAMPLE],
)
evaluation_parameters: Dict[
str,
Selector(),
] = Field(
description="References to additional parameters that may be provided in runtime to parametrise operations",
description="Data to be used in the conditional logic.",
examples=[{"left": "$inputs.some"}],
default_factory=lambda: {},
)
next_steps: List[StepSelector] = Field(
description="Reference to step which shall be executed if expression evaluates to true",
description="Steps to execute if the condition evaluates to true.",
examples=[["$steps.on_true"]],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class DeltaFilterManifest(WorkflowBlockManifest):
image: WorkflowImageSelector
value: Selector(kind=[WILDCARD_KIND]) = Field(
title="Input Value",
description="The input value for this step. Flow will be allowed to continue only if this value changes between frames.",
description="Flow will be allowed to continue only if this value changes between frames.",
examples=["$steps.line_counter.count_in"],
)
next_steps: List[StepSelector] = Field(
description="Reference to steps which shall be executed when value changes.",
description="Steps to execute when the value changes.",
examples=["$steps.write_to_csv", "$steps.write_to_opc"],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ class RateLimiterManifest(WorkflowBlockManifest):
ge=0.0,
)
depends_on: Selector() = Field(
description="Reference to any output of the the step which immediately preceeds this branch.",
description="Step immediately preceding this block.",
examples=["$steps.model"],
)
next_steps: List[StepSelector] = Field(
description="Reference to steps which shall be executed if rate limit allows.",
description="Steps to execute if allowed by the rate limit.",
examples=[["$steps.upload"]],
)
video_reference_image: Optional[WorkflowImageSelector] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class BlockManifest(WorkflowBlockManifest):
default_factory=lambda: {},
)
switch: CasesDefinition = Field(
description="Definition of switch-case statement",
title="Logic Definition",
description="Define the logic to be executed.",
examples=[SWITCH_STATEMENT_EXAMPLE],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class BlockManifest(WorkflowBlockManifest):
"PropertyExtraction",
]
data: Selector() = Field(
description="Reference data to extract property from",
description="Data to extract property from.",
examples=["$steps.my_step.predictions"],
)
operations: List[AllOperationsType] = Field(
description="List of operations to perform on data to generate output",
description="List of operations to perform on the data.",
examples=[
[{"type": "DetectionsPropertyExtract", "property_name": "class_name"}]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BlockManifest(WorkflowBlockManifest):
)
type: Literal["roboflow_core/detections_stitch@v1"]
reference_image: Selector(kind=[IMAGE_KIND]) = Field(
description="Image that was origin to take crops that yielded predictions.",
description="Original image that was cropped to produce the predictions.",
examples=["$inputs.image"],
)
predictions: Selector(
Expand All @@ -73,7 +73,7 @@ class BlockManifest(WorkflowBlockManifest):
INSTANCE_SEGMENTATION_PREDICTION_KIND,
]
) = Field(
description="The output of a detection model describing the bounding boxes to be merged.",
description="Model predictions to be merged into the original image.",
examples=["$steps.my_object_detection_model.predictions"],
)
overlap_filtering_strategy: Union[
Expand All @@ -82,16 +82,16 @@ class BlockManifest(WorkflowBlockManifest):
] = Field(
default="nms",
description="Which strategy to employ when filtering overlapping boxes. "
"None does nothing, NMS discards surplus detections, NMM merges them.",
"None does nothing, NMS discards lower-confidence detections, NMM combines them.",
examples=["nms", "$inputs.overlap_filtering_strategy"],
)
iou_threshold: Union[
FloatZeroToOne,
Selector(kind=[FLOAT_ZERO_TO_ONE_KIND]),
] = Field(
default=0.3,
description="Parameter of overlap filtering strategy. If box intersection over union is above this "
" ratio, discard or merge the lower confidence box.",
description="Minimum overlap threshold between boxes. If intersection over union (IoU) is above this "
"ratio, discard or merge the lower confidence box.",
examples=[0.4, "$inputs.iou_threshold"],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class BlockManifest(WorkflowBlockManifest):
"relevant_for": {
"task_type": {"values": TASKS_REQUIRING_PROMPT, "required": True},
},
"multiline": True,
},
)
output_structure: Optional[Dict[str, str]] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BlockManifest(WorkflowBlockManifest):
"ui_manifest": {
"section": "model",
"icon": "far fa-paperclip",
"blockPriority": 2,
"blockPriority": 9.9,
},
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class BlockManifest(WorkflowBlockManifest):
prompt: Union[Selector(kind=[STRING_KIND]), str] = Field(
description="Text prompt to the CogVLM model",
examples=["my prompt", "$inputs.prompt"],
json_schema_extra={
"multiline": True,
},
)
json_output_format: Optional[Dict[str, str]] = Field(
default=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class BaseManifest(WorkflowBlockManifest):
"relevant_for": {
"task_type": {"values": TASKS_REQUIRING_PROMPT, "required": True},
},
"multiline": True,
},
)
classes: Optional[Union[Selector(kind=[LIST_OF_VALUES_KIND]), List[str]]] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class BlockManifest(WorkflowBlockManifest):
"relevant_for": {
"task_type": {"values": TASKS_REQUIRING_PROMPT, "required": True},
},
"multiline": True,
},
)
output_structure: Optional[Dict[str, str]] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class BlockManifest(WorkflowBlockManifest):
"relevant_for": {
"task_type": {"values": TASKS_REQUIRING_PROMPT, "required": True},
},
"multiline": True,
},
)
output_structure: Optional[Dict[str, str]] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class BlockManifest(WorkflowBlockManifest):
prompt: Union[Selector(kind=[STRING_KIND]), str] = Field(
description="Holds unconstrained text prompt to LMM mode",
examples=["my prompt", "$inputs.prompt"],
json_schema_extra={
"multiline": True,
},
)
lmm_type: Union[Selector(kind=[STRING_KIND]), Literal["gpt_4v", "cog_vlm"]] = Field(
description="Type of LMM to be used", examples=["gpt_4v", "$inputs.lmm_type"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class BlockManifest(WorkflowBlockManifest):
prompt: Union[Selector(kind=[STRING_KIND]), str] = Field(
description="Text prompt to the OpenAI model",
examples=["my prompt", "$inputs.prompt"],
json_schema_extra={
"multiline": True,
},
)
openai_api_key: Union[Selector(kind=[STRING_KIND, SECRET_KIND]), Optional[str]] = (
Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class BlockManifest(WorkflowBlockManifest):
"relevant_for": {
"task_type": {"values": TASKS_REQUIRING_PROMPT, "required": True},
},
"multiline": True,
},
)
output_structure: Optional[Dict[str, str]] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class BlockManifest(WorkflowBlockManifest):
] = Field(
description="Prompt to generate new images from text (what you wish to see)",
examples=["my prompt", "$inputs.prompt"],
json_schema_extra={
"multiline": True,
},
)
negative_prompt: Optional[
Union[
Expand Down
Loading

0 comments on commit 0861cd1

Please sign in to comment.