
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Inkwell is a modular Python library for extracting information from PDF documents documents with state of the art Vision Language Models. We make use of layout understanding models to improve accuracy of Vision Language models.
Inkwell uses the following models, with more integrations in the work
pip install py-inkwell[inference]
In addition, install detectron2
pip install git+https://github.com/facebookresearch/detectron2.git
Install Tesseract
For Ubuntu -
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
and, Mac OS
brew install tesseract
For GPUs, install flash attention and vllm for faster inference.
pip install flash-attn --no-build-isolation
pip install vllm
from inkwell.pipeline import Pipeline
pipeline = Pipeline()
document = pipeline.process("/path/to/file.pdf")
pages = document.pages
Every Page has the following fragment objects -
Each figure fragment's content has the following attributes -
figures = page.figure_fragments()
for figure in figures:
figure_image = figure.content.image
figure_bbox = figure.content.bbox
figure_text = figure.content.text
Each table fragment's content has the following attributes -
tables = page.table_fragments()
for table in tables:
table_data = table.content.data
table_bbox = table.content.bbox
table_image = table.content.image
Each text fragment's content has the following attributes -
text_blocks = page.text_fragments()
for text_block in text_blocks:
text_block_text = text_block.content.text
text_block_bbox = text_block.content.bbox
text_block_image = text_block.content.image
We will take the following PDF and extract text, tables and images from this separtely.
from inkwell.pipeline import Pipeline
pipeline = Pipeline()
document = pipeline.process("/path/to/file.pdf")
pages = document.pages
for page in pages:
figures = page.figure_fragments()
tables = page.table_fragments()
text_blocks = page.text_fragments()
# Check the content of the image fragments
for figure in figures:
figure_image = figure.content.image
figure_text = figure.content.text
# Check the content of the table fragments
for table in tables:
table_image = table.content.image
table_data = table.content.data
# Check the content of the text blocks
for text_block in text_blocks:
text_block_image = text_block.content.image
text_block_text = text_block.content.text
We have defined a default config class here. You can add vision-language models to the config to use them instead of the default models.
from inkwell.pipeline import DefaultPipelineConfig, Pipeline
from inkwell.ocr import OCRType
from inkwell.table_extractor import TableExtractorType
# using Qwen2 2B Vision OCR anf Table Extractor
config = DefaultPipelineConfig(
ocr_detector=OCRType.QWEN2_2B_VISION,
table_extractor=TableExtractorType.QWEN2_2B_VISION
)
# using Phi3.5 Vision OCR and Table Extractor
config = DefaultPipelineConfig(
ocr_detector=OCRType.PHI3_VISION,
table_extractor=TableExtractorType.PHI3_VISION
)
# using OpenAI GPT4o Mini OCR and Table Extractor (Requires API Key)
config = DefaultPipelineConfig(
ocr_detector=OCRType.OPENAI_GPT4O_MINI,
table_extractor=TableExtractorType.OPENAI_GPT4O_MINI
)
pipeline = Pipeline(config=config)
You can add custom detectors and other components to the pipeline yourself - follow the instructions in the Custom Components notebook
We derived inspiration from several open-source libraries in our implementation, like Layout Parser and Deepdoctection. We would like to thank the contributors to these libraries for their work.
FAQs
Python library for document processing
We found that py-inkwell demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.