Adit1Sharma commited on
Commit
d1b1ddc
·
1 Parent(s): 9b8e4e2

fix: format text labels as period-separated lowercase string for Grounding DINO processor

Browse files
Files changed (1) hide show
  1. api/services/dino_service.py +6 -3
api/services/dino_service.py CHANGED
@@ -21,13 +21,16 @@ class GroundingDinoService:
21
  Executes object detection on the PIL Image using the configured labels and thresholds.
22
  Returns a list of detections containing label, confidence score, and bounding boxes.
23
  """
24
- # Format labels as expected by processor: nested list containing label strings
25
- formatted_labels = [settings.TEXT_LABELS]
 
 
 
26
 
27
  # Prepare inputs
28
  inputs = self.processor(
29
  images=image,
30
- text=formatted_labels,
31
  return_tensors="pt"
32
  ).to(self.model.device)
33
 
 
21
  Executes object detection on the PIL Image using the configured labels and thresholds.
22
  Returns a list of detections containing label, confidence score, and bounding boxes.
23
  """
24
+ # Format labels as expected by the Grounding DINO processor:
25
+ # A single lowercase string containing all labels separated by periods and ending with a period.
26
+ text_prompt = ". ".join(settings.TEXT_LABELS).lower().strip()
27
+ if not text_prompt.endswith("."):
28
+ text_prompt += "."
29
 
30
  # Prepare inputs
31
  inputs = self.processor(
32
  images=image,
33
+ text=text_prompt,
34
  return_tensors="pt"
35
  ).to(self.model.device)
36