diff --git a/inference/core/version.py b/inference/core/version.py index a54b5b3ab..d124e3d98 100644 --- a/inference/core/version.py +++ b/inference/core/version.py @@ -1,4 +1,4 @@ -__version__ = "0.20.0" +__version__ = "0.20.1" if __name__ == "__main__": diff --git a/inference/core/workflows/core_steps/analytics/line_counter/v1.py b/inference/core/workflows/core_steps/analytics/line_counter/v1.py index 127b0ada3..e1892119c 100644 --- a/inference/core/workflows/core_steps/analytics/line_counter/v1.py +++ b/inference/core/workflows/core_steps/analytics/line_counter/v1.py @@ -61,12 +61,11 @@ class LineCounterManifest(WorkflowBlockManifest): ) line_segment: Union[list, StepOutputSelector(kind=[LIST_OF_VALUES_KIND]), WorkflowParameterSelector(kind=[LIST_OF_VALUES_KIND])] = Field( # type: ignore - description="Lines (one for each batch) in a format [(x1, y1), (x2, y2)];" - " direction of line zone is assumed to be that of direction of vector normal to [(x1, y1), (x2, y2)]", - examples=["$inputs.zones"], + 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", + examples=[[[0, 50], [500, 50]], "$inputs.zones"], ) - triggering_anchor: Union[str, WorkflowParameterSelector(kind=[STRING_KIND])] = Field( # type: ignore - description=f"Triggering anchor. Allowed values: {', '.join(sv.Position.list())}", + triggering_anchor: Union[str, WorkflowParameterSelector(kind=[STRING_KIND]), Literal[tuple(sv.Position.list())]] = Field( # type: ignore + description=f"Point from the detection for triggering line crossing.", default="CENTER", examples=["CENTER"], ) diff --git a/inference/core/workflows/core_steps/visualizations/line_zone/v1.py b/inference/core/workflows/core_steps/visualizations/line_zone/v1.py index 518fadd75..2a1f459e6 100644 --- a/inference/core/workflows/core_steps/visualizations/line_zone/v1.py +++ b/inference/core/workflows/core_steps/visualizations/line_zone/v1.py @@ -14,6 +14,7 @@ from inference.core.workflows.core_steps.visualizations.common.utils import str_to_color from inference.core.workflows.execution_engine.entities.base import WorkflowImageData from inference.core.workflows.execution_engine.entities.types import ( + FLOAT_KIND, FLOAT_ZERO_TO_ONE_KIND, INTEGER_KIND, LIST_OF_VALUES_KIND, @@ -47,9 +48,8 @@ class LineCounterZoneVisualizationManifest(VisualizationManifest): } ) zone: Union[list, StepOutputSelector(kind=[LIST_OF_VALUES_KIND]), WorkflowParameterSelector(kind=[LIST_OF_VALUES_KIND])] = Field( # type: ignore - description="Line zones (one for each batch) in a format [[(x1, y1), (x2, y2)], ...];" - " each zone must consist of exactly two points", - examples=["$inputs.zones"], + description="Line in the format [[x1, y1], [x2, y2]] consisting of exactly two points.", + examples=[[[0, 50], [500, 50]], "$inputs.zones"], ) color: Union[str, WorkflowParameterSelector(kind=[STRING_KIND])] = Field( # type: ignore description="Color of the zone.", @@ -61,15 +61,27 @@ class LineCounterZoneVisualizationManifest(VisualizationManifest): default=2, examples=[2, "$inputs.thickness"], ) + text_thickness: Union[int, WorkflowParameterSelector(kind=[INTEGER_KIND])] = Field( # type: ignore + description="Thickness of the text in pixels.", + default=1, + examples=[1, "$inputs.text_thickness"], + ) + text_scale: Union[float, WorkflowParameterSelector(kind=[FLOAT_KIND])] = Field( # type: ignore + description="Scale of the text.", + default=1.0, + examples=[1.0, "$inputs.text_scale"], + ) count_in: Union[int, WorkflowParameterSelector(kind=[INTEGER_KIND]), StepOutputSelector(kind=[INTEGER_KIND])] = Field( # type: ignore - description="Thickness of the lines in pixels.", + description="Reference to the number of objects that crossed into the line zone.", default=0, - examples=[2, "$inputs.thickness"], + examples=["$steps.line_counter.count_in"], + json_schema_extra={"always_visible": True}, ) count_out: Union[int, WorkflowParameterSelector(kind=[INTEGER_KIND]), StepOutputSelector(kind=[INTEGER_KIND])] = Field( # type: ignore - description="Thickness of the lines in pixels.", + description="Reference to the number of objects that crossed out of the line zone.", default=0, - examples=[2, "$inputs.thickness"], + examples=["$steps.line_counter.count_out"], + json_schema_extra={"always_visible": True}, ) opacity: Union[FloatZeroToOne, WorkflowParameterSelector(kind=[FLOAT_ZERO_TO_ONE_KIND])] = Field( # type: ignore description="Transparency of the Mask overlay.", @@ -104,6 +116,8 @@ def run( copy_image: bool, color: str, thickness: int, + text_thickness: int, + text_scale: int, count_in: int, count_out: int, opacity: float, @@ -142,7 +156,8 @@ def run( scene=annotated_image, text=f"in: {count_in}, out: {count_out}", text_anchor=sv.Point(x1, y1), - text_thickness=1, + text_thickness=text_thickness, + text_scale=text_scale, background_color=sv.Color.WHITE, text_padding=0, ) diff --git a/tests/workflows/unit_tests/core_steps/visualizations/test_line_counter_zone.py b/tests/workflows/unit_tests/core_steps/visualizations/test_line_counter_zone.py index 52b08979c..814159d16 100644 --- a/tests/workflows/unit_tests/core_steps/visualizations/test_line_counter_zone.py +++ b/tests/workflows/unit_tests/core_steps/visualizations/test_line_counter_zone.py @@ -28,6 +28,8 @@ def test_line_counter_zone_validation_when_valid_manifest_is_given( "color": "#FFFFFF", "opacity": 0.5, "thickness": 3, + "text_thickness": 1, + "text_scale": 2.0, "count_in": 7, "count_out": 1, } @@ -44,6 +46,8 @@ def test_line_counter_zone_validation_when_valid_manifest_is_given( color="#FFFFFF", opacity=0.5, thickness=3, + text_thickness=1, + text_scale=2.0, count_in=7, count_out=1, ) @@ -59,6 +63,8 @@ def test_line_counter_zone_validation_when_invalid_image_is_given() -> None: "color": "#FFFFFF", "opacity": 0.5, "thickness": 3, + "text_thickness": 1, + "text_scale": 2.0, "count_in": 7, "count_out": 1, } @@ -83,6 +89,8 @@ def test_line_counter_zone_visualization_block() -> None: color="#FF0000", opacity=1, thickness=3, + text_thickness=1, + text_scale=1.0, count_in=7, count_out=1, )