Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,12 +4,28 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
@tool
|
| 15 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from tools.ocr import ocr_tool
|
| 8 |
+
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 13 |
|
| 14 |
|
| 15 |
+
@tool
|
| 16 |
+
def ocr_tool(image_path: str) -> str:
|
| 17 |
+
"""Extracts text from images or scanned documents using OCR.
|
| 18 |
+
Args:
|
| 19 |
+
image_path: Path to the image file
|
| 20 |
+
"""
|
| 21 |
+
try:
|
| 22 |
+
ocr_engine = PaddleOCR(use_angle_cls=True, lang='en')
|
| 23 |
+
result = ocr_engine.ocr(image_path, cls=True)
|
| 24 |
+
texts = [line[1][0] for line in result[0]] if result else []
|
| 25 |
+
return "\n".join(texts)
|
| 26 |
+
except Exception as e:
|
| 27 |
+
return f"OCR Error: {str(e)}"
|
| 28 |
+
|
| 29 |
|
| 30 |
@tool
|
| 31 |
def get_current_time_in_timezone(timezone: str) -> str:
|