Update task file
Browse files- src/task.py +5 -2
src/task.py
CHANGED
@@ -1,4 +1,6 @@
|
|
|
|
1 |
import copy
|
|
|
2 |
from src.utils import clean_text, draw_ocr_bboxes
|
3 |
from src.model import run_example
|
4 |
|
@@ -26,9 +28,10 @@ def ocr_task(image):
|
|
26 |
# Get OCR with region
|
27 |
ocr_with_region_results = run_example(ocr_with_region_prompt, image)
|
28 |
output_image = copy.deepcopy(image)
|
29 |
-
|
30 |
-
|
31 |
)
|
|
|
32 |
|
33 |
# Return the output image and cleaned OCR text
|
34 |
return output_image, cleaned_text
|
|
|
1 |
+
# Import necessary libraries
|
2 |
import copy
|
3 |
+
import supervision as sv
|
4 |
from src.utils import clean_text, draw_ocr_bboxes
|
5 |
from src.model import run_example
|
6 |
|
|
|
28 |
# Get OCR with region
|
29 |
ocr_with_region_results = run_example(ocr_with_region_prompt, image)
|
30 |
output_image = copy.deepcopy(image)
|
31 |
+
detections = sv.Detections.from_lmm(
|
32 |
+
lmm=sv.LMM.FLORENCE_2, result=ocr_with_region_results, resolution_wh=image.size
|
33 |
)
|
34 |
+
output_image = draw_ocr_bboxes(image, detections)
|
35 |
|
36 |
# Return the output image and cleaned OCR text
|
37 |
return output_image, cleaned_text
|