Name | vlm-tools JSON |
Version |
0.2.2
JSON |
| download |
home_page | None |
Summary | Tools to work with the VLM-1 API. |
upload_time | 2024-06-27 18:30:48 |
maintainer | None |
docs_url | None |
author | Sudeep Pillai |
requires_python | <3.12,>=3.10 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Tools for VLM-1
<p align="center">
<a href="https://pypi.org/project/vlm-tools/">
<img alt="PyPi Version" src="https://badge.fury.io/py/vlm-tools.svg">
</a>
<a href="https://pypi.org/project/vlm-tools/">
<img alt="PyPi Version" src="https://img.shields.io/pypi/pyversions/vlm-tools">
</a>
</p>
`vlm-tools` provides a convenient set of tools to interact with the [VLM-1](https://autonomi.ai/vlm-1) API.
## Installation
The `vlm-tools` python package is available on PyPI. You can install it using pip:
```sh
pip install vlm-tools
```
Optionally, if you want to install the `torch` extra dependencies, you can do so by installing the package with the `torch` extra:
```sh
pip install vlm-tools[torch]
```
## Authentication
The VLM-1 API requires an API key to authenticate requests. You can obtain an API key by signing up on the [waitlist](https://airtable.com/appjX6543bChjNaEN/pagnciKtynSt4rOT9/form). Once you have an API key, you can set it in the environment variable `VLM_API_KEY`:
```bash
export VLM_API_KEY='...'
```
## Usage
### Image -> JSON
The python client needs to be configured with your personal API key before you can use it. You can set the API key in the environment variable `VLM_API_KEY` as described above or pass it to the client constructor.
```python
from vlm_tools.api import vlm
>>> image = Image.open(...)
>>> response_json = vlm(image, domain="document.presentation")
>>> response_json
{
"description": "...",
"title": "Differentiated Operating Model",
"page_number": 7,
"plots": [
...
],
"tables": null,
"others": [
...
]
}
```
### Streaming Image -> JSON
You can also stream the image to the API using the `stream` method. This is useful when you want to stream images to our API sequentially, and one-by-one. We provide some helper functions to help you with sampling unique-images (content-based sampler) from a video stream.
```python
from vlm_tools.video import VideoReader, VideoItertools
>>> itertools = VideoItertools()
>>> video = VideoReader("path/to/video.mp4")
>>> for img in itertools.islice(video, similarity_threshold=0.9)
... response_json = vlm(img, domain="document.presentation")
```
## Requirements
- Python 3.10+
We currently support Python 3.10+ on Linux and macOS. If you have any questions or issues, please [open an issue](https://github.com/autonomi-ai/vlm-cookbook/issues).
Raw data
{
"_id": null,
"home_page": null,
"name": "vlm-tools",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.12,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Sudeep Pillai",
"author_email": "sudeep.pillai@gmail.com",
"download_url": null,
"platform": null,
"description": "# Tools for VLM-1\n\n<p align=\"center\">\n <a href=\"https://pypi.org/project/vlm-tools/\">\n <img alt=\"PyPi Version\" src=\"https://badge.fury.io/py/vlm-tools.svg\">\n </a>\n <a href=\"https://pypi.org/project/vlm-tools/\">\n <img alt=\"PyPi Version\" src=\"https://img.shields.io/pypi/pyversions/vlm-tools\">\n </a>\n</p>\n\n\n`vlm-tools` provides a convenient set of tools to interact with the [VLM-1](https://autonomi.ai/vlm-1) API.\n\n\n## Installation\n\nThe `vlm-tools` python package is available on PyPI. You can install it using pip:\n\n```sh\npip install vlm-tools\n```\n\nOptionally, if you want to install the `torch` extra dependencies, you can do so by installing the package with the `torch` extra:\n\n```sh\npip install vlm-tools[torch]\n```\n\n\n## Authentication\n\nThe VLM-1 API requires an API key to authenticate requests. You can obtain an API key by signing up on the [waitlist](https://airtable.com/appjX6543bChjNaEN/pagnciKtynSt4rOT9/form). Once you have an API key, you can set it in the environment variable `VLM_API_KEY`:\n\n```bash\nexport VLM_API_KEY='...'\n```\n\n## Usage\n\n### Image -> JSON\n\nThe python client needs to be configured with your personal API key before you can use it. You can set the API key in the environment variable `VLM_API_KEY` as described above or pass it to the client constructor.\n\n```python\nfrom vlm_tools.api import vlm\n\n>>> image = Image.open(...)\n>>> response_json = vlm(image, domain=\"document.presentation\")\n>>> response_json\n{\n \"description\": \"...\",\n \"title\": \"Differentiated Operating Model\",\n \"page_number\": 7,\n \"plots\": [\n ...\n ],\n \"tables\": null,\n \"others\": [\n ...\n ]\n}\n```\n\n### Streaming Image -> JSON\n\nYou can also stream the image to the API using the `stream` method. This is useful when you want to stream images to our API sequentially, and one-by-one. We provide some helper functions to help you with sampling unique-images (content-based sampler) from a video stream.\n\n```python\nfrom vlm_tools.video import VideoReader, VideoItertools\n\n>>> itertools = VideoItertools()\n>>> video = VideoReader(\"path/to/video.mp4\")\n>>> for img in itertools.islice(video, similarity_threshold=0.9)\n... response_json = vlm(img, domain=\"document.presentation\")\n```\n\n## Requirements\n\n - Python 3.10+\n\n We currently support Python 3.10+ on Linux and macOS. If you have any questions or issues, please [open an issue](https://github.com/autonomi-ai/vlm-cookbook/issues).\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Tools to work with the VLM-1 API.",
"version": "0.2.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3e21822aa408926a3156db93b0c488bd371367047b05302c51d320f6113bae6a",
"md5": "f9b608c7d4fbcb72d8722962e62d50a3",
"sha256": "c416d2498ef1a6b1a8b8e62a7cf5d224828dd383fc7e7cd376c140335b35f84c"
},
"downloads": -1,
"filename": "vlm_tools-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f9b608c7d4fbcb72d8722962e62d50a3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.12,>=3.10",
"size": 11211,
"upload_time": "2024-06-27T18:30:48",
"upload_time_iso_8601": "2024-06-27T18:30:48.593768Z",
"url": "https://files.pythonhosted.org/packages/3e/21/822aa408926a3156db93b0c488bd371367047b05302c51d320f6113bae6a/vlm_tools-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-27 18:30:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "vlm-tools"
}