Skip to main content

Module 7: Multimodal and Image Processing

Module 7: Multimodal and Image Processing (Light) Module 7: Multimodal and Image Processing (Dark)

Theoryโ€‹

Why Multimodal Mattersโ€‹

Many real-world applications require agents to understand and process more than just text. Multimodal models, like Gemini, can process text and images together, enabling a powerful new class of vision-enabled agents.

Benefits:

  • ๐Ÿ‘๏ธ Vision Understanding: Analyze images to extract information, identify objects, and understand visual context.
  • ๐ŸŽจ Image Generation: Create new images from text descriptions.
  • ๐Ÿง  Multimodal Reasoning: Combine visual and textual information to answer complex questions.
  • ๐Ÿ“„ Document Analysis: Extract text and structure from images of documents (OCR).

The types.Part Objectโ€‹

The fundamental building block for multimodal content in the ADK is the types.Part object from the google.genai library. A user's prompt is no longer just a string, but a list of Part objects.

A Part can contain:

  • Text: types.Part.from_text(text="Describe this image")
  • Image Data: types.Part(inline_data=types.Blob(data=image_bytes, mime_type='image/png'))

When you send a list of these parts to a vision-capable model like gemini-3.8-flash, the model can reason about the text and the image(s) together.

Figure 7.1: Multimodal Ingestion Pipeline & Part Serializer (Light) Figure 7.1: Multimodal Ingestion Pipeline & Part Serializer (Dark) Figure 7.1: End-to-end multimodal ingestion pipeline from raw media streams to ADK Part objects and Gemini cross-attention reasoning.

Example: Building a Vision Agentโ€‹

To send an image to an agent programmatically, you package it into a list and run it via an App:

from google.adk import Agent
from google.adk.apps import App
from google.adk.runners import InMemoryRunner
from google.genai import types

# 1. Define the agent
agent = Agent(
name="vision_expert",
model="gemini-3.8-flash",
instruction="Describe the provided image in detail."
)

# 2. Wrap in an App
app = App(name="vision_app", root_agent=agent)
runner = InMemoryRunner(app=app)

# 3. Construct the multimodal list
multimodal_prompt = [
"What is in this picture?",
types.Part(inline_data=types.Blob(data=image_bytes, mime_type="image/jpeg"))
]

# 4. Run!
# response = await runner.run_debug(multimodal_prompt)

Image Generationโ€‹

Beyond understanding images, some models can also generate them. Services like Agent Platform Imagen provide text-to-image capabilities. You can create a custom tool that takes a text description, calls the image generation API, and returns the resulting image.

This allows you to build agents that can:

  • Create product mockups from a description.
  • Generate illustrations for a story.
  • Create charts and diagrams from data.

In the lab, you will build a "Visual Product Catalog Analyzer" that uses a single, vision-capable agent to analyze a product image and generate a marketing description from that analysis.

Going Further: the lab below only covers understanding images (analysis), not generating them -- actually calling an image-generation model is a separate integration (a custom tool wrapping the Imagen API) and is out of scope here. If you want to try it hands-on, the shape is the same pattern as any other custom tool from Module 9: a function that calls the generation API and returns image bytes as a types.Part (the same Part type you're about to use for analysis, just produced instead of consumed).

๐ŸŽฏ Knowledge CheckSelect Best Answer

In ADK 2.0 with the Google GenAI SDK, which method is used to construct a multimodal image payload from raw binary bytes for Gemini vision analysis?

Key Takeawaysโ€‹

  • Multimodal models like Gemini can process text and images together, enabling vision-enabled agents.
  • The google.genai.types.Part object is the building block for multimodal content, allowing you to combine text and image data in a single prompt.
  • Vision-capable agents can be used for a wide range of tasks, including image analysis, document understanding, and multimodal reasoning.
  • You can create custom tools to integrate with image generation services like Agent Platform Imagen.
๐Ÿ“–

07: Multimodal & Vision Agents(Theory & Overview)

Part 1: Foundations โ€ข Module 07

Overall Course Progress:
0%(0/98)
Next Step: Challenge Lab ๐Ÿงช โ†’