Skip to main content

Get descriptions of images from OpenAI's GPT models on 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.2.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

textfromimage-0.2.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: textfromimage-0.2.0.tar.gz
  • Upload date:
  • Size: 3.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.2.0.tar.gz
Algorithm Hash digest
SHA256 d526b4609fb472888588f971894d6470076bbf760db2480c3ec4936ee455db22
MD5 5fa47b8ed1d2e60aed02d8428c8d548b
BLAKE2b-256 99e9862b43788597b8c268495138dc50cbf8f61e3a0f41b4bcd3cf5d5c024e21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textfromimage-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d982e513da95ee858f202caffe2d8586cd765f2a4ecfb16bb9d7597beb0154a5
MD5 11a71e74b3be72ca71daa3759d6aebf9
BLAKE2b-256 d268c667091bfcfb21386189e4e6790e5903bc2f6b6fa4cdeaaf4d1e7c41253e

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