File size: 2,739 Bytes
4bf3c80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

title = """# 🙋🏻‍♂️Welcome to Tonic's ImageEditor📸🫴🏻👁GOT-OCR Demo
---
"""

description = """
The **🫴🏻👁GOT-OCR model** is a cutting-edge OCR system with **580M parameters**, designed to process a wide range of "characters." Equipped with a **high-compression encoder** and a **long-context decoder**, it excels in both scene and document-style images. The model supports **multi-page** and **dynamic resolution OCR**, enhancing its versatility.

### Key Features

- **Plain Text OCR**: Extracts text from images.
- **Formatted Text OCR**: Retains the original formatting, including tables and formulas.
- **Fine-grained OCR**: Offers box-based and color-based OCR for precision in specific regions.
- **Multi-crop OCR**: Handles multiple cropped sections within an image.

## Supported Content Types

- Plain text
- Math/molecular formulas
- Tables and charts
- Sheet music
- Geometric shapes

"""
joinus = """
## Join us :

🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻 [![Join us on Discord](https://img.shields.io/discord/1109943800132010065?label=Discord&logo=discord&style=flat-square)](https://discord.gg/qdfnvSPcqP) On 🤗Huggingface:[MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [Build Tonic](https://git.tonic-ai.com/contribute)🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
"""
modelinfor = """
## How to Use

1. Select a task from the dropdown menu.
2. Upload an image.
3. Use Paintbrush to draw a circle around the text you want to OCR.
4. Click **Process** to view the results.

## Model Information

- **Model Name**: GOT-OCR 2.0
- **Hugging Face Repository**: [ucaslcl/GOT-OCR2_0](https://huggingface.co/ucaslcl/GOT-OCR2_0)
- **Environment**: CUDA 11.8 + PyTorch 2.0.1

"""

tasks = [
    "Plain Text OCR",
    "Format Text OCR",
    "Fine-grained OCR (Box)",
    "Fine-grained OCR (Color)",
    "Multi-crop OCR",
    "Render Formatted OCR"
]

ocr_types = ["ocr", "format"]
ocr_colors = ["red", "green", "blue"]

howto =         """
                ## To use Fine-grained OCR (Color):
                1. Click on 'Fine-grained OCR (Color)' in the task dropdown.
                2. Set 'OCR Type' to 'ocr'.
                3. This will display the image editor.
                4. Upload an image to the editor.
                5. Use the drawing tools to draw a circle around the text you want to OCR.
                6. Select the color that matches your circle in the 'OCR Color' dropdown.
                7. Click 'Process Edited Image' to run the OCR on the selected area.
                """