Skip to content

Latest commit

 

History

History
97 lines (56 loc) · 4.23 KB

README.md

File metadata and controls

97 lines (56 loc) · 4.23 KB

AI Image Generation with OpenAI's DALL-E

Simple API calls using OpenAI's Image Generation APIs.

Images generated with OpenAI DALL-E 3

Prompt:

"Create a wintery photo image for a horse and a skier. Include both the horse and the skier in the picture in full. The horse should run fast and pull the skier behind him with ropes. The horse should not be on skis. The skier should look like a Mongolian person from 100 years ago. The photo should look like it's 30 years old."

Despite clear instructions, there is at least one issue with all the pictures.
image 1 - 2 image 3 - 4 image 5 - 6
skijoer1 skijoer3 skijoer5
skijoer2 skijoer4 skijoer6

Image Variations

I created variation images with OpenAI's DALL-E 2 for the last image crated previously.

The AI may have recognised the ambiguity with the horse running over skis so it removed them, or they were just lost as insignificant details. However, for all the variations, the AI decreased the image quality significantly. Variations are only available for DALL-E 2.

variation 1 variation 2 variation 3
variation1 variation2 variation3

Image Edits

I edited the picture with DALL-E 2's edit functionality. (Edits are only available for DALL-E 2)

For the first edit, I tried to remove the skis from under the horse.

original picture mask edited picture
original-picture masked-picture edited-picture

For the second time, I tried adding visible skis under the person. The last picture is finally true to the original prompt.

original picture mask final picture
original-picture2 masked-picture2 edited-picture


How to run this project?

  1. Prerequisites:

    • Make sure Python3 is installed.
    • If you don't have an account with OpenAI, create one here: https://openai.com/
    • Create a project API key under Dashboard / API keys
  2. Clone the project.

  3. Create a virtual environment inside the project folder:

    python -m venv venv

  4. Activate the virtual environment:

    Mac: source venv/bin/activate

    Windows: venv\Scripts\activate

  5. Select interpreter in VSCode:

    (on Mac) Cmd + Shift + P ---> Select Interpreter ---> Select the created venv environment

  6. Install the python dependencies:

    pip install -r requirements.txt

  7. Create an .env file in the root folder and add your project's API key:

    OPENAI_API_KEY=your-unique-opanai-project-key
    
    
  8. Run the Jupyter Notebook:

    • jupyter notebook command will open the Notebook in the browser.
    • The DALL-E-3 image generation code is in the openai-dall-e.ipynb file.
    • Image Variations code is in openai-dall-e-variations.ipynb file.
    • Image Edit code is in openai-dall-e-edits.ipynb file.

Credits