Skip to content

Commit 2b859e6

Browse files
authored
fix: ignore requests from Label Studio with empty contexts (#386)
Ignore requests from Label Studio with empty contexts If Label Studio sends an empty context, ignore
1 parent 75bcda7 commit 2b859e6

File tree

1 file changed

+4
-0
lines changed
  • label_studio_ml/examples/grounding_dino

1 file changed

+4
-0
lines changed

label_studio_ml/examples/grounding_dino/dino.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def __init__(self, project_id, **kwargs):
7676

7777

7878
def predict(self, tasks: List[Dict], context: Optional[Dict] = None, **kwargs) -> List[Dict]:
79+
if not context or not context.get('result'):
80+
# if there is no context, no interaction has happened yet
81+
return []
7982

8083
self.from_name_r, self.to_name_r, self.value_r = self.get_first_tag_occurence('RectangleLabels', 'Image')
8184
self.from_name_b, self.to_name_b, self.value_b = self.get_first_tag_occurence('BrushLabels', 'Image')
@@ -404,4 +407,5 @@ def sam_predictions(self, masks, probs, lengths):
404407
})
405408
return {
406409
'result': results
410+
407411
}

0 commit comments

Comments
 (0)