Skip to content

genai-musings/dallying-with-DALL-E

Repository files navigation

dallying-with-DALL-E

License: MPL 2.0 Bandit Safety Check Super-Linter [CodeQL Markdown Links Check Spell-Checker Unit-Tests Code-Coverage Docker-Build-Push Docker-Push-README

Repository for dallying with DALL-E.

This repository contains Python code, and associated unit tests, which uses the OpenAI API to perform image generation. The code takes the input from the user and generates a response using DALL-E an AI image generator. You just need to provide a description and DALL-E will generate the image.

To run program

Your OpenAI key is passed to program via an environment variable

export OPENAI_KEY="Your OpenAI key"
python main.py

To generate an OpenAI key browse to OpenAI API Keys and select "Create new secret key".

Credits

To generate images you need DALL-E credits.

To run unit tests

pytest

To build and run an instance of a Docker image locally.

The username and password for Docker Hub are stored as secrets this GitHub repository.

Note: To set up the secrets in your GitHub repository, go to the repository page, navigate to the "Settings" tab, and then select "Secrets" from the left menu. Add a secret named DOCKERHUB_USERNAME with the Docker Hub username to be used, and another secret named DOCKERHUB_PASSWORD with the Docker Hub password to be used.

Build

Build the Docker image.

docker build -t dallying-with-dall-e .

Run

Run the Docker image as a container.

export OPENAI_KEY="Your OpenAI key"
docker run -it -e OPENAI_KEY=$OPENAI_KEY dallying-with-dall-e

To pull and run an instance of the Docker image from Docker Hub

Pull

docker pull <dockerhub-username>/dallying-with-dall-e:<tag>

Replace with your Docker Hub username and with the specific tag of the Docker image you want to pull.

Run

export OPENAI_KEY="Your OpenAI key"
docker run -it -e OPENAI_KEY=$OPENAI_KEY <dockerhub-username>/dallying-with-dall-e:<tag>

OpenAI API Reference

For more information on the API available see the OpenAI API Reference Documentation.