> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Grounding DINO 

The `GroundingDINO` implements a wrapper for the GroundingDINO model, which detects objects in RGB images based on text prompts.

<ResponseField name="class GroundingDINO()">
  <ResponseField name="box_threshold" type="float" default="0.4">
    Confidence threshold for bounding box detection.
  </ResponseField>

  <ResponseField name="text_threshold" type="float" default="0.25">
    Confidence threshold for text-based object detection.
  </ResponseField>

  <ResponseField name="use_local" type="boolean" default="False">
    If True, inference call is run on the local VM, else offloaded onto GRID-Cortex. Defaults to False.
  </ResponseField>
</ResponseField>

<ResponseField name="def run()">
  <ResponseField name="rgbimage" type="np.ndarray" required="True">
    The input RGB image of shape $(M,N,3)$.
  </ResponseField>

  <ResponseField name="prompt" type="str" required="True">
    Text prompt for object detection. Multiple prompts can be separated by a ".".
  </ResponseField>

  <ResponseField name="Returns" type="List[float], List[float], List[str]">
    Returns three lists: bounding boxes coordinates, confidence scores, and label strings.
  </ResponseField>
</ResponseField>

<RequestExample>
  ```python Inference Call theme={null}
  from grid.model.perception.detection.gdino import GroundingDINO
  car = AirGenCar()

  # We will be capturing an image from the AirGen simulator 
  # and run model inference on it.

  img =  car.getImage("front_center", "rgb").data

  model = GroundingDINO(use_local = False)
  box, scores, labels = model.run(rgbimage=img, prompt=<prompt>)
  print(box, scores, labels)

  ## if you want to use the model locally, set use_local=True
  model = GroundingDINO(use_local = True)
  box, scores, labels = model.run(rgbimage=img, prompt=<prompt>)
  print(box, labels)
  ```
</RequestExample>

<Tabs>
  <Tab title="License">
    This code is licensed under the Apache 2.0 License.
  </Tab>

  <Tab title="Source">
    No credits information provided.
  </Tab>
</Tabs>
