cancel
Showing results for 
Search instead for 
Did you mean: 
Technical Blog
Explore in-depth articles, tutorials, and insights on data analytics and machine learning in the Databricks Technical Blog. Stay updated on industry trends, best practices, and advanced techniques.
cancel
Showing results for 
Search instead for 
Did you mean: 
andreas-kopp_da
Databricks Employee
Databricks Employee

Image Generation in the Enterprise

For agencies, creative studios, retailers, and media companies, visual assets are core to the business. Better image generation can directly improve output, speed, and revenue.

But visuals matter far beyond creative industries. Marketing teams create campaign assets, sales teams tailor customer-specific visuals, product teams explore mockups, communications teams prepare graphics, and analytics teams turn complex information into infographics. Image generation is becoming a horizontal enterprise capability, not a niche creative tool.

The challenge is that a prompt only creates an image. A business needs a production-ready asset: aligned with brand guidelines, safe to publish, available in the right format, searchable, governed, and reusable. That is why enterprise image generation needs a workflow around the image lifecycle: generation, editing, evaluation, storage, governance, and reuse.

Latest models such as OpenAI’s gpt-image-2 and Google’s Gemini 3 Pro Image make this much more practical. The step forward is not only better image quality, but greater reliability across business-critical tasks: following detailed instructions, rendering text correctly, editing existing images, and combining multiple visual elements consistently.

This makes use cases such as infographics, branded content, product compositions, localized variants, and template-based batch generation much more realistic for enterprise teams.

 

Quickstart: Generating Images on Databricks

Latest foundation models from providers such as Anthropic, OpenAI, and Google are available directly as Databricks-hosted models in your workspace. In this blog post, we use databricks-gpt-5-5 through the Responses API, enabling it to call gpt-image-2 as a tool for image generation and editing.

You can execute the following cell in a Databricks notebook to generate high-quality images.

import base64
from databricks.sdk import WorkspaceClient

client = WorkspaceClient().serving_endpoints.get_open_ai_client()

prompt = "An editorial magazine page about wolves in North America and how they are more harmless than we think. Make it look like a glossy, smooth, well-laid-out science magazine."

response = client.responses.create(
    model="databricks-gpt-5-5",
    input=prompt,
    tools=[{
        "type": "image_generation",
        "model": "gpt-image-2",
        "size": "1024x1536",
    }],
    stream=True,
)

image_base64 = next(
    chunk.item.result
    for chunk in response
    if chunk.type == "response.output_item.done"
    and chunk.item.type == "image_generation_call"
)

with open("wolves.png", "wb") as f:
    f.write(base64.b64decode(image_base64))

andreaskopp_da_0-1786530387184.png

The example uses streaming because generated images are returned as base64-encoded payloads. On Databricks Model Serving, larger image responses can exceed the maximum response size. Streaming avoids this by returning the result as a sequence of events, allowing the image generation call to complete successfully.

The result shows what changes when a strong reasoning model like databricks-gpt-5-5 is paired with a modern image model such as gpt-image-2. Instead of producing only a good-looking picture, the system can infer the structure of an editorial asset, draw on relevant world knowledge, and render a coherent draft with layout, copy, and infographics from a very simple prompt.

The image generation tool exposes several practical controls for production use: 

  • size defines the output resolution, with gpt-image-2 supporting flexible dimensions up to a maximum edge length of 3840 pixels, subject to aspect ratio and total pixel constraints. 
  • quality controls the tradeoff between speed, cost, and fidelity 
  • output_format can be used to select formats such as PNG, JPEG, or WebP. 
  • For JPEG and WebP outputs, output_compression helps reduce payload size for downstream delivery. 
  • Note that gpt-image-2 does currently not support transparent backgrounds. If transparent output is required, you need to switch the image model from gpt-image-2 to gpt-image-1.5 and set background to "transparent".

 

From Prompting to Production Workflows

Image generation becomes more valuable when it moves beyond one-off prompts into repeatable workflows. The reference architecture below shows how Databricks can support the full lifecycle: generation, editing, analysis, search, storage, governance, and reuse.

andreaskopp_da_1-1786530469451.png

The architecture combines a Databricks App based UI with hosted foundation models such as databricks-gpt-5-5 for prompt enhancement and image generation. Generated  assets are stored in Unity Catalog Volumes, while Lakebase manages metadata, lineage, analysis results, and embeddings for multimodal vector search. 

For asset discovery, the architecture uses the SigLIP 2 So400m multimodal embedding model to support text-to-image and image-to-image similarity search.

