This script allows you to generate images using OpenAI's DALL-E 3 model via a command-line interface. The script supports asynchronous image creation, handles user inputs, and saves images with metadata.
- Asynchronous image generation using aiohttp and asyncio.
- Supports standard, landscape, and portrait image sizes.
- Saves generated images with metadata (original and revised prompts).
- Handles multiple jobs concurrently with threading.
- Configurable via environment variables.
- Python 3.10+
- OpenAI API Key
Required Python packages: aiohttp, python-dotenv, Pillow, argparse, asyncio
- Clone the repository:
git clone https://github.com/itachi1621/Dall-E-3_Desktop_Client.git
cd DAll-E-3-Desktop_Client
- Install the required packages:
pip install -r requirements.txt
- Set up your environment variables. Create a .env file in the project directory and add your OpenAI API key:
OPENAI_KEY=your_openai_api_key
MAX_IMAGES=5
QUALITY=standard
USE_REVISED=False
Run the script with the following command:
python Dall-E-3_Desktop_Client.py
Images are stored in the output folder of the directory
You can also provide the prompt, number of images, and image size as command-line arguments: **Note Only prompt is required other arguments are optional
python Dall-E-3_Desktop_Client.py --prompt "A futuristic cityscape" --number_of_images 3 --pic_size "l"
Bring up help info
python Dall-E-3_Desktop_Client.py --help
If no command-line arguments are provided, the script will run in interactive mode, prompting you for the necessary inputs.
- OPENAI_KEY: Your OpenAI API key.
- MAX_IMAGES: Maximum possible number of images to generate per job. e.g only allow the user to generate up to 2 images (May also be dependent on your OpenAI Tier Limits)
- QUALITY: Image quality setting. use
standard
orHD
- USE_REVISED: Use the revised prompt returned by the API for subsequent image generation (True/False). By Default Dalle will generate a new prompt per image and will give varrying results.
Ensure you have a valid OpenAI API key set in your .env file. Check that the required Python packages are installed. Verify that the environment variables are correctly set.
Feel free to open issues or submit pull requests if you have suggestions or improvements.
This project is licensed under the MIT License.