OpenAI (DALL-E) inside Grasshopper with Python — Advanced version

Luciano Ambrosini
4 min readNov 23, 2022

--

Recently many Architects and Designers have been exploring different AI platforms — This is exciting!

So I would like to share with you this little intuition…

This article is the natural continuation of the one related to the first introduction of the request processes for the processing of images from the prompt to image by Artificial Intelligence (see here). So here below I assume that you already have installed all necessary to run LA_OpenAI-GH ghuser component that you will find in the AI Ambrosinus-Toolkit sub-category. Anyway, I added some extra tips for some of you that have encountered issues in installing the python libraries (unfortunately this procedure depends on AI platform developers).

Now this component is available on my GitHub page and has replaced the previous Python light version one

EDIT mode

Coded components in action:

Algorithm with the new Ambrosinus-Toolkit components [since v1.1.2]

The key concept behind the Edit process consists in elaborating an “image mask” based on the given one as input (BaseIMG parameter) with a transparent “shape mask”. In this way, the AI quickly realizes that the area in which the DALL-E algorithm will have to make changes (elaborates new predictions) is only the transparent one, all the rest, opaque, will remain unchanged. The design workflow improvements regard the possibility to avoid going forth and back from Photoshop or from whatever image-editing software you prefer and go on staying in a unique design environment like Rhino and Grasshopper.

Maybe this is a little thing…but this is my intuition. Let me explaining

So thanks to the ImageMask component is it possible to draw inside Rhino and over the base image given as source input and use the 2D Rhino tools as a “lasso selection tool”. The nested sequence is Frame (one curve) > Curves (also more than one) > Holes (also more than one — optional — but very important is that holes need to be contained in Curve) — Please do not draw intersections among these three categories to avoid failure. Others info about ImageMask are available here.

Briefly in order to run Edit mode you need:

  • API Key;
  • select mode;
  • a base image (PNG);
  • an image mask as described above;
  • a full path where saving all new images;
  • text prompt;
  • number of images to generate;
  • images size (256px or 512px or 1024px)

For instance, imagine that you or your colleague has generated a facade study for a beautiful building or architectural project. Now you can “manipulate” as expected by Open AI just a specific portion of that facade. This “little intuition” allows you to push forward your creative boundaries and even more smartly your design production.

Image source credits by Hassan Ragab from IG @hsnrgb — further improvement/enhancement by Luciano Ambrosini IG @lucianoambrosini
Image source credits by Arturo Tedeschi from IG @arturotedeschi — further improvement/enhancement by Luciano Ambrosini IG @lucianoambrosini

Below I have provided a simple carousel of images

More examples on my website https://bit.ly/OpenAI-insideGrasshopperADV
More examples on my website https://bit.ly/OpenAI-insideGrasshopperADV

Here below is the video DEMO

https://youtu.be/nmJTP1QvuIE

VARIATION mode

Coded components in action:

About the Variation process, I can only tell you that the whole image production is made by DALL-E in terms of input parameters, you only need to give as input the base image, no image mask, and no text prompt is needed.

Briefly in order to run Variation mode you need:

  • API Key;
  • select mode;
  • a base image (PNG);

So unleash your creativity! ;)

Image source credits by Hassan Ragab from IG @hsnrgb — further improvement/enhancement by Luciano Ambrosini IG @lucianoambrosini
Image source credits by Arturo Tedeschi from IG @arturotedeschi — further improvement/enhancement by Luciano Ambrosini IG @lucianoambrosini

Below I have provided a simple carousel of images

More examples on my website https://bit.ly/OpenAI-insideGrasshopperADV
More examples on my website https://bit.ly/OpenAI-insideGrasshopperADV

Here below is the video DEMO

https://youtu.be/UPTc5o6rOLM

More info about installation HERE

--

--