Guides
Image generation
֍
An introduction to image generation on Substrate

Prompt: "futuristic city of atlantis"

Enhanced image prompt

A sprawling metropolis of iridescent spires and crystalline towers pierces the sky, its architecture a blend of organic and metallic curves. Towering trees with glowing bark and leaves that shimmer like diamonds stretch towards the clouds, their roots entwined with the city's infrastructure. A network of levitating walkways and glowing, fiber-optic "streets" crisscross the city, weaving through a tapestry of gleaming skyscrapers and futuristic domes. In the distance, a majestic, winged statue of a long-forgotten king soars above the city, its wings beating in slow motion as it surveys the metropolis below.

image
Generated image
image
Upscaled image

We'll build a workflow that takes a short prompt ("futuristic city of atlantis"), and uses the imaginative power of generative AI to produce a highly detailed result. We'll:

  • Generate an enhanced image prompt using ComputeText
  • Generate an image using GenerateImage
  • Upscale the image using UpscaleImage

First, initialize Substrate:

Python
TypeScript

from substrate import (
Substrate,
ComputeText,
GenerateImage,
UpscaleImage,
sb,
)
s = Substrate(api_key=YOUR_API_KEY)

Declare and connect the nodes of the pipeline:

  • Generate an enhanced image prompt using ComputeText
  • Generate an image using GenerateImage
  • Upscale the image using UpscaleImage

Run the pipeline by calling substrate.run with the terminal node of the workflow, upscale.

Python
TypeScript

prompt = "futuristic city of atlants"
description = ComputeText(
prompt=f"create a description of an image of {prompt}. we'll use this description to generate an image. be concise and terse focusing on the subject. just return the description, no preamble.",
)
image = GenerateImage(prompt=description.future.text)
upscale = UpscaleImage(
prompt=description.future.text,
image_uri=image.future.image_uri,
output_resolution=2048,
)
res = s.run(upscale)