Beyond single-image flows, the same architecture supports scalable production patterns: one prompt template across many input images, one source image through many prompt variations, and bulk import for existing archives. Imported and generated images are analyzed, embedded, and stored in the same governed asset library.

The analysis layer runs on every asset. databricks-gpt-5-5 returns a structured evaluation with a five-axis score covering quality, prompt adherence, purpose fit, text legibility, and content safety, plus explicit issue lists and a suggested improved prompt when needed. Configurable style-guideline templates make brand fit, on-message visuals, and campaign-specific rules measurable rather than purely manual review steps.

We are packaging this reference architecture as Databricks Vision, a sample application that is published in a GitHub repository. The repo includes a React-based frontend, but its main value is the reusable backend structure. Classes such as VisionWorkspace, ImageGen, ImageAnalyzer, ImageSearch, and ImageAdmin can be reused by enterprise developers to build or customize their own workflows.

 

Databricks Vision in Action

The examples below put Databricks Vision to work on a series of concrete tasks: enhancing prompts, generating and editing brand assets, running automated quality analysis, and searching the resulting library by text or image. Each snippet is short and self-contained, but together they trace the full lifecycle from idea to governed, searchable visual asset.

 

Establish Vision Workspace Connection

The following prerequisites are required to run the code samples below. For detailed setup instructions, see the Databricks Vision repository.

  • A Databricks workspace with foundation models enabled. databricks-gpt-5-2 or higher is required.
  • A Lakebase (autoscaling Postgres) database for metadata and vector embeddings
  • A SigLIP embedding model (siglip-so400m-embeddings) for semantic image search deployed on a custom endpoint
  • A Unity Catalog Volume for storing generated images
  • A local Python 3.12+ environment authenticated via DATABRICKS_HOST and DATABRICKS_TOKEN
import os
from dotenv import load_dotenv
from image_gen import VisionWorkspace, ImageGen, ImageAnalyzer, ImageSearch

load_dotenv()

vw = VisionWorkspace(
    lakebase_project="image-gen-dbx", # autoscaling Lakebase project 
    embedding_endpoint="siglip-so400m-embeddings",
)
gen      = ImageGen(vw, output_root="/Volumes/marketing/image_gen/blogpost")
analyzer = ImageAnalyzer(vw)
search   = ImageSearch(vw)

Generated images are written to a Unity Catalog Volume, metadata and vector embeddings are managed in Lakebase.

 

Prompt Enhancement for commercial-quality Brand Assets

Assume the design team is exploring ideas for Databricks-branded sneakers and wants to turn a basic request into a high-quality image generation prompt:

polished = await gen.rewrite(prompt="commercial product shot of databricks-branded sneakers")

Prompt enhancement also supports image inputs. This is useful for image editing scenarios where the model can use both the text instruction and the reference image to create a more precise edit prompt.

A related pattern is image-to-prompt regeneration: provide an existing image and ask the model to describe it as a detailed generation prompt. The resulting text prompt can then be passed to gpt-image-2 to recreate a similar image. In our tests, this worked surprisingly well, even though the image generation model only received the extracted text prompt, not the original image.

Let’s check out the results of the suggested polished prompt for our Databricks sneakers:

andreaskopp_da_3-1786530664613.png

We can now select the strongest generation and refine it with the model’s image editing capabilities as required. Edits are guided by a text prompt that describes the desired change, such as adjusting the background, changing colors, or refining brand elements.

Accurate logo reproduction is a common requirement. While the Databricks logo is already reasonably well represented in these examples, a production workflow would typically include the original logo as an input image to improve brand accuracy in the final asset.

 

Create high-quality Infographics 

Generating complex infographics has traditionally been very difficult for AI image models. They require much more than a good visual style: correct spelling, structured layouts, aligned panels, meaningful icons, labels, arrows, and a clear visual hierarchy. To get reliable results, prompts often need to describe the full information architecture, including layout, wording, relationships between elements, and text wrapping.

With gpt-image-2, this use case has improved significantly. The model is better suited for text-heavy and structured visuals, with stronger image quality, improved editing performance, and more flexible image sizes. This makes it more practical for architecture diagrams, presentation slides, educational visuals, posters, and widescreen infographics.

The following examples illustrate the breadth of infographic use cases supported by gpt-image-2, from maps and architecture diagrams to trend overviews and financial visualizations. 

andreaskopp_da_4-1786530697064.png

