### Install Vision Parse with Gemini Support Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/gemini_demo.ipynb Install the vision-parse package with the necessary dependencies for Google Gemini integration. Use '-Uqq' for an upgrade and quiet installation. ```python !pip install 'vision-parse[gemini]' -Uqq ``` -------------------------------- ### Install uv (Windows) Source: https://github.com/iamarunbrahma/vision-parse/blob/main/CONTRIBUTING.md Installs the uv package manager using PowerShell. This is the recommended way to manage dependencies. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install Ollama on Linux Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/ollama_setup.md Use this command to install Ollama on a Linux system by downloading and executing the official install script. ```bash curl -fsSL https://ollama.com/install.sh | sh ``` -------------------------------- ### Install vision-parse Package Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/ollama_demo.ipynb Installs the vision-parse package with ollama support. Use this command to set up the necessary libraries. ```python !pip install vision-parse -Uqq # install the vision-parse package with ollama ``` -------------------------------- ### Install uv (Mac/Linux) Source: https://github.com/iamarunbrahma/vision-parse/blob/main/CONTRIBUTING.md Installs the uv package manager using a curl script. This is the recommended way to manage dependencies. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/iamarunbrahma/vision-parse/blob/main/CONTRIBUTING.md Synchronizes all project dependencies using uv and activates the virtual environment. ```bash uv sync --all-extras && source .venv/bin/activate ``` -------------------------------- ### Install Vision Parse with OpenAI Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/openai_demo.ipynb Install the vision-parse package with OpenAI support using pip. The -Uqq flags ensure the package is upgraded and output is quiet. ```bash !pip install 'vision-parse[openai]' -Uqq ``` -------------------------------- ### Install Docker Compose on Linux Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Installs Docker Engine and Docker Compose on a Linux system. For GPU support, additional steps are required. ```bash # Install Docker Engine curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # Install Docker Compose sudo apt-get install docker-compose # For GPU Support (Optional) curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list sudo apt-get update sudo apt-get install -y nvidia-container-toolkit ``` -------------------------------- ### Install Ollama on macOS Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/ollama_setup.md Install Ollama on macOS using the Homebrew package manager. ```bash brew install ollama ``` -------------------------------- ### Install Vision Parse Package Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Install the core vision-parse package using pip. For additional dependencies supporting OpenAI or Gemini, use the '[all]' extra. ```bash pip install vision-parse ``` ```bash pip install 'vision-parse[all]' ``` ```bash pip install 'git+https://github.com/iamarunbrahma/vision-parse.git#egg=vision-parse[all]' ``` -------------------------------- ### Install Benchmark Requirements Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Install the necessary Python packages for running benchmarks using pip. The `--no-cache-dir` flag prevents pip from storing downloaded packages in its cache. ```bash pip install --no-cache-dir -r benchmarks/requirements.txt ``` -------------------------------- ### Initialize Vision Parser with OpenAI Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/openai_demo.ipynb Initialize the VisionParser with OpenAI model configurations. Ensure the OPENAI_API_KEY is set in your environment variables. This setup allows for detailed extraction and concurrent processing. ```python from vision_parse import VisionParser import os # Initialize parser parser = VisionParser( model_name="gpt-4o", api_key=os.getenv("OPENAI_API_KEY"), temperature=0.9, top_p=0.4, max_tokens=4096, frequency_penalty=0.3, image_mode=None, detailed_extraction=True, enable_concurrency=True, ) pdf_path = "../tests/Texas-Holdem-Rules.pdf" markdown_pages = parser.convert_pdf(pdf_path) # Print the markdown pages for i, page_content in enumerate(markdown_pages): print(f"\n--- Page {i+1} ---\n{page_content}") ``` -------------------------------- ### Pull and Serve Ollama Models Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/ollama_setup.md Commands to pull a specific vision model and start the Ollama server to serve it. ```bash ollama pull llama3.2-vision:11b ``` ```bash ollama serve ``` -------------------------------- ### OpenAI Configuration Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Configure OpenAI client settings for advanced use cases and proxy setups. ```APIDOC ## OpenAI Configuration Configure OpenAI client settings including custom base URL, retry logic, timeout, and default headers for advanced use cases and proxy setups. ### Request Example ```python from vision_parse import VisionParser ``` -------------------------------- ### PDF Conversion Output Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/openai_demo.ipynb Example output indicating the progress of PDF page conversion. This shows a single page being processed. ```text Output: Converting pages in PDF file into markdown format: 100%|██████████| 1/1 [00:25<00:00, 25.21s/it] ``` -------------------------------- ### Configure OpenAI Client Settings Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt This snippet shows how to configure advanced OpenAI client settings, such as custom base URLs, retry logic, and timeouts, for specific use cases or proxy setups. ```python from vision_parse import VisionParser ``` -------------------------------- ### Build and Run Vision Parse Docker Container Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Builds the Docker image and starts the Vision Parse container in detached mode. Requires uncommenting GPU resources in docker-compose.yml if using an Nvidia GPU. ```yaml deploy: resources: reservations: devices: - driver: nvidia count: 1 capabilities: [gpu] ``` ```bash # Build the image docker compose build # Start the container in detached mode docker compose up -d ``` -------------------------------- ### Markdown Conversion Result Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/openai_demo.ipynb Example of the markdown output generated from a PDF page. This includes headings, lists, and text content. ```markdown Output: --- Page 1 --- # TEXAS A&M AGRILIFE EXTENSION March 3, 2020 TO: JR Sprague, TCAAA D1 Chairman FROM: Andy Holloway, CEA ANR Hemphill County Regarding the three chairmanships appointed to me none have any action needed at this time except for the rules to be submitted to be posted on the TCAAA website for the Texas Holdem Tournament. Please note the following: ## Texas Hold'em Basic Poker Rules Texas Hold'em is played with a standard deck of 52 cards. The object of the game is to make the best possible five-card poker hand using any combination of the two card's in a player's hand (known as the "hole cards") and the five community cards that the dealer places in the middle of the table, which can be used by all players. The standard hand rankings are used, as follows (from best to worst): - **Straight Flush**: Any five cards of the same suit and consecutive rank; the best of these hands, AKQJT of a single suit, is known as a Royal Flush. For these and regular straights, aces may be played as high or low cards. - **Four of a Kind**: Any four cards of the same rank. - **Full House**: Any three cards from a single rank combined with a pair from a different rank (i.e., TTT55). - **Flush**: Any five cards of the same suit. - **Straight**: Any five cards of consecutive ranks (i.e., 34567). - **Three of a Kind**: Any three cards of the same rank. - **Two Pair**: Any two pairs of cards from the same ranks (ie, 5599A). - **One Pair**: Any two cards of the same rank. - **High Card**: Hands that do not fit any of the above categories are ranked based on the highest card in their hand (aces are high), then by the second highest card, and so on. ``` -------------------------------- ### Initialize VisionParser with Ollama Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Basic initialization for a local Ollama model. No API key is required for local models. ```python from vision_parse import VisionParser # Basic initialization with local Ollama model (no API key required) parser = VisionParser( model_name="llama3.2-vision:11b", temperature=0.4, top_p=0.5, image_mode="url", detailed_extraction=False, enable_concurrency=False, ) ``` -------------------------------- ### Initialize VisionParser with OpenAI GPT-4o Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Initialize the VisionParser with OpenAI's GPT-4o model. Requires an API key and can enable concurrency for faster processing. ```python from vision_parse import VisionParser # Initialize with OpenAI GPT-4o parser = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=True, enable_concurrency=True, ) ``` -------------------------------- ### Clone Vision Parse Repository Source: https://github.com/iamarunbrahma/vision-parse/blob/main/CONTRIBUTING.md Clone your forked repository and navigate into the project directory. ```bash git clone https://github.com/YOUR_USERNAME/vision-parse.git cd vision-parse ``` -------------------------------- ### Configure Ollama for Optimized Performance Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Initialize VisionParser with custom Ollama configurations, including parallel processing, timeouts, and GPU settings. A custom prompt can also be provided for specific extraction needs. ```python from vision_parse import VisionParser # Custom prompt for specific document types custom_prompt = """ Strictly preserve markdown formatting during text extraction from scanned document. Ensure all mathematical equations are converted to LaTeX format. """ # Initialize with optimized Ollama configuration parser = VisionParser( model_name="llama3.2-vision:11b", temperature=0.7, top_p=0.6, num_ctx=4096, image_mode="base64", custom_prompt=custom_prompt, detailed_extraction=True, ollama_config={ "OLLAMA_NUM_PARALLEL": 8, "OLLAMA_REQUEST_TIMEOUT": 240, "OLLAMA_HOST": "http://localhost:11434", "OLLAMA_KEEP_ALIVE": -1, "OLLAMA_NUM_GPU": 1, "OLLAMA_NUM_THREAD": 4, }, enable_concurrency=True, ) markdown_pages = parser.convert_pdf("document.pdf") ``` -------------------------------- ### Initialize VisionParser with Google Gemini Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Initialize the VisionParser using a Google Gemini model. Provide your Gemini API key obtained from Google AI Studio. Adjust `temperature` and `top_p` for controlling the creativity and focus of the model's output. `detailed_extraction` can be set to True for advanced content extraction. ```python parser = VisionParser( model_name="gemini-2.5-flash", api_key="your-gemini-api-key", # Get the Gemini API key from https://aistudio.google.com/app/apikey temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=False, # Set to True for more detailed extraction enable_concurrency=True, ) ``` -------------------------------- ### API Models Usage (OpenAI, Gemini) Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Initialize the VisionParser to use API-based models like OpenAI's GPT-4o. Ensure you provide your API key and configure parameters such as temperature and top_p for desired output. ```python from vision_parse import VisionParser # Initialize parser with OpenAI model parser = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", # Get the OpenAI API key from https://platform.openai.com/api-keys temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=False, # Set to True for more detailed extraction enable_concurrency=True, ) ``` -------------------------------- ### Run Quality Checks Source: https://github.com/iamarunbrahma/vision-parse/blob/main/CONTRIBUTING.md Execute linting, code formatting, and the test suite to ensure code quality before committing. ```bash make lint # Run code linting make format # Format code make test # Run test suite ``` -------------------------------- ### Initialize VisionParser with Google Gemini Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Initialize the VisionParser with Google's Gemini model. Requires an API key and supports base64 image encoding. ```python from vision_parse import VisionParser # Initialize with Google Gemini parser = VisionParser( model_name="gemini-2.5-flash", api_key="your-gemini-api-key", temperature=0.7, top_p=0.4, image_mode="base64", detailed_extraction=True, enable_concurrency=True, ) ``` -------------------------------- ### Initialize VisionParser with Custom OpenAI Configuration Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Configure the VisionParser with specific OpenAI parameters, including custom base URLs, retry counts, timeouts, and headers. This allows for fine-grained control over API interactions. ```python parser = VisionParser( model_name="gpt-4o-mini", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=True, enable_concurrency=True, openai_config={ "OPENAI_BASE_URL": None, # Custom base URL if needed "OPENAI_MAX_RETRIES": 3, "OPENAI_TIMEOUT": 240.0, "OPENAI_DEFAULT_HEADERS": None, }, max_tokens=8192, # Model-specific parameter frequency_penalty=0.3, ) markdown_pages = parser.convert_pdf("complex_document.pdf") ``` -------------------------------- ### Initialize VisionParser with Azure OpenAI Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Initialize the VisionParser using an Azure OpenAI model. Ensure your Azure credentials and deployment details are correctly configured in the `openai_config` dictionary. Set `detailed_extraction` to True for more complex content extraction. ```python parser = VisionParser( model_name="gpt-4o", image_mode="url", detailed_extraction=False, # Set to True for more detailed extraction enable_concurrency=True, openai_config={ "AZURE_ENDPOINT_URL": "https://****.openai.azure.com/", # replace with your azure endpoint url "AZURE_DEPLOYMENT_NAME": "*******", # replace with azure deployment name, if needed "AZURE_OPENAI_API_KEY": "***********", # replace with your azure openai api key "AZURE_OPENAI_API_VERSION": "2024-08-01-preview", # replace with latest azure openai api version }, ) ``` -------------------------------- ### Configure VisionParser with Azure OpenAI Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Initialize VisionParser for use with Azure OpenAI services. Requires Azure-specific configuration parameters like endpoint URL and deployment name. ```python from vision_parse import VisionParser # Initialize with Azure OpenAI configuration parser = VisionParser( model_name="gpt-4o", image_mode="url", detailed_extraction=True, enable_concurrency=True, openai_config={ "AZURE_ENDPOINT_URL": "https://your-resource.openai.azure.com/", "AZURE_DEPLOYMENT_NAME": "your-deployment-name", "AZURE_OPENAI_API_KEY": "your-azure-api-key", "AZURE_OPENAI_API_VERSION": "2024-08-01-preview", }, ) markdown_pages = parser.convert_pdf("enterprise_document.pdf") ``` -------------------------------- ### VisionParser Class Initialization Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Initialize the VisionParser class with different LLM providers and customizable parameters. ```APIDOC ## VisionParser Class Initialization The main class for converting PDF documents to markdown. Supports multiple LLM providers with customizable parameters for temperature, top_p, and provider-specific configurations. ### Request Example ```python from vision_parse import VisionParser # Basic initialization with local Ollama model (no API key required) parser = VisionParser( model_name="llama3.2-vision:11b", temperature=0.4, top_p=0.5, image_mode="url", detailed_extraction=False, enable_concurrency=False, ) # Initialize with OpenAI GPT-4o parser = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=True, enable_concurrency=True, ) # Initialize with Google Gemini parser = VisionParser( model_name="gemini-2.5-flash", api_key="your-gemini-api-key", temperature=0.7, top_p=0.4, image_mode="base64", detailed_extraction=True, enable_concurrency=True, ) ``` ``` -------------------------------- ### Initialize and Use VisionParser with Ollama Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/ollama_demo.ipynb Initializes the VisionParser with specific Ollama model and configuration settings. This snippet demonstrates how to convert a PDF file to markdown pages and print the content of each page. ```python from vision_parse import VisionParser parser = VisionParser( model_name="llama3.2-vision:11b", temperature=0.7, top_p=0.4, num_ctx=4096, num_predict=4096, ollama_config={ "OLLAMA_NUM_PARALLEL": "10", }, image_mode="base64", detailed_extraction=True, enable_concurrency=True, ) pdf_path = "../tests/Texas-Holdem-Rules.pdf" markdown_pages = parser.convert_pdf(pdf_path) for i, page_content in enumerate(markdown_pages): print(f"\n--- Page {i+1} ---\n{page_content}") ``` -------------------------------- ### Initialize and Use Vision Parser with Gemini Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/examples/gemini_demo.ipynb Initialize the VisionParser with Gemini model details and API key. The parser converts a specified PDF file into markdown format, page by page. Ensure the GEMINI_API_KEY environment variable is set. ```python from vision_parse import VisionParser import os # Initialize parser parser = VisionParser( model_name="gemini-2.5-flash", api_key=os.getenv("GEMINI_API_KEY"), temperature=0.9, top_p=0.4, max_output_tokens=2048, image_mode="url", detailed_extraction=True, ) pdf_path = "../tests/Texas-Holdem-Rules.pdf" markdown_pages = parser.convert_pdf(pdf_path) # Print the markdown pages for i, page_content in enumerate(markdown_pages): print(f"\n--- Page {i+1} ---\n{page_content}") ``` -------------------------------- ### Ollama Configuration Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Configure local Ollama models with custom settings for performance optimization. ```APIDOC ## Ollama Configuration Configure local Ollama models with custom settings for parallel processing, timeout, GPU utilization, and threading to optimize performance for your hardware setup. ### Request Example ```python from vision_parse import VisionParser # Custom prompt for specific document types custom_prompt = """ Strictly preserve markdown formatting during text extraction from scanned document. Ensure all mathematical equations are converted to LaTeX format. """ # Initialize with optimized Ollama configuration parser = VisionParser( model_name="llama3.2-vision:11b", temperature=0.7, top_p=0.6, num_ctx=4096, image_mode="base64", custom_prompt=custom_prompt, detailed_extraction=True, ollama_config={ "OLLAMA_NUM_PARALLEL": 8, "OLLAMA_REQUEST_TIMEOUT": 240, "OLLAMA_HOST": "http://localhost:11434", "OLLAMA_KEEP_ALIVE": -1, "OLLAMA_NUM_GPU": 1, "OLLAMA_NUM_THREAD": 4, }, enable_concurrency=True, ) markdown_pages = parser.convert_pdf("document.pdf") ``` ``` -------------------------------- ### Basic PDF to Markdown Conversion Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Initialize the VisionParser with a local model name and convert a PDF file to markdown. The output is a list of strings, where each string represents the markdown content of a page. ```python from vision_parse import VisionParser # Initialize parser parser = VisionParser( model_name="llama3.2-vision:11b", # For local models, you don't need to provide the api key temperature=0.4, top_p=0.5, image_mode="url", # Image mode can be "url", "base64" or None detailed_extraction=False, # Set to True for more detailed extraction enable_concurrency=False, # Set to True for parallel processing ) # Convert PDF to markdown pdf_path = "input_document.pdf" # local path to your pdf file markdown_pages = parser.convert_pdf(pdf_path) # Process results for i, page_content in enumerate(markdown_pages): print(f"\n--- Page {i+1} ---\n{page_content}") ``` -------------------------------- ### Run Benchmark Script Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Execute the benchmark script to evaluate Vision Parse's performance. Remember to update `pdf_path` to your PDF file location and `benchmark_results_path` to your desired output directory before running. ```bash # Change `pdf_path` to your pdf file path and `benchmark_results_path` to your desired output path python benchmarks/scoring.py ``` -------------------------------- ### Commit and Push Changes Source: https://github.com/iamarunbrahma/vision-parse/blob/main/CONTRIBUTING.md Stage all changes, commit them with a descriptive message, and push the branch to your remote repository. ```bash git add . git commit -m "Description of your changes" git push origin feature/your-feature-name ``` -------------------------------- ### Customize Ollama Configuration for Performance Source: https://github.com/iamarunbrahma/vision-parse/blob/main/README.md Configure the VisionParser with Ollama-specific settings and a custom prompt for enhanced performance and detailed extraction. This includes adjusting context size, image mode, and parallel processing parameters. ```python from vision_parse import VisionParser custom_prompt = """ Strictly preserve markdown formatting during text extraction from scanned document. """ # Initialize parser with Ollama configuration parser = VisionParser( model_name="llama3.2-vision:11b", temperature=0.7, top_p=0.6, num_ctx=4096, image_mode="base64", custom_prompt=custom_prompt, detailed_extraction=True, ollama_config={ "OLLAMA_NUM_PARALLEL": 8, "OLLAMA_REQUEST_TIMEOUT": 240, }, enable_concurrency=True, ) # Convert PDF to markdown pdf_path = "input_document.pdf" # local path to your pdf file markdown_pages = parser.convert_pdf(pdf_path) ``` -------------------------------- ### View Supported Vision LLM Models Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Retrieve a list of all models supported by the VisionParser library, including their providers (OpenAI, Gemini, Ollama). This helps in selecting the appropriate model for your task. ```python from vision_parse import SUPPORTED_MODELS # View all supported models for model_name, provider in SUPPORTED_MODELS.items(): print(f"{model_name}: {provider}") # Output: # llama3.2-vision:11b: ollama # gpt-4o: openai # gpt-4o-mini: openai # gemini-2.5-pro: gemini # gemini-2.5-flash: gemini # gemini-2.0-flash: gemini # Additional Ollama models (auto-discovered): # llava:13b: ollama # llava:34b: ollama # llama3.2-vision:70b: ollama # deepseek-r1:32b: ollama ``` -------------------------------- ### Azure OpenAI Configuration Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Configure Azure OpenAI integration for enterprise deployments. ```APIDOC ## Azure OpenAI Configuration Configure Azure OpenAI integration with endpoint URL, deployment name, and API key for enterprise deployments requiring Azure cloud services. ### Request Example ```python from vision_parse import VisionParser # Initialize with Azure OpenAI configuration parser = VisionParser( model_name="gpt-4o", image_mode="url", detailed_extraction=True, enable_concurrency=True, openai_config={ "AZURE_ENDPOINT_URL": "https://your-resource.openai.azure.com/", "AZURE_DEPLOYMENT_NAME": "your-deployment-name", "AZURE_OPENAI_API_KEY": "your-azure-api-key", "AZURE_OPENAI_API_VERSION": "2024-08-01-preview", }, ) markdown_pages = parser.convert_pdf("enterprise_document.pdf") ``` ``` -------------------------------- ### Configure PDF Page Rendering with PDFPageConfig Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Customize PDF to image conversion settings using PDFPageConfig for high-quality rendering. Adjust DPI, color space, and annotation inclusion for optimal output. ```python from vision_parse import VisionParser, PDFPageConfig # Custom page configuration for high-quality rendering page_config = PDFPageConfig( dpi=400, # Resolution for PDF to image conversion color_space="RGB", # Color mode for image output include_annotations=True, # Include PDF annotations preserve_transparency=False, # Control alpha channel ) parser = VisionParser( page_config=page_config, model_name="gpt-4o", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=True, enable_concurrency=True, ) markdown_pages = parser.convert_pdf("high_quality_document.pdf") ``` -------------------------------- ### Configure Vision Parse Environment Variables Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Sets environment variables for the Vision Parse model name and optional API keys. Ensure you select a supported model name. ```bash # Required: Choose one of the following models export MODEL_NAME=llama3.2-vision:11b # select the model name from the list of supported models # Optional: API keys (required only for specific models) export OPENAI_API_KEY=your_openai_api_key export GEMINI_API_KEY=your_gemini_api_key ``` -------------------------------- ### View Vision Parse Container Logs Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Retrieves logs for the Vision Parse container to diagnose errors. ```bash docker compose logs vision-parse ``` -------------------------------- ### Execute Vision Parse Application Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Runs the Gradio application script within the running Vision Parse Docker container. ```bash # Execute the python script inside the container docker compose exec vision-parse python docs/examples/gradio_app.py ``` -------------------------------- ### Configure Image Extraction Modes Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Control how images are handled during PDF conversion. Choose 'url' to save images as separate files, 'base64' to embed them directly in markdown, or None to disable image extraction. ```python from vision_parse import VisionParser # URL mode - saves images as separate files (image_1_1.png, etc.) parser_url = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", image_mode="url", # Images saved as files detailed_extraction=True, enable_concurrency=True, ) # Base64 mode - embeds images directly in markdown parser_base64 = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", image_mode="base64", # Images embedded as base64 detailed_extraction=True, enable_concurrency=True, ) # No image extraction parser_no_images = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", image_mode=None, # No image extraction detailed_extraction=False, enable_concurrency=True, ) markdown_pages = parser_url.convert_pdf("document_with_images.pdf") ``` -------------------------------- ### Create New Git Branch Source: https://github.com/iamarunbrahma/vision-parse/blob/main/CONTRIBUTING.md Create a new branch for bug fixes or new features. Use descriptive names for your branches. ```bash # If you are fixing a bug git checkout -b bugfix/your-bug-name # If you are adding a new feature git checkout -b feature/your-feature-name ``` -------------------------------- ### Troubleshoot Ollama Connection Issues Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Checks if port 11434 is in use, which might cause connection issues with Ollama-based models. ```bash sudo lsof -i :11434 ``` -------------------------------- ### convert_pdf Method Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Converts all pages in a PDF file to markdown-formatted text. Returns a list of strings where each element contains the markdown content of a single page. ```APIDOC ## convert_pdf Method Converts all pages in a PDF file to markdown-formatted text. Returns a list of strings where each element contains the markdown content of a single page. Supports both sequential and concurrent processing modes. ### Request Example ```python from vision_parse import VisionParser parser = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=True, enable_concurrency=True, ) # Convert PDF to markdown pdf_path = "research_paper.pdf" markdown_pages = parser.convert_pdf(pdf_path) # Process and display results for i, page_content in enumerate(markdown_pages): print(f"\n--- Page {i+1} ---\n{page_content}") # Save to file with open("output.md", "w") as f: f.write("\n\n---\n\n".join(markdown_pages)) ``` ``` -------------------------------- ### Convert Large PDF to Markdown Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Use this snippet to convert a large PDF document into a list of markdown pages. Ensure the 'parser' object is initialized with appropriate model settings. ```python markdown_pages = parser.convert_pdf("large_document.pdf") print(f"Converted {len(markdown_pages)} pages") ``` -------------------------------- ### Verify Ollama Server Status Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/ollama_setup.md Use curl to check if the Ollama server is running and accessible by querying its API version. ```bash curl http://localhost:11434/api/version ``` -------------------------------- ### Verify Docker Container Status Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Checks if the Vision Parse Docker container is running. ```bash docker ps ``` -------------------------------- ### Enable Concurrent PDF Page Processing Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Improve performance for multi-page PDFs by enabling concurrent processing. The library automatically optimizes worker usage based on system resources, or you can specify the number of workers. ```python from vision_parse import VisionParser # Enable concurrent processing for faster conversion parser = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=True, enable_concurrency=True, # Process pages in parallel num_workers=4, # Optional: override auto-detected worker count ) ``` -------------------------------- ### Handle VisionParser Errors with Exception Classes Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Implement robust error handling for various stages of PDF processing, including file validation, LLM interactions, and image extraction. Catch specific exceptions for targeted error management. ```python from vision_parse import ( VisionParser, VisionParserError, UnsupportedFileError, LLMError, UnsupportedModelError, ImageExtractionError, ) parser = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, ) try: markdown_pages = parser.convert_pdf("document.pdf") for i, page in enumerate(markdown_pages): print(f"Page {i+1}: {len(page)} characters") except FileNotFoundError as e: print(f"PDF file not found: {e}") except UnsupportedFileError as e: print(f"File is not a valid PDF: {e}") except UnsupportedModelError as e: print(f"Model not supported: {e}") except LLMError as e: print(f"LLM processing failed: {e}") except VisionParserError as e: print(f"Parser error: {e}") except ImageExtractionError as e: print(f"Image extraction failed: {e}") ``` -------------------------------- ### Convert PDF to Markdown Source: https://context7.com/iamarunbrahma/vision-parse/llms.txt Converts a PDF file to markdown format, returning content page by page. The output can be processed or saved to a file. ```python from vision_parse import VisionParser parser = VisionParser( model_name="gpt-4o", api_key="your-openai-api-key", temperature=0.7, top_p=0.4, image_mode="url", detailed_extraction=True, enable_concurrency=True, ) # Convert PDF to markdown pdf_path = "research_paper.pdf" markdown_pages = parser.convert_pdf(pdf_path) # Process and display results for i, page_content in enumerate(markdown_pages): print(f"\n--- Page {i+1} ---\n{page_content}") # Save to file with open("output.md", "w") as f: f.write("\n\n---\n\n".join(markdown_pages)) ``` -------------------------------- ### Manage Vision Parse Docker Container Source: https://github.com/iamarunbrahma/vision-parse/blob/main/docs/docker_setup.md Commands to stop the Vision Parse container while preserving data, or to stop and remove all associated Docker resources. ```bash # Stop the container and preserve data docker compose stop # Stop and remove containers, networks docker compose down ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.