Image Engineering with Amazon Nova Canvas [🎥 Video Demo Included]

image-engineering-with-amazon-nova-canvas-[-video-demo-included]

Amazon Nova Canvas: AI-Powered Image Generation with AWS Bedrock

Amazon Nova Canvas is a powerful image generation application that leverages AWS Bedrock’s image generation capabilities through a user-friendly Streamlit interface. The application enables users to create, manipulate, and customize images using advanced AI models with features like text-to-image generation, color-guided generation, and image-guided generation.

The application provides a comprehensive set of controls for image generation parameters including quality settings, dimensions, and prompt adherence. It supports multiple generation modes to accommodate different creative needs – from simple text prompts to sophisticated image variations guided by reference images or color palettes. All generated images and associated metadata are automatically saved and can be downloaded directly from the interface.

Image Engineering Project Demo

Repository Structure

.
├── amazon_image_gen.py           # Core image generation class using AWS Bedrock API
├── amazon_image_streamlit_app.py # Main Streamlit application interface
├── output/                       # Generated images and metadata storage
│   └── [timestamp]/             # Timestamped output directories containing:
│       ├── request.json         # Generation request parameters
│       ├── response_body.json   # API response with generated images
│       └── response_metadata.json# AWS response metadata
└── streamlit_requirements.txt    # Python package dependencies

Usage Instructions

Prerequisites

  • Python 3.7 or higher
  • AWS account with Bedrock access
  • AWS credentials configured locally
  • Required Python packages:
    • boto3 >= 1.33.8
    • Pillow >= 10.1.0
    • ipywidgets >= 8.1.5
    • streamlit >= 1.30.0

Installation

  1. Clone the repository:
git clone [repository-url]
cd [repository-name]
  1. Install dependencies:
pip install -r streamlit_requirements.txt
  1. Configure AWS credentials:
aws configure

Quick Start

  1. Launch the Streamlit application:
streamlit run amazon_image_streamlit_app.py
  1. Select a generation feature from the sidebar:
  2. Simple Image Generation
  3. Color-Guided Generation
  4. Image-Guided Generation
  5. Instant Customization
  6. Background Replacement

  7. Configure generation parameters:

  8. Image quality (standard/premium)

  9. Dimensions (width/height)

  10. CFG Scale (prompt adherence)

  11. Number of images

  12. Seed value

  13. Enter your prompt and generate images

More Detailed Examples

Simple Image Generation

# Example text prompt
text_prompt = "A beautiful landscape with mountains and a lake at sunset"
negative_prompt = "clouds, people, text"

# Configure parameters
inference_params = {
    "taskType": "TEXT_IMAGE",
    "textToImageParams": {
        "text": text_prompt,
        "negativeText": negative_prompt,
    },
    "imageGenerationConfig": {
        "numberOfImages": 1,
        "quality": "standard",
        "width": 1024,
        "height": 768,
        "cfgScale": 7.0,
        "seed": 123456
    }
}

Color-Guided Generation

# Example with color guidance
inference_params = {
    "taskType": "COLOR_GUIDED_GENERATION",
    "colorGuidedGenerationParams": {
        "text": "digital painting of a landscape",
        "colors": ["#81FC81", "#386739", "#C9D688"]
    },
    "imageGenerationConfig": {
        "numberOfImages": 1,
        "quality": "standard",
        "width": 1024,
        "height": 768
    }
}

Troubleshooting

Common Issues:

  1. AWS Credentials Error

    • Error: “Failed to initialize AWS Bedrock client”
    • Solution: Verify AWS credentials in ~/.aws/credentials
    • Check region configuration in ~/.aws/config
  2. Image Generation Timeout

    • Error: “Read timeout error”
    • Solution: Adjust the boto3 client timeout in config
    • Default timeout is 300 seconds for multiple images
  3. Validation Errors

    • Error: “Malformed input request”
    • Solution: Ensure all required parameters are provided
    • Check minimum length requirements for text prompts

Debug Mode:

import logging
logging.basicConfig(level=logging.DEBUG)

Data Flow

The application processes image generation requests through AWS Bedrock’s API, handling both text-to-image and image-to-image transformations. The system manages request parameters, API communication, and response processing while maintaining a persistent output structure.

[User Input] -> [Streamlit Interface] -> [BedrockImageGenerator]
                                              |
                                        [AWS Bedrock API]
                                              |
[Output Directory] <- [Response Processing] <- [Generated Images]

Key Component Interactions:

  1. User input captured through Streamlit interface
  2. Parameters validated and formatted for AWS Bedrock
  3. BedrockImageGenerator handles AWS API communication
  4. Generated images saved to timestamped directories
  5. Response metadata logged for tracking
  6. Images displayed in interface with download options
  7. Error handling and validation at each step
Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
my-$10,000-mistake-with-eks-auto-mode-(and-how-you-can-avoid-it)

My $10,000 Mistake with EKS Auto Mode (And How You Can Avoid It)

Next Post
automatiza-tu-despliegue-con-gitops-usando-flux-y-kubernetes-

Automatiza tu despliegue con GitOps usando Flux y Kubernetes 🚀

Related Posts