https://github.com/heyfoz/python-dalle2-image-edit
This Python script enables users to interact with OpenAI's DALL·E 2 API for image editing. Users can specify an original image, a mask image, and a text prompt for the DALL·E 2 model to edit the image accordingly.
https://github.com/heyfoz/python-dalle2-image-edit
api dalle dalle2 environment-variables openai os python
Last synced: 2 months ago
JSON representation
This Python script enables users to interact with OpenAI's DALL·E 2 API for image editing. Users can specify an original image, a mask image, and a text prompt for the DALL·E 2 model to edit the image accordingly.
- Host: GitHub
- URL: https://github.com/heyfoz/python-dalle2-image-edit
- Owner: heyfoz
- License: mit
- Created: 2024-02-17T22:59:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-24T19:53:50.000Z (about 1 year ago)
- Last Synced: 2024-09-12T00:13:01.975Z (about 1 year ago)
- Topics: api, dalle, dalle2, environment-variables, openai, os, python
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DALL·E 2 Image Editor Script
This Python script enables users to interact with OpenAI's DALL·E 2 API for image editing. Users can specify an original image, a mask image, and a text prompt for the DALL·E 2 model to edit the image accordingly.
**NOTE**: OpenAI API documentation and capabilities may change over time. For the most current information, refer to the official [OpenAI site for developers](https://platform.openai.com/docs/guides/images/introduction).
## Important Note
The images generated or edited by the DALL·E 2 API are typically available immediately after the request. However, it's important to handle the data responsibly and in accordance with OpenAI's use case policies.## Authentication
The script requires an API key from OpenAI for authentication. Before running the script, you must set up an environment variable `OPENAI_API_KEY` or similarly named variable with your OpenAI API key. Retrieve your API key from the [API Keys page on OpenAI](https://platform.openai.com/account/api-keys).Alternatively, the environment variable name can be customized if needed. The purpose of setting this environment variable is to securely store and access the API key within your application without hardcoding it into the script.
For assistance on setting up environment variables:
- On Windows, see Microsoft's guide on [Environment Variables](https://learn.microsoft.com/en-us/windows/win32/procthread/environment-variables).
- On Linux/Unix, refer to the guide on [setting environment variables in Linux](https://linuxize.com/post/how-to-set-and-list-environment-variables-in-linux/).## Features
- Interactive prompts for user input of the original image, mask image, and editing prompt.
- Integration with OpenAI's DALL·E 2 API for image editing.
- Execution of a constructed cURL command to make the API request.## Prerequisites
Ensure you have the following installed before running this script:
- Python (3.x or higher)
- Access to a terminal or command prompt
- An API key from OpenAI for DALL·E 2 access## Installation
1. Install Python from [Python's official website](https://www.python.org/downloads/).
2. Ensure you have access to a terminal or command prompt for executing Python scripts.
3. Set up an environment variable `OPENAI_API_KEY` with your OpenAI API key.## Usage
Run the script in a Python environment. Follow the interactive prompts to enter the locations of your original image, mask image, and your editing prompt. The script will then perform the image editing and provide feedback.
## OpenAI DALL·E 2 API Resources
For detailed information about the DALL·E 2 API and its image editing capabilities, refer to the following resources:
- [OpenAI Edit Image API Reference](https://platform.openai.com/docs/api-reference/images/createEdit)
- [OpenAI Edit Image Guide](https://platform.openai.com/docs/guides/images/edits-DALL·E-2-only)
- [DALL·E](https://labs.openai.com/)
- [OpenAI API Pricing](https://openai.com/api/pricing)## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.