Build a Multi-Modal GenAI Application: Challenge Lab
Welcome to the "Build a Multi-Modal GenAI Application" Challenge Lab on Google Cloud! In this lab, you’ll take your AI development skills to the next level by solving a real-world scenario using cutting-edge GenAI tools like Imagen 3.0 and Gemini 2.0 Flash. 📌 Lab Duration: 20 minutes 🧠 Difficulty: Introductory (but hands-on and unscripted!) 💡 Use Case: AI-powered bouquet design and image analysis Code Telegram:- https://t.me/refactorslife/20 ------------------------------------------------------------------------------------------------------------------------------------- 🔍 What You'll Do: Task-1 import vertexai from vertexai.preview.vision_models import ImageGenerationModel def generate_bouquet_image(prompt:str): project_id = "qwiklabs-gcp-01-7bddb62394e6" # Replace with actual Project ID location = "us-west1" # Use the correct region output_file = "bouquet_image.jpeg" vertexai.init(project=project_id, location=location) model = ImageGenerationModel.from_pretrained("imagen-3.0-generate-002") images = model.generate_images( prompt=prompt, number_of_images=1, seed=1, add_watermark=False, ) Task-2 import vertexai from vertexai.preview.generative_models import GenerativeModel, Part def analyze_bouquet_image(image_path: str): project_id = "qwiklabs-gcp-01-7bddb62394e6" location = "us-west1" # Initialize Vertex AI vertexai.init(project=project_id, location=location) try: # Read the image in binary mode with open(image_path, "rb") as img_file: image_part = Part.from_data(img_file.read(), mime_type="image/jpeg") prompt = "Write a birthday wish based on this bouquet." # Load the Gemini multimodal model model = GenerativeModel("gemini-2.0-flash-001") # Generate content with streaming enabled responses = model.generate_content( [prompt, image_part], stream=True ) print("\n🎉 Birthday Wish:") for chunk in responses: if chunk.text: print(chunk.text, end="", flush=True) except Exception as e: print(f"❌ Error: {e}") # Call the function with correct image path analyze_bouquet_image("bouquet_image.jpeg") ----------------------------------------------------------------------------------------------------------------------------------------------- This lab doesn’t guide you step-by-step. Instead, it tests your problem-solving and real implementation skills in an AI development scenario. Perfect for those looking to validate their practical understanding of Google’s Generative AI APIs! ✅ Complete all tasks to score 100% 🧪 No cost, no risk – just your skill and 20 focused minutes! 🔗 Subscribe for more GenAI tutorials, walkthroughs, and tips!
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.