Skip to content

Commit 9b30b8b

Browse files
committed
from_easy_ocr: cast results to float, remove class_id
1 parent 1a870b9 commit 9b30b8b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

supervision/detection/core.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -873,20 +873,20 @@ def from_easyocr(cls, easyocr_results: list) -> Detections:
873873

874874
bbox = np.array([result[0] for result in easyocr_results])
875875
xyxy = np.hstack((np.min(bbox, axis=1), np.max(bbox, axis=1)))
876+
confidence = np.array(
877+
[
878+
result[2] if len(result) > 2 and result[2] else 0
879+
for result in easyocr_results
880+
]
881+
)
882+
ocr_text = np.array([result[1] for result in easyocr_results])
876883

877884
return cls(
878-
xyxy=xyxy,
879-
confidence=np.array(
880-
[
881-
result[2] if len(result) > 2 and result[2] else 0
882-
for result in easyocr_results
883-
]
884-
),
885-
class_id=np.arange(len(xyxy)),
885+
xyxy=xyxy.astype(np.float32),
886+
confidence=confidence.astype(np.float32),
887+
class_id=None,
886888
data={
887-
CLASS_NAME_DATA_FIELD: np.array(
888-
[result[1] for result in easyocr_results]
889-
)
889+
CLASS_NAME_DATA_FIELD: ocr_text,
890890
},
891891
)
892892

0 commit comments

Comments
 (0)