docs: 📝 add examples for using from_vlm with Moondream results in Detections class
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
This commit is contained in:
parent
e17e7d712f
commit
7076b4da0c
|
|
@ -1009,6 +1009,35 @@ class Detections:
|
|||
detections.data
|
||||
# {'class_name': array(['cat', 'dog'], dtype='<U26')}
|
||||
```
|
||||
|
||||
Examples:
|
||||
```python
|
||||
import supervision as sv
|
||||
|
||||
moondream_result = \"\"\"
|
||||
{'objects': [{'x_min': 0.5704046934843063,
|
||||
'y_min': 0.20069346576929092,
|
||||
'x_max': 0.7049859315156937,
|
||||
'y_max': 0.3012596592307091},
|
||||
{'x_min': 0.6210969910025597,
|
||||
'y_min': 0.3300672620534897,
|
||||
'x_max': 0.8417936339974403,
|
||||
'y_max': 0.4961046129465103}]}}]
|
||||
\"\"\"
|
||||
|
||||
detections = sv.Detections.from_vlm(
|
||||
sv.VLM.MOONDREAM,
|
||||
moondream_result,
|
||||
resolution_wh=(IMAGE.size[0], IMAGE.size[1]),
|
||||
)
|
||||
|
||||
detections.xyxy
|
||||
# array([[1752.28, 818.82, 2165.72, 1229.14],
|
||||
# [1908.01, 1346.67, 2585.99, 2024.11]])
|
||||
|
||||
detections.class_id
|
||||
# array([0, 1])
|
||||
|
||||
"""
|
||||
vlm = validate_vlm_parameters(vlm, result, kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue