OCR Tool
OCR Tool
OCRTool은 비전(vision)을 갖춘 LLM을 사용해 로컬 이미지 또는 이미지 URL에서 텍스트를 추출하는 도구예요.
출처: 문서
본문
OCRTool
설명 (Description)
이미지(로컬 경로 또는 URL)에서 텍스트를 추출합니다. CrewAI의 LLM 인터페이스를 통해 비전(vision) 기능이 있는 LLM을 사용합니다.
설치 (Installation)
crewai-tools 외에 추가 설치는 필요하지 않습니다. 선택한 LLM이 비전을 지원하는지 확인하세요.
매개변수 (Parameters)
실행 매개변수 (Run Parameters)
image_path_url(str, required): 로컬 이미지 경로 또는 HTTP(S) URL입니다.
예시 (Examples)
직접 사용 (Direct usage)
from crewai_tools import OCRTool
print(OCRTool().run(image_path_url="/tmp/receipt.png"))
에이전트와 함께 사용 (With an agent)
from crewai import Agent, Task, Crew
from crewai_tools import OCRTool
ocr = OCRTool()
agent = Agent(
role="OCR",
goal="Extract text",
tools=[ocr],
)
task = Task(
description="Extract text from https://example.com/invoice.jpg",
expected_output="All detected text in plain text",
agent=agent,
)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()
참고 사항 (Notes)
- 선택한 LLM이 이미지 입력을 지원하는지 확인하세요.
- 큰 이미지의 경우 토큰 사용량을 줄이기 위해 크기를 줄이는 것을 고려하세요.
- 필요하다면 도구에 특정 LLM 인스턴스를 전달할 수 있습니다(예:
LLM(model="gpt-4o")). README 안내와 동일합니다.
예시 (Example)
from crewai import Agent, Task, Crew
from crewai_tools import OCRTool
tool = OCRTool()
agent = Agent(
role="OCR Specialist",
goal="Extract text from images",
backstory="Vision‑enabled analyst",
tools=[tool],
verbose=True,
)
task = Task(
description="Extract text from https://example.com/receipt.png",
expected_output="All detected text in plain text",
agent=agent,
)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()