Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.
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.
The script relies on the following Python libraries:
Here's how you can use apple_ocr
:
Installation: Install the required libraries, including Torch
, NumPy
, Pandas
, Pillow
, scikit-learn
, and Plotly
.
Initialization: Create an instance of the OCR
class, providing an image to be processed.
from apple_ocr.ocr import OCR
from PIL import Image
image = Image.open("your_image.png")
ocr_instance = OCR(image=image)
recognize
method to perform text recognition. It will return a structured DataFrame containing recognized text, bounding box dimensions, text density, and centroid coordinates.dataframe = ocr_instance.recognize()
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.cluster_labels = ocr_instance.cluster(dataframe, num_clusters=3)
scatter
method to create an interactive 3D scatter plot. This plot visualizes the clustered text elements, including centroids, text density, and more.ocr_instance.scatter()
Here's an example of the entire process:
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()
If you use this code in your research, please use the following BibTeX entry.
@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}
}
If you have any feedback, please reach out at louisbrulenaudet@icloud.com.
FAQs
An OCR (Optical Character Recognition) utility for text extraction from images.
We found that apple-ocr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.