This Python project enables efficient extraction of text and images from PDF, DOCX, and PPTX files, using Vision Language Models for image description. It offers a command-line interface and detailed logging to enhance data processing and preparation workflows.
Content Extractor with Vision LLM is a Python-based tool designed to extract, enrich, and organize text and images from documents efficiently. It supports PDF, DOCX, and PPTX file formats and is highly customizable for diverse document processing needs.
Key Features Comprehensive Data Extraction: Extract text and images, preserving the original layout for detailed analysis. Advanced Image Description: Generate image descriptions using local (Ollama) or cloud-based (OpenAI) Vision Language Models. Flexible Output Options: Save extracted content in Markdown format for organized data management. CLI and Library Usage: Use via command-line interface or integrate as a Python library. Detailed Logging: Logs all operations with timestamps for debugging and auditing. Modularity: Modular architecture following SOLID principles for easy maintenance and extension. File Processing Methods PDF Files Extract text and images or convert pages into high-resolution images for content preservation. DOCX Files Extract formatted text and embedded images or save entire pages as images. PPTX Files Convert slides to images while maintaining visual fidelity and apply image descriptions. Image Description Options Local Description:
Powered by the llama3.2-vision model from Ollama. Ideal for offline use with no API key required. Cloud Description:
Powered by OpenAI's GPT-4 Vision or GPT-3 models. Offers higher accuracy with API key requirements. Installation and Setup System Dependencies: Install LibreOffice and Poppler for document processing.
bash Copy code
brew install --cask libreoffice brew install poppler
sudo apt-get install libreoffice poppler-utils Install the Package:
bash Copy code pip install pyvisionai Set Environment Variables: For OpenAI API:
bash Copy code export OPENAI_API_KEY='your-api-key' For Ollama (local):
bash Copy code ollama serve ollama pull llama3.2-vision Usage Examples Command-Line Interface: bash Copy code
file-extract -t pdf -s path/to/file.pdf -o output_dir
describe-image -i path/to/image.jpg Python Library: python Copy code from pyvisionai import create_extractor, describe_image_openai
extractor = create_extractor("pdf") output_path = extractor.extract("input.pdf", "output_dir")
description = describe_image_openai("image.jpg", api_key="your-api-key") Logging and Testing Logs: Stored in content/log/ with detailed operation timestamps. Testing: Includes integration tests for file handling, model comparisons, and error management. Content Extractor with Vision LLM is ideal for applications requiring robust document processing and advanced image analysis, making it a foundational tool for building knowledge pipelines.
No comments yet.
Sign in to be the first to comment.