apple-ocr


Nameapple-ocr JSON
Version 1.0.8 PyPI version JSON
download
home_page
SummaryAn OCR (Optical Character Recognition) utility for text extraction from images.
upload_time2024-01-29 19:25:23
maintainer
docs_urlNone
author
requires_python
license
keywords ocr image-recognition text-extraction clustering apple vision nlp llm data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Easy-to-Use Apple Vision wrapper for text extraction and clustering
[![Python](https://img.shields.io/pypi/pyversions/tensorflow.svg)](https://badge.fury.io/py/tensorflow) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ![Maintainer](https://img.shields.io/badge/maintainer-@louisbrulenaudet-blue)

`apple_ocr` is a utility for Optical Character Recognition (OCR) that facilitates the extraction of text from images. This Python-based tool is designed to help developers, researchers, and enthusiasts in the field of text extraction and clustering. It leverages a combination of various technologies to achieve this, including the Vision framework provided by Apple.

![Plot](https://github.com/louisbrulenaudet/apple-ocr/blob/main/scatter.png?raw=true)

## Features
- **Text Recognition**: `apple_ocr` uses the Vision framework to recognize text within an image. It extracts recognized text and provides information about its confidence levels.

- **Clustering**: The tool can perform K-Means clustering on the extracted data. It groups similar text elements together based on their coordinates.

- **Interactive 3D Visualization**: `apple_ocr` offers an interactive 3D scatter plot using Plotly, displaying the clustered text elements. This visualization helps users gain insights into the distribution of text and text density.

## Dependencies
The script relies on the following Python libraries:
- Torch
- NumPy
- Pandas
- Pillow
- Scikit-learn
- Plotly
- Pyobjc

## Usage
Here's how you can use `apple_ocr`:

1. **Installation**: Install the required libraries, including `Torch`, `NumPy`, `Pandas`, `Pillow`, `scikit-learn`, and `Plotly`.

2. **Initialization**: Create an instance of the `OCR` class, providing an image to be processed.
```python
from apple_ocr.ocr import OCR
from PIL import Image

image = Image.open("your_image.png")
ocr_instance = OCR(image=image)
```

3. **Text Recognition**: Use the `recognize` method to perform text recognition. It will return a structured DataFrame containing recognized text, bounding box dimensions, text density, and centroid coordinates.
```python
dataframe = ocr_instance.recognize()
```

4. **Clustering**: Use the `cluster` method to perform K-Means clustering on the recognized text data. This method assigns cluster labels to each data point based on their coordinates.
```python
cluster_labels = ocr_instance.cluster(dataframe, num_clusters=3)
```

5. **Visualization**: Finally, use the `scatter` method to create an interactive 3D scatter plot. This plot visualizes the clustered text elements, including centroids, text density, and more.
```python
ocr_instance.scatter()
```

## Example
Here's an example of the entire process:

```python
from apple_ocr.ocr import OCR
from PIL import Image

image = Image open("your_image.png")
ocr_instance = OCR(image=image)
dataframe = ocr_instance.recognize()
cluster_labels = ocr_instance.cluster(dataframe, num_clusters=3)
ocr_instance.scatter()
```

## Citing this project
If you use this code in your research, please use the following BibTeX entry.

```BibTeX
@misc{louisbrulenaudet2023,
	author = {Louis Brulé Naudet},
	title = {Easy-to-Use Apple Vision wrapper for text extraction and clustering},
	howpublished = {\url{https://github.com/louisbrulenaudet/apple-ocr}},
	year = {2023}
}

```
## Feedback
If you have any feedback, please reach out at [louisbrulenaudet@icloud.com](mailto:louisbrulenaudet@icloud.com).

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "apple-ocr",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "OCR,image-recognition,text-extraction,clustering,Apple Vision,NLP,LLM,data",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/f2/43/bb901cd3b46019297058a49f3c087486d76ba8cc129f891299463dd4e70d/apple-ocr-1.0.8.tar.gz",
    "platform": null,
    "description": "# Easy-to-Use Apple Vision wrapper for text extraction and clustering\n[![Python](https://img.shields.io/pypi/pyversions/tensorflow.svg)](https://badge.fury.io/py/tensorflow) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ![Maintainer](https://img.shields.io/badge/maintainer-@louisbrulenaudet-blue)\n\n`apple_ocr` is a utility for Optical Character Recognition (OCR) that facilitates the extraction of text from images. This Python-based tool is designed to help developers, researchers, and enthusiasts in the field of text extraction and clustering. It leverages a combination of various technologies to achieve this, including the Vision framework provided by Apple.\n\n![Plot](https://github.com/louisbrulenaudet/apple-ocr/blob/main/scatter.png?raw=true)\n\n## Features\n- **Text Recognition**: `apple_ocr` uses the Vision framework to recognize text within an image. It extracts recognized text and provides information about its confidence levels.\n\n- **Clustering**: The tool can perform K-Means clustering on the extracted data. It groups similar text elements together based on their coordinates.\n\n- **Interactive 3D Visualization**: `apple_ocr` offers an interactive 3D scatter plot using Plotly, displaying the clustered text elements. This visualization helps users gain insights into the distribution of text and text density.\n\n## Dependencies\nThe script relies on the following Python libraries:\n- Torch\n- NumPy\n- Pandas\n- Pillow\n- Scikit-learn\n- Plotly\n- Pyobjc\n\n## Usage\nHere's how you can use `apple_ocr`:\n\n1. **Installation**: Install the required libraries, including `Torch`, `NumPy`, `Pandas`, `Pillow`, `scikit-learn`, and `Plotly`.\n\n2. **Initialization**: Create an instance of the `OCR` class, providing an image to be processed.\n```python\nfrom apple_ocr.ocr import OCR\nfrom PIL import Image\n\nimage = Image.open(\"your_image.png\")\nocr_instance = OCR(image=image)\n```\n\n3. **Text Recognition**: Use the `recognize` method to perform text recognition. It will return a structured DataFrame containing recognized text, bounding box dimensions, text density, and centroid coordinates.\n```python\ndataframe = ocr_instance.recognize()\n```\n\n4. **Clustering**: Use the `cluster` method to perform K-Means clustering on the recognized text data. This method assigns cluster labels to each data point based on their coordinates.\n```python\ncluster_labels = ocr_instance.cluster(dataframe, num_clusters=3)\n```\n\n5. **Visualization**: Finally, use the `scatter` method to create an interactive 3D scatter plot. This plot visualizes the clustered text elements, including centroids, text density, and more.\n```python\nocr_instance.scatter()\n```\n\n## Example\nHere's an example of the entire process:\n\n```python\nfrom apple_ocr.ocr import OCR\nfrom PIL import Image\n\nimage = Image open(\"your_image.png\")\nocr_instance = OCR(image=image)\ndataframe = ocr_instance.recognize()\ncluster_labels = ocr_instance.cluster(dataframe, num_clusters=3)\nocr_instance.scatter()\n```\n\n## Citing this project\nIf you use this code in your research, please use the following BibTeX entry.\n\n```BibTeX\n@misc{louisbrulenaudet2023,\n\tauthor = {Louis Brul\u00e9 Naudet},\n\ttitle = {Easy-to-Use Apple Vision wrapper for text extraction and clustering},\n\thowpublished = {\\url{https://github.com/louisbrulenaudet/apple-ocr}},\n\tyear = {2023}\n}\n\n```\n## Feedback\nIf you have any feedback, please reach out at [louisbrulenaudet@icloud.com](mailto:louisbrulenaudet@icloud.com).\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "An OCR (Optical Character Recognition) utility for text extraction from images.",
    "version": "1.0.8",
    "project_urls": null,
    "split_keywords": [
        "ocr",
        "image-recognition",
        "text-extraction",
        "clustering",
        "apple vision",
        "nlp",
        "llm",
        "data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3ba7872de2c0fe42ff79e7cc685cca80dd9905c751fd6f757fa2b4cf473be1e",
                "md5": "1a4e54a08f3fe45429c7fc96eb88228f",
                "sha256": "5026030e4e3f2bc8e997431c2cb7ef00eeca560d4c67a7a69ac94b7938ac1e74"
            },
            "downloads": -1,
            "filename": "apple_ocr-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1a4e54a08f3fe45429c7fc96eb88228f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9424,
            "upload_time": "2024-01-29T19:25:21",
            "upload_time_iso_8601": "2024-01-29T19:25:21.947712Z",
            "url": "https://files.pythonhosted.org/packages/b3/ba/7872de2c0fe42ff79e7cc685cca80dd9905c751fd6f757fa2b4cf473be1e/apple_ocr-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f243bb901cd3b46019297058a49f3c087486d76ba8cc129f891299463dd4e70d",
                "md5": "406acb265735743b722a09eda8d45e06",
                "sha256": "9ede4888ac808d33a6078df019a7fddcff44f7018fe8a481abb24e6aadeb9649"
            },
            "downloads": -1,
            "filename": "apple-ocr-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "406acb265735743b722a09eda8d45e06",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9226,
            "upload_time": "2024-01-29T19:25:23",
            "upload_time_iso_8601": "2024-01-29T19:25:23.690241Z",
            "url": "https://files.pythonhosted.org/packages/f2/43/bb901cd3b46019297058a49f3c087486d76ba8cc129f891299463dd4e70d/apple-ocr-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-29 19:25:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "apple-ocr"
}
        
Elapsed time: 0.27473s