mrpe24's picture
implemented agent with tools
d75dae7
raw
history blame contribute delete
718 Bytes
from smolagents import Tool
import easyocr
class ImageTextExtractorTool(Tool):
name = "image_text_extractor"
description = """
Multilingual OCR tool to extract key information or presented text from any image.
Supported image extensions: .png, .jpg, .jpeg, .bmp, .svg.
"""
inputs = {
"image_path": {
"type": "string",
"description": "The path to the image file",
}
}
output_type = "array"
def __init__(self):
super().__init__()
self.reader = easyocr.Reader(['ch_sim', 'en'])
def forward(self, image_path: str) -> list[str]:
result = self.reader.readtext(image_path, detail=False)
return result