Special case for REGION_TO_DESCRIPTION when nothing is detected

This commit is contained in:
LinasKo 2024-06-21 15:38:21 +03:00
parent fc11f4d7af
commit 19bf417810
1 changed files with 3 additions and 0 deletions

View File

@ -165,6 +165,9 @@ def from_florence_2(
result, str
), f"Expected string as <REGION_TO_CATEGORY> result, got {type(result)}"
if result == "No object detected.":
return np.empty((0, 4), dtype=np.float32), np.array([]), None, None
pattern = re.compile(r"<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>")
match = pattern.search(result)
assert (