> ## 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.

# owlv2

> Detect objects in image using text prompt

Detect objects in image using text prompt.

## Parameters

<ParamField body="image_input" type="ImageInput" required>
  RGB image as file path, URL, PIL Image, or numpy array.
</ParamField>

<ParamField body="prompt" type="str" required>
  Text description of objects to detect.
</ParamField>

<ParamField body="box_threshold" type="float | None">
  Optional confidence threshold (0.0-1.0) for filtering detections.
</ParamField>

<ParamField body="timeout" type="float | None">
  Optional timeout in seconds for the HTTP request.
</ParamField>

## Returns

Dictionary with keys:

* "boxes": List of bounding boxes as \[x1, y1, x2, y2] coordinates
* "scores": List of confidence scores (0.0-1.0)
* "labels": List of label indices

## Example

```python theme={null}
from grid_cortex_client import CortexClient, ModelType
import numpy as np
from PIL import Image
client = CortexClient()
image = np.array(Image.open("cat.jpg"))
dets = client.run(ModelType.OWLV2, image_input=image, prompt="a cat")
print(f"Found {len(dets['boxes'])} objects")
```

Uses Google's OWL-ViT v2.

## Tips

* Prompt with period-separated object phrases, e.g. `"car. person. traffic light"`.
* `box_threshold` defaults to `0.2`.

## Example Output

<img src="https://mintcdn.com/scaledfoundations/lgZgGQWKvUIw0C7n/assets/images/cortex/owlv2-output.jpg?fit=max&auto=format&n=lgZgGQWKvUIw0C7n&q=85&s=dd4a06e4f28a481ae8bf5160864ab269" alt="OWLv2 object detection output with bounding boxes" width="544" height="552" data-path="assets/images/cortex/owlv2-output.jpg" />

```python theme={null}
from grid_cortex_client import CortexClient
from PIL import Image

client = CortexClient()
image = Image.open("scene.jpg")  # 640x480 RGB
dets = client.run(
    model_id="owlv2",
    image_input=image,
    prompt="building.",
    box_threshold=0.1,
)

print(len(dets["boxes"]))
# 10

# Top detections:
print(dets["scores"][0], dets["boxes"][0])
# 0.152  [122.0, 5.7, 187.9, 227.1]

print(dets["scores"][1], dets["boxes"][1])
# 0.271  [167.7, 26.6, 334.8, 242.4]

print(dets["scores"][2], dets["boxes"][2])
# 0.165  [-0.5, -0.9, 179.5, 242.3]
```


## Related topics

- [owlv2](/models/cortex/owlv2.md)
- [AsyncCortexClient](/python-api/grid-cortex-client/asynccortexclient.md)
- [CortexClient](/python-api/grid-cortex-client/cortexclient.md)
