swarmauri_ocr_pytesseract 0.9.4.dev3__tar.gz → 0.11.0.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_ocr_pytesseract
3
+ Version: 0.11.0.dev1
4
+ Summary: Local Tesseract OCR adapter for Swarmauri with sync, async, and batch image-to-text workflows.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,ocr,pytesseract,tesseract,image,text,image to text,optical character recognition,document processing,text extraction,async ocr,batch ocr
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.15
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Multimedia :: Graphics
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Text Processing
22
+ Classifier: Programming Language :: Python
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3 :: Only
25
+ Classifier: Programming Language :: Python :: 3.10
26
+ Classifier: Programming Language :: Python :: 3.11
27
+ Classifier: Programming Language :: Python :: 3.12
28
+ Classifier: Programming Language :: Python :: 3.13
29
+ Classifier: Programming Language :: Python :: 3.14
30
+ Requires-Dist: pytesseract (>=0.3.13)
31
+ Requires-Dist: swarmauri_base
32
+ Requires-Dist: swarmauri_core
33
+ Requires-Dist: swarmauri_standard
34
+ Description-Content-Type: text/markdown
35
+
36
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
37
+
38
+ <p align="center">
39
+ <a href="https://pepy.tech/project/swarmauri_ocr_pytesseract/">
40
+ <img src="https://static.pepy.tech/badge/swarmauri_ocr_pytesseract/month" alt="PyPI - Downloads"/></a>
41
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract/">
42
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract.svg"/></a>
43
+ <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
44
+ <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
45
+ <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
46
+ <img src="https://img.shields.io/pypi/l/swarmauri_ocr_pytesseract" alt="PyPI - License"/></a>
47
+ <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
48
+ <img src="https://img.shields.io/pypi/v/swarmauri_ocr_pytesseract?label=swarmauri_ocr_pytesseract&color=green" alt="PyPI - swarmauri_ocr_pytesseract"/></a>
49
+ <a href="https://discord.gg/N4UpBuQv8T">
50
+ <img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
51
+
52
+ # Swarmauri OCR Pytesseract
53
+
54
+ `swarmauri_ocr_pytesseract` is the Swarmauri OCR adapter for running local
55
+ Tesseract-powered image-to-text extraction through a consistent Swarmauri
56
+ `OCRBase` interface. It accepts file paths, raw bytes, or in-memory PIL images
57
+ and supports synchronous, asynchronous, and batch OCR workflows.
58
+
59
+ ## Why Use Swarmauri OCR Pytesseract
60
+
61
+ - Use the same OCR component shape across local and pipeline-based Swarmauri
62
+ workflows.
63
+ - Run OCR on local infrastructure without routing images through a hosted API.
64
+ - Tune Tesseract language selection and engine flags for receipts, forms,
65
+ scanned PDFs, screenshots, and other document images.
66
+ - Reuse the same component in parsing, ingestion, indexing, and agent
67
+ workflows.
68
+
69
+ ## FAQ
70
+
71
+ > **What does this package do?**
72
+ > It wraps PyTesseract and the local Tesseract binary behind Swarmauri's OCR
73
+ > component interface.
74
+
75
+ > **Does it require a hosted API key?**
76
+ > No. It runs locally, but the host must have the `tesseract` executable and
77
+ > any required language packs installed.
78
+
79
+ > **What image inputs are supported?**
80
+ > File path strings, raw image bytes, and `PIL.Image.Image` instances.
81
+
82
+ > **Can it process multiple images concurrently?**
83
+ > Yes. Use `batch()` for synchronous lists and `abatch()` for async execution
84
+ > with a concurrency limit.
85
+
86
+ ## Features
87
+
88
+ - Local OCR backed by [PyTesseract](https://pypi.org/project/pytesseract/) and
89
+ [Tesseract OCR](https://tesseract-ocr.github.io/).
90
+ - Supports configurable `language`, `config`, and explicit `tesseract_cmd`
91
+ resolution.
92
+ - Accepts paths, bytes, and PIL image objects.
93
+ - Includes `extract_text`, `aextract_text`, `batch`, and `abatch` methods.
94
+ - Can report installed OCR languages through `get_supported_languages()`.
95
+ - Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
96
+
97
+ ## Installation
98
+
99
+ ```bash
100
+ uv add swarmauri_ocr_pytesseract
101
+ ```
102
+
103
+ ```bash
104
+ pip install swarmauri_ocr_pytesseract
105
+ ```
106
+
107
+ System requirement:
108
+
109
+ - Install the native `tesseract` binary and ensure it is available on `PATH`,
110
+ or set `TESSERACT_CMD` to the executable location.
111
+
112
+ ## Usage
113
+
114
+ ```python
115
+ from swarmauri_ocr_pytesseract import PytesseractOCR
116
+
117
+ ocr = PytesseractOCR(language="eng", config="--psm 6")
118
+ text = ocr.extract_text("docs/invoice.png")
119
+ print(text)
120
+ ```
121
+
122
+ ## Examples
123
+
124
+ ### OCR from image bytes
125
+
126
+ ```python
127
+ from pathlib import Path
128
+ from swarmauri_ocr_pytesseract import PytesseractOCR
129
+
130
+ ocr = PytesseractOCR(language="eng")
131
+ image_bytes = Path("receipts/ticket.png").read_bytes()
132
+ text = ocr.extract_text(image_bytes)
133
+ print(text)
134
+ ```
135
+
136
+ ### OCR from a PIL image
137
+
138
+ ```python
139
+ from PIL import Image
140
+ from swarmauri_ocr_pytesseract import PytesseractOCR
141
+
142
+ image = Image.open("scans/form.png")
143
+ ocr = PytesseractOCR(language="eng", config="--oem 3 --psm 4")
144
+ print(ocr.extract_text(image))
145
+ ```
146
+
147
+ ### Async batch OCR
148
+
149
+ ```python
150
+ import asyncio
151
+ from swarmauri_ocr_pytesseract import PytesseractOCR
152
+
153
+ ocr = PytesseractOCR(language="eng")
154
+
155
+ async def run():
156
+ results = await ocr.abatch(
157
+ ["scans/page1.png", "scans/page2.png", "scans/page3.png"],
158
+ max_concurrent=2,
159
+ )
160
+ for index, text in enumerate(results, start=1):
161
+ print(index, text[:120])
162
+
163
+ asyncio.run(run())
164
+ ```
165
+
166
+ ### List installed OCR languages
167
+
168
+ ```python
169
+ from swarmauri_ocr_pytesseract import PytesseractOCR
170
+
171
+ ocr = PytesseractOCR()
172
+ print(ocr.get_supported_languages())
173
+ ```
174
+
175
+ ## Related Packages
176
+
177
+ - [swarmauri_parser_fitzpdf](https://pypi.org/project/swarmauri_parser_fitzpdf/)
178
+ - [swarmauri_parser_pypdf2](https://pypi.org/project/swarmauri_parser_pypdf2/)
179
+ - [swarmauri_parser_pypdftk](https://pypi.org/project/swarmauri_parser_pypdftk/)
180
+ - [swarmauri_ocr_pytesseract](https://pypi.org/project/swarmauri_ocr_pytesseract/)
181
+
182
+ ## Swarmauri Foundations
183
+
184
+ - [swarmauri](https://pypi.org/project/swarmauri/)
185
+ - [swarmauri_core](https://pypi.org/project/swarmauri_core/)
186
+ - [swarmauri_base](https://pypi.org/project/swarmauri_base/)
187
+ - [swarmauri_standard](https://pypi.org/project/swarmauri_standard/)
188
+
189
+ ## More Documentation
190
+
191
+ - [Tesseract OCR documentation](https://tesseract-ocr.github.io/)
192
+ - [PyTesseract on PyPI](https://pypi.org/project/pytesseract/)
193
+ - [Pillow documentation](https://pillow.readthedocs.io/)
194
+
195
+ ## Best Practices
196
+
197
+ - Use `--psm` and `--oem` options through `config` to match the page layout you
198
+ expect.
199
+ - Install the correct `.traineddata` language packs for multilingual OCR.
200
+ - Pre-process noisy or skewed scans before OCR to improve extraction quality.
201
+ - Use PDF parsers when a PDF already contains embedded text; use OCR when the
202
+ PDF or image is scan-only.
203
+
204
+ ## License
205
+
206
+ This project is licensed under the Apache-2.0 License.
207
+
208
+
209
+
@@ -0,0 +1,173 @@
1
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
2
+
3
+ <p align="center">
4
+ <a href="https://pepy.tech/project/swarmauri_ocr_pytesseract/">
5
+ <img src="https://static.pepy.tech/badge/swarmauri_ocr_pytesseract/month" alt="PyPI - Downloads"/></a>
6
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract/">
7
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract.svg"/></a>
8
+ <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
9
+ <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
10
+ <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
11
+ <img src="https://img.shields.io/pypi/l/swarmauri_ocr_pytesseract" alt="PyPI - License"/></a>
12
+ <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
13
+ <img src="https://img.shields.io/pypi/v/swarmauri_ocr_pytesseract?label=swarmauri_ocr_pytesseract&color=green" alt="PyPI - swarmauri_ocr_pytesseract"/></a>
14
+ <a href="https://discord.gg/N4UpBuQv8T">
15
+ <img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
16
+
17
+ # Swarmauri OCR Pytesseract
18
+
19
+ `swarmauri_ocr_pytesseract` is the Swarmauri OCR adapter for running local
20
+ Tesseract-powered image-to-text extraction through a consistent Swarmauri
21
+ `OCRBase` interface. It accepts file paths, raw bytes, or in-memory PIL images
22
+ and supports synchronous, asynchronous, and batch OCR workflows.
23
+
24
+ ## Why Use Swarmauri OCR Pytesseract
25
+
26
+ - Use the same OCR component shape across local and pipeline-based Swarmauri
27
+ workflows.
28
+ - Run OCR on local infrastructure without routing images through a hosted API.
29
+ - Tune Tesseract language selection and engine flags for receipts, forms,
30
+ scanned PDFs, screenshots, and other document images.
31
+ - Reuse the same component in parsing, ingestion, indexing, and agent
32
+ workflows.
33
+
34
+ ## FAQ
35
+
36
+ > **What does this package do?**
37
+ > It wraps PyTesseract and the local Tesseract binary behind Swarmauri's OCR
38
+ > component interface.
39
+
40
+ > **Does it require a hosted API key?**
41
+ > No. It runs locally, but the host must have the `tesseract` executable and
42
+ > any required language packs installed.
43
+
44
+ > **What image inputs are supported?**
45
+ > File path strings, raw image bytes, and `PIL.Image.Image` instances.
46
+
47
+ > **Can it process multiple images concurrently?**
48
+ > Yes. Use `batch()` for synchronous lists and `abatch()` for async execution
49
+ > with a concurrency limit.
50
+
51
+ ## Features
52
+
53
+ - Local OCR backed by [PyTesseract](https://pypi.org/project/pytesseract/) and
54
+ [Tesseract OCR](https://tesseract-ocr.github.io/).
55
+ - Supports configurable `language`, `config`, and explicit `tesseract_cmd`
56
+ resolution.
57
+ - Accepts paths, bytes, and PIL image objects.
58
+ - Includes `extract_text`, `aextract_text`, `batch`, and `abatch` methods.
59
+ - Can report installed OCR languages through `get_supported_languages()`.
60
+ - Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ uv add swarmauri_ocr_pytesseract
66
+ ```
67
+
68
+ ```bash
69
+ pip install swarmauri_ocr_pytesseract
70
+ ```
71
+
72
+ System requirement:
73
+
74
+ - Install the native `tesseract` binary and ensure it is available on `PATH`,
75
+ or set `TESSERACT_CMD` to the executable location.
76
+
77
+ ## Usage
78
+
79
+ ```python
80
+ from swarmauri_ocr_pytesseract import PytesseractOCR
81
+
82
+ ocr = PytesseractOCR(language="eng", config="--psm 6")
83
+ text = ocr.extract_text("docs/invoice.png")
84
+ print(text)
85
+ ```
86
+
87
+ ## Examples
88
+
89
+ ### OCR from image bytes
90
+
91
+ ```python
92
+ from pathlib import Path
93
+ from swarmauri_ocr_pytesseract import PytesseractOCR
94
+
95
+ ocr = PytesseractOCR(language="eng")
96
+ image_bytes = Path("receipts/ticket.png").read_bytes()
97
+ text = ocr.extract_text(image_bytes)
98
+ print(text)
99
+ ```
100
+
101
+ ### OCR from a PIL image
102
+
103
+ ```python
104
+ from PIL import Image
105
+ from swarmauri_ocr_pytesseract import PytesseractOCR
106
+
107
+ image = Image.open("scans/form.png")
108
+ ocr = PytesseractOCR(language="eng", config="--oem 3 --psm 4")
109
+ print(ocr.extract_text(image))
110
+ ```
111
+
112
+ ### Async batch OCR
113
+
114
+ ```python
115
+ import asyncio
116
+ from swarmauri_ocr_pytesseract import PytesseractOCR
117
+
118
+ ocr = PytesseractOCR(language="eng")
119
+
120
+ async def run():
121
+ results = await ocr.abatch(
122
+ ["scans/page1.png", "scans/page2.png", "scans/page3.png"],
123
+ max_concurrent=2,
124
+ )
125
+ for index, text in enumerate(results, start=1):
126
+ print(index, text[:120])
127
+
128
+ asyncio.run(run())
129
+ ```
130
+
131
+ ### List installed OCR languages
132
+
133
+ ```python
134
+ from swarmauri_ocr_pytesseract import PytesseractOCR
135
+
136
+ ocr = PytesseractOCR()
137
+ print(ocr.get_supported_languages())
138
+ ```
139
+
140
+ ## Related Packages
141
+
142
+ - [swarmauri_parser_fitzpdf](https://pypi.org/project/swarmauri_parser_fitzpdf/)
143
+ - [swarmauri_parser_pypdf2](https://pypi.org/project/swarmauri_parser_pypdf2/)
144
+ - [swarmauri_parser_pypdftk](https://pypi.org/project/swarmauri_parser_pypdftk/)
145
+ - [swarmauri_ocr_pytesseract](https://pypi.org/project/swarmauri_ocr_pytesseract/)
146
+
147
+ ## Swarmauri Foundations
148
+
149
+ - [swarmauri](https://pypi.org/project/swarmauri/)
150
+ - [swarmauri_core](https://pypi.org/project/swarmauri_core/)
151
+ - [swarmauri_base](https://pypi.org/project/swarmauri_base/)
152
+ - [swarmauri_standard](https://pypi.org/project/swarmauri_standard/)
153
+
154
+ ## More Documentation
155
+
156
+ - [Tesseract OCR documentation](https://tesseract-ocr.github.io/)
157
+ - [PyTesseract on PyPI](https://pypi.org/project/pytesseract/)
158
+ - [Pillow documentation](https://pillow.readthedocs.io/)
159
+
160
+ ## Best Practices
161
+
162
+ - Use `--psm` and `--oem` options through `config` to match the page layout you
163
+ expect.
164
+ - Install the correct `.traineddata` language packs for multilingual OCR.
165
+ - Pre-process noisy or skewed scans before OCR to improve extraction quality.
166
+ - Use PDF parsers when a PDF already contains embedded text; use OCR when the
167
+ PDF or image is scan-only.
168
+
169
+ ## License
170
+
171
+ This project is licensed under the Apache-2.0 License.
172
+
173
+
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "swarmauri_ocr_pytesseract"
3
- version = "0.9.4.dev3"
4
- description = "Swarmauri Tesseract Image to Text Model"
3
+ version = "0.11.0.dev1"
4
+ description = "Local Tesseract OCR adapter for Swarmauri with sync, async, and batch image-to-text workflows."
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
7
7
  repository = "http://github.com/swarmauri/swarmauri-sdk"
@@ -11,7 +11,13 @@ classifiers = [
11
11
  "Natural Language :: English",
12
12
  "Development Status :: 3 - Alpha",
13
13
  "Intended Audience :: Developers",
14
+ "Intended Audience :: Science/Research",
15
+ "Operating System :: OS Independent",
16
+ "Topic :: Multimedia :: Graphics",
17
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
14
18
  "Topic :: Software Development :: Libraries :: Application Frameworks",
19
+ "Topic :: Software Development :: Libraries",
20
+ "Topic :: Text Processing",
15
21
  "Programming Language :: Python",
16
22
  "Programming Language :: Python :: 3",
17
23
  "Programming Language :: Python :: 3 :: Only",
@@ -30,7 +36,12 @@ keywords = [
30
36
  "tesseract",
31
37
  "image",
32
38
  "text",
33
- "model",
39
+ "image to text",
40
+ "optical character recognition",
41
+ "document processing",
42
+ "text extraction",
43
+ "async ocr",
44
+ "batch ocr",
34
45
  ]
35
46
 
36
47
  [tool.uv.sources]
@@ -71,7 +82,7 @@ dev = [
71
82
  "pytest-xdist>=3.6.1",
72
83
  "pytest-json-report>=1.5.0",
73
84
  "python-dotenv",
74
- "requests>=2.32.3",
85
+ "httpx>=0.27",
75
86
  "flake8>=7.0",
76
87
  "pytest-timeout>=2.3.1",
77
88
  "ruff>=0.9.9",
@@ -12,7 +12,8 @@ from swarmauri_base.ocrs.OCRBase import OCRBase
12
12
  @ComponentBase.register_type(OCRBase, "PytesseractOCR")
13
13
  class PytesseractOCR(OCRBase):
14
14
  """
15
- A model for performing OCR (Optical Character Recognition) using Pytesseract.
15
+ A model for performing OCR (Optical Character Recognition) using
16
+ Pytesseract.
16
17
  It can process both local images and image bytes, returning extracted text.
17
18
  Requires Tesseract-OCR to be installed on the system.
18
19
  """
@@ -20,7 +21,11 @@ class PytesseractOCR(OCRBase):
20
21
  tesseract_cmd: str = Field(
21
22
  default_factory=lambda: os.environ.get(
22
23
  "TESSERACT_CMD",
23
- ("/usr/bin/tesseract" if os.path.exists("/usr/bin/tesseract") else None),
24
+ (
25
+ "/usr/bin/tesseract"
26
+ if os.path.exists("/usr/bin/tesseract")
27
+ else None
28
+ ),
24
29
  )
25
30
  )
26
31
  type: Literal["PytesseractOCR"] = "PytesseractOCR"
@@ -32,7 +37,9 @@ class PytesseractOCR(OCRBase):
32
37
  super().__init__(**data)
33
38
  pytesseract.pytesseract.tesseract_cmd = self.tesseract_cmd
34
39
 
35
- def _process_image(self, image: Union[str, bytes, Image.Image], **kwargs) -> str:
40
+ def _process_image(
41
+ self, image: Union[str, bytes, Image.Image], **kwargs
42
+ ) -> str:
36
43
  """Process an image and return extracted text."""
37
44
  try:
38
45
  # Handle different input types
@@ -52,14 +59,18 @@ class PytesseractOCR(OCRBase):
52
59
  custom_config = kwargs.get("config", self.config)
53
60
  lang = kwargs.get("language", self.language)
54
61
 
55
- text = pytesseract.image_to_string(img, lang=lang, config=custom_config)
62
+ text = pytesseract.image_to_string(
63
+ img, lang=lang, config=custom_config
64
+ )
56
65
 
57
66
  return text.strip()
58
67
 
59
68
  except Exception as e:
60
69
  raise Exception(f"OCR processing failed: {str(e)}")
61
70
 
62
- def extract_text(self, image: Union[str, bytes, Image.Image], **kwargs) -> str:
71
+ def extract_text(
72
+ self, image: Union[str, bytes, Image.Image], **kwargs
73
+ ) -> str:
63
74
  """
64
75
  Extracts text from an image.
65
76
 
@@ -81,7 +92,9 @@ class PytesseractOCR(OCRBase):
81
92
  Asynchronously extracts text from an image.
82
93
  """
83
94
  loop = asyncio.get_event_loop()
84
- return await loop.run_in_executor(None, self.extract_text, image, **kwargs)
95
+ return await loop.run_in_executor(
96
+ None, self.extract_text, image, **kwargs
97
+ )
85
98
 
86
99
  def batch(
87
100
  self, images: List[Union[str, bytes, Image.Image]], **kwargs
@@ -130,13 +143,15 @@ class PytesseractOCR(OCRBase):
130
143
 
131
144
  def get_supported_languages(self) -> List[str]:
132
145
  """
133
- Returns a list of supported languages by executing 'tesseract --list-langs' command.
146
+ Returns a list of supported languages by executing 'tesseract
147
+ --list-langs' command.
134
148
 
135
149
  Returns:
136
150
  List[str]: List of available language codes (e.g., ['eng', 'osd'])
137
151
 
138
152
  Raises:
139
- Exception: If the command execution fails or returns unexpected output
153
+ Exception: If the command execution fails or returns unexpected
154
+ output
140
155
  """
141
156
  try:
142
157
  # Execute tesseract command to list languages
@@ -154,11 +169,15 @@ class PytesseractOCR(OCRBase):
154
169
 
155
170
  # Skip the first line which is the directory info
156
171
  # and filter out empty lines
157
- languages = [lang.strip() for lang in output_lines[1:] if lang.strip()]
172
+ languages = [
173
+ lang.strip() for lang in output_lines[1:] if lang.strip()
174
+ ]
158
175
 
159
176
  return languages
160
177
 
161
178
  except subprocess.CalledProcessError as e:
162
- raise Exception(f"Failed to get language list from Tesseract: {e.stderr}")
179
+ raise Exception(
180
+ f"Failed to get language list from Tesseract: {e.stderr}"
181
+ )
163
182
  except Exception as e:
164
183
  raise Exception(f"Error getting supported languages: {str(e)}")
@@ -1,137 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: swarmauri_ocr_pytesseract
3
- Version: 0.9.4.dev3
4
- Summary: Swarmauri Tesseract Image to Text Model
5
- License-Expression: Apache-2.0
6
- License-File: LICENSE
7
- Keywords: swarmauri,ocr,pytesseract,tesseract,image,text,model
8
- Author: Jacob Stewart
9
- Author-email: jacob@swarmauri.com
10
- Requires-Python: >=3.10,<3.15
11
- Classifier: License :: OSI Approved :: Apache Software License
12
- Classifier: Natural Language :: English
13
- Classifier: Development Status :: 3 - Alpha
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
16
- Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3 :: Only
19
- Classifier: Programming Language :: Python :: 3.10
20
- Classifier: Programming Language :: Python :: 3.11
21
- Classifier: Programming Language :: Python :: 3.12
22
- Classifier: Programming Language :: Python :: 3.13
23
- Classifier: Programming Language :: Python :: 3.14
24
- Requires-Dist: pytesseract (>=0.3.13)
25
- Requires-Dist: swarmauri_base
26
- Requires-Dist: swarmauri_core
27
- Requires-Dist: swarmauri_standard
28
- Description-Content-Type: text/markdown
29
-
30
- ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
31
-
32
- <p align="center">
33
- <a href="https://pepy.tech/project/swarmauri_ocr_pytesseract/">
34
- <img src="https://static.pepy.tech/badge/swarmauri_ocr_pytesseract/month" alt="PyPI - Downloads"/></a>
35
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract/">
36
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract.svg"/></a>
37
- <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
38
- <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
39
- <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
40
- <img src="https://img.shields.io/pypi/l/swarmauri_ocr_pytesseract" alt="PyPI - License"/></a>
41
- <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
42
- <img src="https://img.shields.io/pypi/v/swarmauri_ocr_pytesseract?label=swarmauri_ocr_pytesseract&color=green" alt="PyPI - swarmauri_ocr_pytesseract"/></a>
43
- </p>
44
-
45
- # Swarmauri OCR Pytesseract
46
-
47
- OCR adapter for Swarmauri built on top of [PyTesseract](https://pypi.org/project/pytesseract/). Accepts paths, bytes, or PIL images, and exposes synchronous, async, and batch APIs for extracting text.
48
-
49
- ## Features
50
-
51
- - Wraps Tesseract OCR via PyTesseract behind Swarmauri's `OCRBase` interface.
52
- - Supports multiple languages (`language` parameter) and custom Tesseract configs.
53
- - Handles individual, async, and batched OCR calls with optional concurrency limits.
54
- - Helper to list installed Tesseract languages through `get_supported_languages()`.
55
-
56
- ## Prerequisites
57
-
58
- - Python 3.10 or newer.
59
- - [Tesseract OCR](https://github.com/tesseract-ocr/tesseract) installed on the host (`tesseract` binary reachable on `PATH` or via `TESSERACT_CMD`).
60
- - `pytesseract`, `Pillow`, and related dependencies (installed automatically with this package).
61
-
62
- ## Installation
63
-
64
- ```bash
65
- # pip
66
- pip install swarmauri_ocr_pytesseract
67
-
68
- # poetry
69
- poetry add swarmauri_ocr_pytesseract
70
-
71
- # uv (pyproject-based projects)
72
- uv add swarmauri_ocr_pytesseract
73
- ```
74
-
75
- ## Quickstart
76
-
77
- ```python
78
- from swarmauri_ocr_pytesseract import PytesseractOCR
79
-
80
- ocr = PytesseractOCR(language="eng")
81
- text = ocr.extract_text("docs/invoice.png")
82
- print(text)
83
- ```
84
-
85
- ## Processing Image Bytes
86
-
87
- ```python
88
- from pathlib import Path
89
- from swarmauri_ocr_pytesseract import PytesseractOCR
90
-
91
- png_bytes = Path("receipts/ticket.png").read_bytes()
92
- ocr = PytesseractOCR(language="eng", config="--psm 6")
93
- print(ocr.extract_text(png_bytes))
94
- ```
95
-
96
- ## Async and Batch APIs
97
-
98
- ```python
99
- import asyncio
100
- from swarmauri_ocr_pytesseract import PytesseractOCR
101
-
102
- ocr = PytesseractOCR(language="fra")
103
-
104
- async def run_async():
105
- text = await ocr.aextract_text("scans/document_fr.png")
106
- print(text)
107
-
108
- texts = await ocr.abatch([
109
- "scans/page1.png",
110
- "scans/page2.png",
111
- ], max_concurrent=2)
112
- for page, content in enumerate(texts, start=1):
113
- print(f"Page {page}: {content[:80]}")
114
-
115
- # asyncio.run(run_async())
116
- ```
117
-
118
- ## List Available Languages
119
-
120
- ```python
121
- from swarmauri_ocr_pytesseract import PytesseractOCR
122
-
123
- ocr = PytesseractOCR()
124
- print(ocr.get_supported_languages())
125
- ```
126
-
127
- ## Tips
128
-
129
- - Set `TESSERACT_CMD` if the binary lives outside standard locations (e.g., Windows installs).
130
- - Use appropriate page segmentation modes (`--psm`) and OCR engine modes (`--oem`) through the `config` parameter to improve quality.
131
- - Pre-process images (grayscale, thresholding) before passing them to the OCR for better accuracy.
132
- - When running in containers, ensure Tesseract language packs (`.traineddata`) are installed for the languages you plan to use.
133
-
134
- ## Want to help?
135
-
136
- If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
137
-
@@ -1,107 +0,0 @@
1
- ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
2
-
3
- <p align="center">
4
- <a href="https://pepy.tech/project/swarmauri_ocr_pytesseract/">
5
- <img src="https://static.pepy.tech/badge/swarmauri_ocr_pytesseract/month" alt="PyPI - Downloads"/></a>
6
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract/">
7
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_ocr_pytesseract.svg"/></a>
8
- <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
9
- <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
10
- <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
11
- <img src="https://img.shields.io/pypi/l/swarmauri_ocr_pytesseract" alt="PyPI - License"/></a>
12
- <a href="https://pypi.org/project/swarmauri_ocr_pytesseract/">
13
- <img src="https://img.shields.io/pypi/v/swarmauri_ocr_pytesseract?label=swarmauri_ocr_pytesseract&color=green" alt="PyPI - swarmauri_ocr_pytesseract"/></a>
14
- </p>
15
-
16
- # Swarmauri OCR Pytesseract
17
-
18
- OCR adapter for Swarmauri built on top of [PyTesseract](https://pypi.org/project/pytesseract/). Accepts paths, bytes, or PIL images, and exposes synchronous, async, and batch APIs for extracting text.
19
-
20
- ## Features
21
-
22
- - Wraps Tesseract OCR via PyTesseract behind Swarmauri's `OCRBase` interface.
23
- - Supports multiple languages (`language` parameter) and custom Tesseract configs.
24
- - Handles individual, async, and batched OCR calls with optional concurrency limits.
25
- - Helper to list installed Tesseract languages through `get_supported_languages()`.
26
-
27
- ## Prerequisites
28
-
29
- - Python 3.10 or newer.
30
- - [Tesseract OCR](https://github.com/tesseract-ocr/tesseract) installed on the host (`tesseract` binary reachable on `PATH` or via `TESSERACT_CMD`).
31
- - `pytesseract`, `Pillow`, and related dependencies (installed automatically with this package).
32
-
33
- ## Installation
34
-
35
- ```bash
36
- # pip
37
- pip install swarmauri_ocr_pytesseract
38
-
39
- # poetry
40
- poetry add swarmauri_ocr_pytesseract
41
-
42
- # uv (pyproject-based projects)
43
- uv add swarmauri_ocr_pytesseract
44
- ```
45
-
46
- ## Quickstart
47
-
48
- ```python
49
- from swarmauri_ocr_pytesseract import PytesseractOCR
50
-
51
- ocr = PytesseractOCR(language="eng")
52
- text = ocr.extract_text("docs/invoice.png")
53
- print(text)
54
- ```
55
-
56
- ## Processing Image Bytes
57
-
58
- ```python
59
- from pathlib import Path
60
- from swarmauri_ocr_pytesseract import PytesseractOCR
61
-
62
- png_bytes = Path("receipts/ticket.png").read_bytes()
63
- ocr = PytesseractOCR(language="eng", config="--psm 6")
64
- print(ocr.extract_text(png_bytes))
65
- ```
66
-
67
- ## Async and Batch APIs
68
-
69
- ```python
70
- import asyncio
71
- from swarmauri_ocr_pytesseract import PytesseractOCR
72
-
73
- ocr = PytesseractOCR(language="fra")
74
-
75
- async def run_async():
76
- text = await ocr.aextract_text("scans/document_fr.png")
77
- print(text)
78
-
79
- texts = await ocr.abatch([
80
- "scans/page1.png",
81
- "scans/page2.png",
82
- ], max_concurrent=2)
83
- for page, content in enumerate(texts, start=1):
84
- print(f"Page {page}: {content[:80]}")
85
-
86
- # asyncio.run(run_async())
87
- ```
88
-
89
- ## List Available Languages
90
-
91
- ```python
92
- from swarmauri_ocr_pytesseract import PytesseractOCR
93
-
94
- ocr = PytesseractOCR()
95
- print(ocr.get_supported_languages())
96
- ```
97
-
98
- ## Tips
99
-
100
- - Set `TESSERACT_CMD` if the binary lives outside standard locations (e.g., Windows installs).
101
- - Use appropriate page segmentation modes (`--psm`) and OCR engine modes (`--oem`) through the `config` parameter to improve quality.
102
- - Pre-process images (grayscale, thresholding) before passing them to the OCR for better accuracy.
103
- - When running in containers, ensure Tesseract language packs (`.traineddata`) are installed for the languages you plan to use.
104
-
105
- ## Want to help?
106
-
107
- If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.