Despite the clear progress of gpt-image-2, complex infographic generation still requires iteration. Dense layouts can take longer to generate, text placement may still need refinement, and repeated visual elements are not always perfectly consistent across generations. A good practice is to work iteratively: be explicit about structure, wording, and hierarchy, then refine the result through edits. If you already have example visuals or key objects, using them as references in edit workflows can help guide the model toward a more accurate final result.

 

Create a fashion/product composition using image edits

Image editing is about more than changing a single image. With current models such as gpt-image-2, edit workflows can modify existing images, generate new compositions from one or more reference images, and support iterative multi-turn refinement. 

In this example, we combine a selfie with separate clothing assets to create a catalog-style outfit visualization.

source_images = ["input/selfie.png", "input/woman-shirt.png", "input/woman-jeans.png", "input/woman-shoes.png"]
gen.show(source_images)

andreaskopp_da_0-1786530867122.png

prompt = "Create a professional catalog shot of the woman wearing the shirt, jeans and shoes. Ensure an accurate reproduction of her face and hair."

images = await gen.edit(
    prompt=prompt,
    images=input_images,
    quality="high",
    size="1024x1536",
    n=3,
)

The model uses the input images as references and generates a new fashion image that preserves the person’s identity while composing the selected shirt, jeans, and shoes into a coherent result. This is a practical pattern for virtual fitting rooms, merchandising mockups, and rapid campaign prototyping.

andreaskopp_da_1-1786530888804.png

The same approach extends naturally to other domains. Retail teams can create bundle shots or seasonal product variants from separate assets, real-estate teams can stage interiors or replace furnishings, and marketing or design teams can refine layouts, backgrounds, and branded elements through iterative edits instead of rebuilding an image from scratch.

 

Template-based batch generation

Single-prompt workflows work for exploration, but production teams typically need to apply the same recipe across many input images, such as localizing a hero asset for multiple markets, restyling an entire product catalog, or generating variants of a campaign template. Databricks Vision supports two batch patterns: a single prompt template applied across many input images, or a single source image rendered through many prompt variations. Both reuse the same generation pipeline and write results into the same governed asset library.

In this example, we generate a Databricks AI Days event poster for every tour city. The input Volume holds one skyline photo per city, and the AI Days logo is passed as a reference image so branding stays consistent across the run.

batch = await gen.batch(
    input_volume_path="/Volumes/marketing/image_gen/ai_days/cities",
    prompt_template=(
        "Databricks AI Days event poster for {image_name}. "
        "Use the city skyline as the hero background, overlay the Databricks AI Days logo."
    ),
    reference_image_path="/Volumes/marketing/image_gen/ai_days/dbx-ai-days-logo.png",
    size="1024x1536",
    quality="high",
)

The {image_name} placeholder resolves to each city in turn (london, paris, barcelona, and so on), and the reference logo keeps brand elements consistent across the run. Each output is written to the same Volume, with metadata, lineage, and prompt history synced to Lakebase. Behind the scenes, the call triggers a Databricks Job that uses ai_query against the image generation endpoint, with Spark partitions sized to the endpoint's provisioned concurrency. A batch of 500 images runs as fast as the endpoint allows, with no custom retry or fan-out code.

andreaskopp_da_2-1786530947390.png

Databricks Vision also supports the inverse pattern, where a single source image is rendered through a list of labelled prompt variations. This is useful for exploring formats, audiences, or messaging around one hero asset without rebuilding it from scratch each time.

 

Analyze generated Images

A generated image is not automatically a production-ready asset. At enterprise scale, it needs supporting metadata, quality signals, and governance checks before it can be stored, reused, or shared. This includes descriptions and tags for search and organization, moderation and safety signals for responsible use, brand checks for commercial consistency, and refinement suggestions when the output does not fully match the intended result.

 

Original prompt

Premium commercial product shot of sleek white-and-red Databricks-branded sneakers on a polished concrete pedestal, featuring subtle geometric paneling, embroidered Databricks cube logo on the side, red accent stitching, translucent outsole, and clean techwear styling; three-quarter hero angle with one shoe slightly forward, crisp studio lighting with softbox highlights and gentle rim light, cool gray gradient background with faint data-grid reflections, ultra-sharp focus, realistic materials, minimalist enterprise-tech mood, high-end advertising aesthetic.

Resulting Image

andreaskopp_da_3-1786530973579.png

 


“Small heel-side Databricks text is partially illegible/distorted and may be misspelled.”
(see issues below)

Tags

branded sneakers  Databricks logo  white athletic shoes
product photography  studio lighting  tech brand merchandise
red accent details

