Skip to main content

Get descriptions of images from OpenAI, Azure OpenAI, and Anthropic Claude models in an easy way.

Project description

TextFromImage

Get descriptions of images using OpenAI's GPT models on easy way.

Installation

You can install the textfromimage package via PyPI using pip:

pip install textfromimage

Usage

The textfromimage package is now class-based, allowing you to initialize the TextFromImage class with your desired configurations and use its methods to obtain image descriptions.

from textfromimage import TextFromImage

# Option 1: Set your OpenAI API key as an environment variable
import os
os.environ['OPENAI_API_KEY'] = 'your-api-key'

# Initialize the TextFromImage class
text_from_image = TextFromImage()

# Get a description of the image
image_url = 'https://example.com/image.jpg'
description = text_from_image.get_description(image_url)
print(description)

Specifying a Different Model

You can specify a different OpenAI model if needed. By default, the model is set to "gpt-4o".

from textfromimage import TextFromImage

# Initialize with a specific model
text_from_image = TextFromImage(model='gpt-4o-mini')

# Get a description of the image
image_url = 'https://example.com/image.jpg'
description = text_from_image.get_description(image_url)
print(description)

Parameters

  • image_url (str): The URL of the image.
  • prompt (str, optional): The prompt for the description (default: "What's in this image?").
  • model (str, optional): The OpenAI model to use (default: "gpt-4o").
  • api_key (str, optional): Your OpenAI API key.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a pull request.

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

textfromimage-0.3.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

textfromimage-0.3.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file textfromimage-0.3.0.tar.gz.

File metadata

  • Download URL: textfromimage-0.3.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for textfromimage-0.3.0.tar.gz
Algorithm Hash digest
SHA256 fe3a5a19a18d7fe264f0b9810c923d54c4c8df2a1d8849d7ed5aa3a8e19edb06
MD5 ee7ca4b0ae06198f0bd06c236cdf5941
BLAKE2b-256 c08d08ca1de064d31cf7ce69b5bf552292576f828b9859073c08472d6aca284c

See more details on using hashes here.

File details

Details for the file textfromimage-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for textfromimage-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cf881ee8012c47fd63f33b40c89bae05f5f09668f4745baad7b3fcb86166f78
MD5 5ca9e87319d7704ad821605e590257bd
BLAKE2b-256 8700acf1362f3a0869950c4d223d2a2554c62b77509e8964e2b8387d9e742dd8

See more details on using hashes here.

Supported by

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