Skip to content

Commit

Permalink
Merge pull request #874 from roboflow/fix/annotate_image_at_roboflow-…
Browse files Browse the repository at this point in the history
…for-multi-label-annotations

Extend roboflow_api.annotate_image_at_roboflow to pass list of classes if multi-label-classification model was used
  • Loading branch information
grzegorz-roboflow authored Dec 12, 2024
2 parents a24d655 + d3b809a commit 40698b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def run_locally(
api_key=self._api_key,
)
predictions = self._model_manager.infer_from_request_sync(
model_id=model_id, request=request
model_id=model_id, request=request, confidence=confidence
)
if isinstance(predictions, list):
predictions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ def is_prediction_registration_forbidden(
return True
if isinstance(prediction, sv.Detections) and len(prediction) == 0:
return True
if isinstance(prediction, dict) and "top" not in prediction:
if isinstance(prediction, dict) and all(
k not in prediction for k in ["top", "predicted_classes"]
):
return True
return False

Expand All @@ -561,6 +563,8 @@ def encode_prediction(
prediction: Union[sv.Detections, dict],
) -> Tuple[str, str]:
if isinstance(prediction, dict):
if "predicted_classes" in prediction:
return ",".join(prediction["predicted_classes"]), "txt"
return prediction["top"], "txt"
detections_in_inference_format = serialise_sv_detections(detections=prediction)
return json.dumps(detections_in_inference_format), "json"

0 comments on commit 40698b7

Please sign in to comment.