From ca4dcddf84da726304f959d2de89a8dbf4f62355 Mon Sep 17 00:00:00 2001 From: Grzegorz Klimaszewski <166530809+grzegorz-roboflow@users.noreply.github.com> Date: Fri, 24 Jan 2025 16:56:19 +0100 Subject: [PATCH 1/3] wip --- inference/core/interfaces/http/http_api.py | 3 +++ .../manager_app/inference_pipeline_manager.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/inference/core/interfaces/http/http_api.py b/inference/core/interfaces/http/http_api.py index 949a51f88..fbb950384 100644 --- a/inference/core/interfaces/http/http_api.py +++ b/inference/core/interfaces/http/http_api.py @@ -1410,6 +1410,9 @@ async def initialise(request: InitialisePipelinePayload) -> CommandResponse: async def initialise_webrtc_inference_pipeline( request: InitialiseWebRTCPipelinePayload, ) -> CommandResponse: + print("#################################") + print(request.json()) + print("#################################") resp = await self.stream_manager_client.initialise_webrtc_pipeline( initialisation_request=request ) diff --git a/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py b/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py index 4350ca2d6..99efc1e8c 100644 --- a/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py +++ b/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py @@ -281,6 +281,12 @@ def webrtc_sink( if prediction[parsed_payload.stream_output[0]] is None: from_inference_queue.sync_put(video_frame.image) return + print("#################################") + print(type(prediction[parsed_payload.stream_output[0]])) + print("------") + for k, v in prediction.items(): + print(f"{k}: {type(v)}") + print("#################################") from_inference_queue.sync_put( prediction[parsed_payload.stream_output[0]].numpy_image ) From a4b40dc2ddb2e2c3202252c1ffbcca9366804099 Mon Sep 17 00:00:00 2001 From: Grzegorz Klimaszewski <166530809+grzegorz-roboflow@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:43:48 +0100 Subject: [PATCH 2/3] Show guidance on preview if user needs to configure visual outputs in workflow --- inference/core/interfaces/http/http_api.py | 3 -- .../stream_manager/manager_app/entities.py | 4 +- .../manager_app/inference_pipeline_manager.py | 43 ++++++++++++++----- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/inference/core/interfaces/http/http_api.py b/inference/core/interfaces/http/http_api.py index fbb950384..949a51f88 100644 --- a/inference/core/interfaces/http/http_api.py +++ b/inference/core/interfaces/http/http_api.py @@ -1410,9 +1410,6 @@ async def initialise(request: InitialisePipelinePayload) -> CommandResponse: async def initialise_webrtc_inference_pipeline( request: InitialiseWebRTCPipelinePayload, ) -> CommandResponse: - print("#################################") - print(request.json()) - print("#################################") resp = await self.stream_manager_client.initialise_webrtc_pipeline( initialisation_request=request ) diff --git a/inference/core/interfaces/stream_manager/manager_app/entities.py b/inference/core/interfaces/stream_manager/manager_app/entities.py index c5c4e3022..4703a03f7 100644 --- a/inference/core/interfaces/stream_manager/manager_app/entities.py +++ b/inference/core/interfaces/stream_manager/manager_app/entities.py @@ -100,8 +100,8 @@ class WebRTCTURNConfig(BaseModel): class InitialiseWebRTCPipelinePayload(InitialisePipelinePayload): webrtc_offer: WebRTCOffer webrtc_turn_config: Optional[WebRTCTURNConfig] = None - stream_output: Optional[List[str]] = Field(default_factory=list) - data_output: Optional[List[str]] = Field(default_factory=list) + stream_output: Optional[List[Optional[str]]] = Field(default_factory=list) + data_output: Optional[List[Optional[str]]] = Field(default_factory=list) webrtc_peer_timeout: float = 1 webcam_fps: Optional[float] = None diff --git a/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py b/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py index 99efc1e8c..1cc929854 100644 --- a/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py +++ b/inference/core/interfaces/stream_manager/manager_app/inference_pipeline_manager.py @@ -11,6 +11,7 @@ from types import FrameType from typing import Dict, Optional, Tuple +import cv2 as cv from pydantic import ValidationError from inference.core import logger @@ -275,18 +276,38 @@ def start_loop(loop: asyncio.AbstractEventLoop): def webrtc_sink( prediction: Dict[str, WorkflowImageData], video_frame: VideoFrame ) -> None: - if parsed_payload.stream_output[0] not in prediction: - from_inference_queue.sync_put(video_frame.image) - return - if prediction[parsed_payload.stream_output[0]] is None: - from_inference_queue.sync_put(video_frame.image) + errors = [] + if not any( + isinstance(v, WorkflowImageData) for v in prediction.values() + ): + errors.append("Visualisation blocks were not executed") + errors.append("or workflow was not configured to output visuals.") + errors.append( + "Please try to adjust the scene so models detect objects" + ) + errors.append("or stop preview, update workflow and try again.") + elif parsed_payload.stream_output[0] not in prediction: + if not parsed_payload.stream_output[0]: + errors.append("No stream output selected to show") + else: + errors.append( + f"{parsed_payload.stream_output[0]} not available in results" + ) + errors.append("Please stop, update outputs and try again") + if errors: + result_frame = video_frame.image.copy() + for row, error in enumerate(errors): + result_frame = cv.putText( + result_frame, + error, + (10, 20 + 30 * row), + cv.FONT_HERSHEY_SIMPLEX, + 0.7, + (0, 255, 0), + 2, + ) + from_inference_queue.sync_put(result_frame) return - print("#################################") - print(type(prediction[parsed_payload.stream_output[0]])) - print("------") - for k, v in prediction.items(): - print(f"{k}: {type(v)}") - print("#################################") from_inference_queue.sync_put( prediction[parsed_payload.stream_output[0]].numpy_image ) From 9a5b3f3d5c2cbb54ce9d411a277be387a21648aa Mon Sep 17 00:00:00 2001 From: Grzegorz Klimaszewski <166530809+grzegorz-roboflow@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:52:07 +0100 Subject: [PATCH 3/3] 0.35.0 --- inference/core/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference/core/version.py b/inference/core/version.py index e8eb7c8d3..9cc9b6c89 100644 --- a/inference/core/version.py +++ b/inference/core/version.py @@ -1,4 +1,4 @@ -__version__ = "0.35.0rc2" +__version__ = "0.35.0" if __name__ == "__main__":