From cb5e9c0df07e15a06899429eb834c94f7db67a2d Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Tue, 5 Dec 2023 13:57:27 +0100 Subject: [PATCH] Added error handling in Detections.from_azure_analyze_image method --- supervision/detection/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 75fd0a9c..8d97bc03 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -525,6 +525,11 @@ class Detections: >>> detections = sv.Detections.from_azure_analyze_image(response) """ + if "error" in azure_result: + raise ValueError( + f'Azure API returned an error {azure_result["error"]["message"]}' + ) + xyxy, confidences, class_ids = [], [], [] is_dynamic_mapping = class_map is None