non-max-merging visualization + `from_lmm` updates

This commit is contained in:
SkalskiP 2024-06-05 15:40:28 +02:00
parent 59c5ab5252
commit c28c93bd4f
3 changed files with 25 additions and 3 deletions

View File

@ -1222,7 +1222,9 @@ class Detections:
Raises:
AssertionError: If `confidence` is None or `class_id` is None and
class_agnostic is False.
"""
![non-max-merging](https://media.roboflow.com/supervision-docs/non-max-merging.png){ align=center width="800" }
""" # noqa: E501 // docs
if len(self) == 0:
return self

View File

@ -41,7 +41,7 @@ def from_paligemma(
) -> Tuple[np.ndarray, Optional[np.ndarray], np.ndarray]:
w, h = resolution_wh
pattern = re.compile(
r"(?<!<loc\d{4}>)<loc(\d{4})><loc(\d{4})><loc(\d{4})><loc(\d{4})> ([\w\s]+)"
r"(?<!<loc\d{4}>)<loc(\d{4})><loc(\d{4})><loc(\d{4})><loc(\d{4})> ([\w\s\-]+)"
)
matches = pattern.findall(result)
matches = np.array(matches) if matches else np.empty((0, 5))

View File

@ -76,7 +76,27 @@ from supervision.detection.lmm import from_paligemma
None,
np.array(["black cat"]).astype(np.dtype("U")),
),
), # correct response; no classes
), # correct response; class name with space; no classes
(
"<loc0256><loc0256><loc0768><loc0768> black-cat",
(1000, 1000),
None,
(
np.array([[250.0, 250.0, 750.0, 750.0]]),
None,
np.array(["black-cat"]).astype(np.dtype("U")),
),
), # correct response; class name with hyphen; no classes
(
"<loc0256><loc0256><loc0768><loc0768> black_cat",
(1000, 1000),
None,
(
np.array([[250.0, 250.0, 750.0, 750.0]]),
None,
np.array(["black_cat"]).astype(np.dtype("U")),
),
), # correct response; class name with underscore; no classes
(
"<loc0256><loc0256><loc0768><loc0768> cat ;",
(1000, 1000),