sitammeur commited on
Commit
ffe55fe
1 Parent(s): 1b3384e

Delete src/task.py

Browse files
Files changed (1) hide show
  1. src/task.py +0 -35
src/task.py DELETED
@@ -1,35 +0,0 @@
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
-
7
-
8
- def ocr_task(image):
9
- """
10
- Perform OCR (Optical Character Recognition) on the given image.
11
-
12
- Args:
13
- image (PIL.Image.Image): The input image to perform OCR on.
14
-
15
- Returns:
16
- tuple: A tuple containing the output image with OCR bounding boxes drawn and the cleaned OCR text.
17
- """
18
- # Task prompts
19
- ocr_prompt = "<OCR>"
20
- ocr_with_region_prompt = "<OCR_WITH_REGION>"
21
-
22
- # Get OCR text
23
- ocr_results = run_example(ocr_prompt, image)
24
- cleaned_text = clean_text(ocr_results["<OCR>"])
25
-
26
- # Get OCR with region
27
- ocr_with_region_results = run_example(ocr_with_region_prompt, image)
28
- output_image = copy.deepcopy(image)
29
- detections = sv.Detections.from_lmm(
30
- lmm=sv.LMM.FLORENCE_2, result=ocr_with_region_results, resolution_wh=image.size
31
- )
32
- output_image = draw_ocr_bboxes(image, detections)
33
-
34
- # Return the output image and cleaned OCR text
35
- return output_image, cleaned_text