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.
Official client for Siftrics' Hydra API, which is a text recognition documents-to-database service
This repository contains the official Hydra API Python client. The Hydra API is a text recognition service.
pip install hydra-api
or
poetry add hydra-api
etc.
import hydra_api
client = hydra_api.Client('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
rows = client.recognize('my_data_source_id', ['invoice.pdf', 'receipt_1.png'])
rows
looks like this:
[
{
"Error": "",
"FileIndex": 0,
"RecognizedText": { ... }
},
...
]
FileIndex
is the index of this file in the original request's "files" array.
RecognizedText
is a dictionary mapping labels to values. Labels are the titles of the bounding boxes drawn during the creation of the data source. Values are the recognized text inside those bounding boxes.
There is another function, client.recognizeBase64(dataSourceId, base64Files, doFaster=False)
, which accepts base64 strings (file contents) instead of file paths. Because it is not trivial to infer MIME type from the contents of a file, you must specify the MIME type associated to each base64 file string: base64Files
must be a list of dict
objects containing two fields: "mimeType"
and ``"base64File"`. Example:
base64Files = [
{
'mimeType': 'image/png',
'base64File': '...',
},
{
'mimeType': 'application/pdf',
'base64File': '...',
},
]
rows = client.recognizeBase64('Helm-Test-Againe', base64Files, doFaster=True)
Hydra can transform input documents so they are cropped and aligned with the original image used to create the data source.
The recognize
and recognizeBase64
functions have an additional default parameter, returnTransformedImages
, which defaults to False
, but if it's set to True
then Siftrics transforms and returns images so they are aligned with the original image.
Returned images will be available in the "TransformedImages" field of each element of "Rows" in the response:
{
"Rows": [
{
"Error": "",
"FileIndex": 0,
"RecognizedText": {
"My Field 1": "text from your document...",
"My Field 2": "text from your document...",
...
},
"TransformedImages": [
{
"Base64Image": ...,
"PageNumber": 1
},
...
]
},
...
]
}
The recognize
and recognizeBase64
functions have an additional default parameter, doFaster
, which defaults to False
, but if it's set to True
then Siftrics processes the documents faster at the risk of lower text recognition accuracy. Experimentally, doFaster=true seems not to affect accuracy when all the documents to be processed have been rotated no more than 45 degrees.
The recognize
and recognizeBase64
functions have additional default parameters, returnJpgs=False
and jpgQuality=85
. If returnJpgs
is set to True
, then Siftrics returns cropped images in JPG format instead of PNG format. jpgQuality
must be an integer between 1 and 100 inclusive.
Here is the official documentation for the Hydra API.
This code is licensed under Apache V2.0. The full text of the license can be found in the "LICENSE" file.
FAQs
Official client for Siftrics' Hydra API, which is a text recognition documents-to-database service
We found that hydra-api 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.