{"library":"mineru-vl-utils","title":"MinerU Vision-Language Utilities","description":"mineru-vl-utils is a Python library providing utilities for interacting with MinerU Vision-Language models. It acts as a lightweight wrapper to simplify sending requests and handling responses from the MinerU VLM. The library is actively maintained, with frequent minor releases, and the current version is 0.2.3.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install mineru-vl-utils","pip install \"mineru-vl-utils[transformers]\"","pip install \"mineru-vl-utils[vllm]\"","pip install \"mineru-vl-utils[mlx]\"","pip install \"mineru-vl-utils[lmdeploy]\""],"cli":null},"imports":["from mineru_vl_utils import MinerUClient","from mineru_vl_utils import MinerULogitsProcessor"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom PIL import Image\nfrom mineru_vl_utils import MinerUClient\n\n# For http-client backend, ensure a MinerU server is running at the specified URL.\n# For local testing, you might run a server (e.g., using vllm with a MinerU model).\n# Replace with your actual server URL if different.\nserver_url = os.environ.get('MINERU_SERVER_URL', 'http://127.0.0.1:8000')\n\n# Initialize the client with the http-client backend\n# Other backends (e.g., 'transformers', 'vllm-engine') require additional setup and dependencies.\nclient = MinerUClient(backend=\"http-client\", server_url=server_url)\n\n# Create a dummy image for demonstration (replace with your actual image loading)\ntry:\n    image = Image.new('RGB', (60, 30), color = 'red')\n    image_bytes = None # In a real scenario, load image bytes or path\n    # Example: image = Image.open(\"path/to/your/image.jpg\")\n    # image.save(\"temp_image.png\") # Save to a temp file if needed for client input\n\n    # Assuming the client can take a PIL Image object directly or you convert to bytes/path\n    # The actual API call might look slightly different based on specific model endpoint\n    print(f\"Attempting to send a dummy image to {server_url}...\")\n    # This is a simplified example; actual client methods might be like client.process_image(image)\n    # The actual method often depends on the MinerU model's exposed API.\n    # For this example, we'll simulate a call that would use an image input.\n    # Check MinerU documentation for exact `two_step_extract` or similar method signature.\n    \n    # A more realistic quickstart often involves a hosted model or a fully configured local one.\n    # As `mineru-vl-utils` is a wrapper, its usage depends on the backend selected.\n    # For HTTP client, interaction is via server_url.\n    # For direct model inference (transformers, vllm-engine), it involves passing the model/processor.\n    \n    # Example with a generic 'process' method if available:\n    # result = client.process(image) \n    # print(\"Processed result:\", result)\n    print(\"MinerUClient initialized. To use it, you would call a method like client.two_step_extract(image) \")\n    print(\"or client.async_process(image) depending on the backend and model capabilities.\")\n\nexcept Exception as e:\n    print(f\"An error occurred during quickstart: {e}\")\n    print(\"Please ensure a MinerU VLM server is running at the specified server_url for the 'http-client' backend.\")","lang":"python","description":"This quickstart demonstrates how to initialize the `MinerUClient` using the `http-client` backend. It shows how to prepare a dummy PIL Image and hints at the interaction with a running MinerU VLM server. Note that for direct model inference backends like `transformers` or `vllm-engine`, you would pass the pre-loaded model and processor during client initialization.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}