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:
- Fork the repository.
- Create a new branch (git checkout -b feature/YourFeature).
- Commit your changes (git commit -m 'Add some feature').
- Push to the branch (git push origin feature/YourFeature).
- 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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe3a5a19a18d7fe264f0b9810c923d54c4c8df2a1d8849d7ed5aa3a8e19edb06 |
|
MD5 | ee7ca4b0ae06198f0bd06c236cdf5941 |
|
BLAKE2b-256 | c08d08ca1de064d31cf7ce69b5bf552292576f828b9859073c08472d6aca284c |
File details
Details for the file textfromimage-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: textfromimage-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cf881ee8012c47fd63f33b40c89bae05f5f09668f4745baad7b3fcb86166f78 |
|
MD5 | 5ca9e87319d7704ad821605e590257bd |
|
BLAKE2b-256 | 8700acf1362f3a0869950c4d223d2a2554c62b77509e8964e2b8387d9e742dd8 |