Evaluation

The image is highly successful as a premium commercial product shot: composition is strong, the foreground shoe has a confident three-quarter hero angle, and the second shoe sits naturally behind it to create depth. Lighting is polished and advertising-grade, with soft highlights on the white materials, a gentle rim effect, and a clean gray tech-oriented background. Material rendering is convincing, especially the leather-like panels, mesh toe box, padded collar, stitching, translucent outsole, and concrete pedestal texture. The Databricks brand cues are clear through the red stacked cube-like side mark and the tongue logo, and the red accent stitching/outsole inserts reinforce the brand palette. The faint data-grid background supports the enterprise-tech mood without distracting from the product. The main issue is text fidelity: the tongue wordmark reads clearly as “databricks,” but the small heel-side text appears slightly distorted/possibly misspelled, which is common in AI imagery and could be problematic for a real brand asset. The embroidered side logo is recognizable as Databricks-inspired, though it may not be an exact official cube mark. Overall, it fits the prompt very well and would be close to usable for a high-end concept mockup, with minor refinements needed for exact brand/logo accuracy and small text cleanup.

Metrics

  • Quality 5/5
  • Prompt adherence: 4/5
  • Purpose fit 5/5
  • Text legibility: 4/5
  • Content safety: 5/5

Issues

  1. Small heel-side Databricks text is partially illegible/distorted and may be misspelled.
  2. Side cube logo is Databricks-like but may not precisely match the official Databricks cube logo.
  3. Prompt asks for embroidered Databricks cube logo on the side; the side logo looks raised/stitched but the embroidery texture could be more explicit

Prompt suggestion

Premium commercial product shot of sleek white-and-red Databricks-branded sneakers on a polished concrete pedestal, featuring subtle geometric paneling, embroidered official Databricks cube logo on the side, red accent stitching, translucent outsole, and clean techwear styling; three-quarter hero angle with one shoe slightly forward and the second shoe clearly behind, crisp studio lighting with softbox highlights and gentle rim light, cool gray gradient background with faint data-grid reflections, ultra-sharp focus, realistic leather/mesh/rubber materials, no extra labels or distorted text, minimalist enterprise-tech mood, high-end advertising aesthetic.

We derive this analysis from a call to databricks-gpt-5-5 through the Responses API. The model receives the original prompt, the generated image, and optional brand or purpose context, then returns a JSON object validated against a Pydantic schema.

The response includes a short factual description, metadata tags, a critical evaluation, separate lists for missing prompt elements, safety flags, and brand conflicts, plus a five-axis score from 0 to 5 across quality, fidelity, fit, legibility, and safety. If the output has a clear issue, the model also suggests a revised prompt to address it.

The description and tags feed the search index. Safety and brand fields support moderation gates. The revised prompt closes the loop into the next generation. With one model call per image and one row in Lakebase, each asset becomes ready to govern, search, and reuse.

 

Semantic Image Search

Finding the right visual asset in a large archive can be time-consuming. Metadata can help with filtering and navigation, but it is often not descriptive enough to find an image that matches a specific scene, mood, or composition.

With the deployed multimodal embedding model, we can perform semantic image search across text and image modalities. Users can describe the scene they are looking for in natural language, or provide an input image to find visually or semantically similar assets.

The following examples demonstrate text-to-image search using descriptive and abstract search queries.

query = "indian woman painting the wall orange with her daughter watching"
results = search.text(query, k=4)
gen.show(results)

andreaskopp_da_4-1786531039384.png

Results are ordered by semantic similarity. The highest-ranked match captures all key aspects of the query. The remaining results still share some semantic similarity, but relevance decreases gradually: first the daughter is missing, then the task changes from painting a wall to painting on a canvas, and finally the results match only the broader theme of a woman painting.

More abstract queries, such as “animal parental care” or “female model looking pensive, introverted”, show how semantic search can retrieve accurate matches when the query describes a concept, mood, or relationship rather than concrete objects. These results are based only on image and text embeddings, without using metadata or file names.

andreaskopp_da_5-1786531039384.png

andreaskopp_da_6-1786531039383.png

The same approach also supports image-to-image search. Instead of describing the target asset in text, users can provide a reference image and retrieve assets with similar visual or semantic characteristics. Let’s try this with one of the generated Databricks-branded sneakers.

query = "output/databricks_sneakers_001.png"
results = search.image(query, k=3)
gen.show(results, query=query)

andreaskopp_da_7-1786531078595.png

 

Resources