Skip to main content

A Python library for working with vision models.

Project description

limin-vision

A Python library for working with vision models.

Installation

Install the library using pip:

pip install limin-vision

Usage

After you've installed the library, you can use it by importing the limin_vision module and calling the functions you need. You will also need to provide an API key for your API either by running export OPENAI_API_KEY=$YOUR_API_KEY or by creating an .env file in the root directory of your project and adding the following line:

OPENAI_API_KEY=$YOUR_API_KEY

Here is an example of how to use the library:

import asyncio
from limin_vision import process_image_from_url

async def main():
    url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
    result = await process_image_from_url(url)
    print(result)

if __name__ == "__main__":
    asyncio.run(main())

You can pass additional parameters to the process_image_from_url function to customize the model configuration and prompt:

await process_image_from_url(
    url,
    prompt="What's in this image?",
    model_configuration=ModelConfiguration(
        model="gpt-4o",
        temperature=1.0
    ),
    detail="high",
)

You can find the full example in examples/process_from_url.py.

Alternatively, you can process an image from a local file by calling process_image_from_file instead of process_image_from_url.

from limin_vision import process_image_from_file

async def main():
    result = await process_image_from_file("image.png")
    print(result)

if __name__ == "__main__":
    asyncio.run(main())

Just like with process_image_from_url, you can pass additional parameters to the process_image_from_file function to customize the model configuration and prompt:

await process_image_from_file(
    "image.png",
    prompt="What's in this image?",
    model_configuration=ModelConfiguration(
        model="gpt-4o",
        temperature=1.0
    ),
    detail="high",
)

You can find the full example in examples/process_from_file.py.

You can also get a structured response from the model by passing a response model to the process_image_from_url_structured or process_image_from_file_structured functions.

For example, here's how you can process an image from a URL and get a structured response:

import asyncio
from limin_vision import process_image_from_url_structured
from pydantic import BaseModel

class ImageResponse(BaseModel):
    title: str
    description: str

async def main():
    url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
    result = await process_image_from_url_structured(url, ImageResponse)
    print(result)

if __name__ == "__main__":
    asyncio.run(main())

You can find the full example in examples/process_from_url_structured.py.

You can also process an image from a local file by calling process_image_from_file_structured instead of process_image_from_file.

from limin_vision import process_image_from_file_structured

async def main():
    result = await process_image_from_file_structured("image.png", ImageResponse)
    print(result)

if __name__ == "__main__":
    asyncio.run(main())

You can find the full example in examples/process_from_file_structured.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

limin_vision-0.2.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

limin_vision-0.2.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file limin_vision-0.2.0.tar.gz.

File metadata

  • Download URL: limin_vision-0.2.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for limin_vision-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c918c6f48ed408cf3ef3193f9bdb1c867e1b7940fd5e6b4987215096e0f5bbb1
MD5 9477f3c8f0d056d997bda335755528c8
BLAKE2b-256 ad937d3f4bbaaf5853369ae442a3a27abba84de4e1a935e3923455664e1e8f2d

See more details on using hashes here.

File details

Details for the file limin_vision-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: limin_vision-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for limin_vision-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0522756d0b17e3d8e2618b3677ded22a516862a19231f898649b01da8c005d75
MD5 4a10bcefbcb8af67205433f0d7bb1897
BLAKE2b-256 6897039c2a5d6db3d5d8a23697431d3445176a69af5bd5a330c20cb215d59b44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page