{"id":14958383,"url":"https://github.com/louisbrulenaudet/apple-ocr","last_synced_at":"2025-10-24T14:31:56.607Z","repository":{"id":202751389,"uuid":"707689580","full_name":"louisbrulenaudet/apple-ocr","owner":"louisbrulenaudet","description":"Easy-to-Use Apple Vision wrapper for text extraction, scalar representation and clustering using K-means.","archived":false,"fork":false,"pushed_at":"2024-01-29T19:26:55.000Z","size":149,"stargazers_count":98,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T02:21:20.488Z","etag":null,"topics":["apple","clustering","kmeans","nlp","ocr","ocr-recognition","pyobjc","python","scatter-plot","sklearn"],"latest_commit_sha":null,"homepage":"https://github.com/louisbrulenaudet/apple-ocr","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/louisbrulenaudet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"louisbrulenaudet"}},"created_at":"2023-10-20T12:50:46.000Z","updated_at":"2025-01-28T14:28:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e0d5df2-fc8e-498f-99d7-fe057c22520b","html_url":"https://github.com/louisbrulenaudet/apple-ocr","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"8fba9da94f6eaea182874a6cbc68c31279a3b3e2"},"previous_names":["louisbrulenaudet/apple-ocr"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Fapple-ocr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Fapple-ocr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Fapple-ocr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Fapple-ocr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/louisbrulenaudet","download_url":"https://codeload.github.com/louisbrulenaudet/apple-ocr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237990569,"owners_count":19398452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple","clustering","kmeans","nlp","ocr","ocr-recognition","pyobjc","python","scatter-plot","sklearn"],"created_at":"2024-09-24T13:16:54.868Z","updated_at":"2025-10-24T14:31:48.270Z","avatar_url":"https://github.com/louisbrulenaudet.png","language":"Python","funding_links":["https://github.com/sponsors/louisbrulenaudet"],"categories":[],"sub_categories":[],"readme":"# 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é 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrulenaudet%2Fapple-ocr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flouisbrulenaudet%2Fapple-ocr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrulenaudet%2Fapple-ocr/lists"}