Experiments with OpenAI

James Carlson
3 min readMay 7, 2023

--

See the app at imagemachine.io.

The past few weeks, like many, I’ve been drawn to experiment with OpenAI’s offerings. My test project wast to build a little app to make images using DALL-E. Below is one image, created by asking “make an abstract painting mixing the styles of Braque and Klee; use blues, reds, a little orange and warm grays.”

Below is another, generated by asking DALL-E to “make an abstract painting blending the styles of Braque and Signac. Use mostly pastel colors but some with strong values.”

Writing the app turned out to be surprisingly easy. OpenAI, the company behind ChatGPT, has very good documentation. Browsing it, I found an explanation of how to generate images. Here is the key piece of code, a shell script:

url https://api.openai.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"prompt": "A cute baby sea otter",
"n": 2,
"size": "1024x1024"
}

I signed up for an API key, tried out the shell script, and with it as a guide, built a small web app. Below is a screenshot of the first version, which you can find at imagemachine.io. It is written in Elm, a pure functional language, using choonkeat’s Elm library for working with the OpenAI API. There will be some upgrades coming in the next few weeks.

PS. While I’ve used the app mostly for generating abstract art, you can of course prompt it to create any kind of image. Here is one such example:

Here is one more image, with a fairly long prompt:

Prompt for the above: An abstract composition with one large shape, two medium-sized shapes, and a few smaller ones. Make it two-dimensional. Add a network of lines. The background should be reminiscent of Australian aboriginal paintings. Keep the colors only partially saturated, with lots of grays and earth tones.

Remark. In its current incarnation, the app generates 10 images per prompt. My experience is that one has to look through at least that many images on average to find one that has satisfying esthetics. The other knob to turn, of course, is tuning the prompt itself, using it to guide DALL-E in the direction you want to go (and discovering or at least refining that direction as you proceed).

Addendum, May 13, 2023

I’ve added a number of features to imagemachine.io: (a) users can store generated images that they like in a private searchable library, (b) images can be displayed as a “gallery,” as in the example below:

Public galleries can be accessed by url without sign-in. Try imagemachine.io/gallery/jxxcarlson or imagemachine.io/gallery/zeno.

Addendum, May 26, 2023

The best way to see what people are doing with ImageMachine.io. Just go to https://imagemachine.io/exhibit

Exhibit Space @ ImageMachine.io

--

--

No responses yet