Skip to content

Commit 40698b7

Browse files
Merge pull request #874 from roboflow/fix/annotate_image_at_roboflow-for-multi-label-annotations
Extend roboflow_api.annotate_image_at_roboflow to pass list of classes if multi-label-classification model was used
2 parents a24d655 + d3b809a commit 40698b7

File tree

2 files changed

+6
-2
lines changed
  • inference/core/workflows/core_steps
    • models/roboflow/multi_label_classification
    • sinks/roboflow/dataset_upload

2 files changed

+6
-2
lines changed

inference/core/workflows/core_steps/models/roboflow/multi_label_classification/v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def run_locally(
181181
api_key=self._api_key,
182182
)
183183
predictions = self._model_manager.infer_from_request_sync(
184-
model_id=model_id, request=request
184+
model_id=model_id, request=request, confidence=confidence
185185
)
186186
if isinstance(predictions, list):
187187
predictions = [

inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,9 @@ def is_prediction_registration_forbidden(
552552
return True
553553
if isinstance(prediction, sv.Detections) and len(prediction) == 0:
554554
return True
555-
if isinstance(prediction, dict) and "top" not in prediction:
555+
if isinstance(prediction, dict) and all(
556+
k not in prediction for k in ["top", "predicted_classes"]
557+
):
556558
return True
557559
return False
558560

@@ -561,6 +563,8 @@ def encode_prediction(
561563
prediction: Union[sv.Detections, dict],
562564
) -> Tuple[str, str]:
563565
if isinstance(prediction, dict):
566+
if "predicted_classes" in prediction:
567+
return ",".join(prediction["predicted_classes"]), "txt"
564568
return prediction["top"], "txt"
565569
detections_in_inference_format = serialise_sv_detections(detections=prediction)
566570
return json.dumps(detections_in_inference_format), "json"

0 commit comments

Comments
 (0)