For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
EnterpriseQuick Start
API ReferenceTutorials
  • Tutorials
    • Create a Project
    • Import Tasks
    • Assign Users to Tasks
    • Manage Labeling Jobs
    • Add Model Predictions
    • Export and Convert Snapshots
    • Logging ML Server Predictions
    • Evaluate LLM Responses
    • Improve Object Detection with YOLO
    • Interactive OCR with Tesseract
LogoLogo
EnterpriseQuick Start
On this page
  • Create Interactive Model
  • Connect to Label Studio
  • Create a project
  • Connect OCR Model to Project
Tutorials

Interactive OCR with Tesseract

Was this page helpful?
Previous
Built with

Label Studio can be used to interactively work with OCR (Optical Character Recognition) models like Tesseract.

Create Interactive Model

You can use Label Studio ML Backend to start an interactive OCR model:

  1. Download git clone https://github.com/HumanSignal/label-studio-ml-backend.git
  2. Go to label_studio_ml/examples/tesseract
  3. Run docker-compose up

It will start the server listening on http://localhost:9090.

Connect to Label Studio

For information on finding your base URL and API key, see Authenticate and Connect to the API.

1LABEL_STUDIO_URL = 'YOUR_BASE_URL'
2LABEL_STUDIO_API_KEY = 'YOUR_API_KEY'
3
4from label_studio_sdk import LabelStudio
5
6client = LabelStudio(base_url=LABEL_STUDIO_URL, api_key=LABEL_STUDIO_API_KEY)

Create a project

To create a project, you need to specify the label_config that defines the labeling interface and the labels ontology.

1project = client.projects.create(
2 title='Live OCR',
3 description='A project to demonstrate live OCR with connected Tesseract model',
4 label_config='''
5 <View>
6 <Image name="image" value="$ocr"/>
7
8 <Labels name="label" toName="image">
9 <Label value="Text" background="green"/>
10 <Label value="Handwriting" background="blue"/>
11 </Labels>
12
13 <Rectangle name="bbox" toName="image" strokeWidth="3"/>
14
15 <TextArea name="transcription" toName="image"
16 editable="true"
17 perRegion="true"
18 required="true"
19 maxSubmissions="1"
20 rows="5"
21 placeholder="Recognized Text"
22 displayMode="region-list"
23 />
24 </View>'''
25)

Connect OCR Model to Project

To connect your running OCR model to the project, you need to specify the model URL and the project ID:

1client.ml.create(
2 title='Tesseract OCR',
3 description='A model to perform OCR using Tesseract',
4 url='http://localhost:9090', # if LS runs in Docker, prefer http://host.docker.internal:9090
5 project=project.id,
6 is_interactive=True
7)

Also see this example notebook.