Today's AI/ML headlines are brought to you by ThreatPerspective

AWS Machine Learning Blog

Build a generative AI image description application with Anthropic’s Claude 3.5 Sonnet on Amazon Bedrock and AWS CDK

In this post, we delve into the process of building and deploying a sample application capable of generating multilingual descriptions for multiple images with a Streamlit UI, AWS Lambda powered with the Amazon Bedrock SDK, and AWS AppSync driven by the open source Generative AI CDK Constructs. Install all dependencies: npm install Bootstrap AWS CDK resources on the AWS account. Replace ACCOUNT_ID and REGION with your own values: cdk bootstrap aws://ACCOUNT_ID/REGION Deploy the solution: cdk deploy The preceding command deploys the stack in your account. The deployment will take approximately 5 minutes to complete. Configure client_app: cd client_app python -m venv venv source venv/bin/activate pip install -r requirements.txt Within the /client_app directory, create a new file named .env with the following content. Replace the property values with the values retrieved from the stack outputs. COGNITO_DOMAIN="<ImageDescriptionStack.CognitoDomain>" REGION="<ImageDescriptionStack.Region>" USER_POOL_ID="<ImageDescriptionStack.UserPoolId>" CLIENT_ID="<ImageDescriptionStack.ClientId>" CLIENT_SECRET="COGNITO_CLIENT_SECRET" IDENTITY_POOL_ID="<ImageDescriptionStack.IdentityPoolId>" APP_URI="http://localhost:8501/" AUTHENTICATED_ROLE_ARN="<ImageDescriptionStack.AuthenticatedRoleArn>" GRAPHQL_ENDPOINT = "<ImageDescriptionStack.GraphQLEndpoint>" S3_INPUT_BUCKET = "<ImageDescriptionStack.InputsAssetsBucket>" S3_PROCESSED_BUCKET = "<ImageDescriptionStack.processedAssetsBucket>" COGNITO_CLIENT_SECRET is a secret value that can be retrieved from the Amazon Cognito console. Navigate to the user pool created by the stack. Under App integration, navigate to App clients and analytics, and choose App client name. Under App client information, choose Show client secret and copy the value of the client secret. Run client_app: streamlit run Home.py When the client application is up and running, it will open the browser 8501 port (http://localhost:8501/Home). Make sure your virtual environment is free from SSL certificate issues. If any SSL certificate issues are present, reinstall the CA certificates and OpenSSL package using the following command: brew reinstall ca-certificates openssl Test the solution To test the solution, we upload some sample images and generate descriptions in different applications. Complete the following steps: In the Streamlit UI, choose Log In and register the user for the first time After the user is registered and logged in, choose Image Description in the navigation pane. Upload multiple images and select the preferred model configuration ( Anthropic’s Claude 3.5 Sonnet or Anthropic’s Claude 3), then choose Submit. The uploaded image and the generated description are shown in the center pane. Set the language as French in the left pane and upload a new image, then choose Submit. The image description is generated in French. Clean up To avoid incurring unintended charges, delete the resources you created: Remove all data from the S3 buckets. Run the CDK destroy Delete the S3 buckets. Conclusion In this post, we discussed how to integrate Amazon Bedrock with Generative AI CDK Constructs. This solution enables the rapid development and deployment of cloud infrastructure tailored for an image description application by using the power of generative AI, specifically Anthropic’s Claude 3. The Generative AI CDK Constructs abstract the intricate complexities of infrastructure, thereby accelerating development timelines. The Generative AI CDK Constructs Library offers a comprehensive suite of constructs, empowering developers to augment and enhance generative AI capabilities within their applications, unlocking a myriad of possibilities for innovation. Try out the Generative AI CDK Constructs Library for your own use cases, and share your feedback and questions in the comments. About the Authors Dinesh Sajwan is a Senior Solutions Architect with the Prototyping Acceleration team at Amazon Web Services. He helps customers to drive innovation and accelerate their adoption of cutting-edge technologies, enabling them to stay ahead of the curve in an ever-evolving technological landscape. Beyond his professional endeavors, Dinesh enjoys a quiet life with his wife and three children. Justin Lewis leads the Emerging Technology Accelerator at AWS. Justin and his team help customers build with emerging technologies like generative AI by providing open source software examples to inspire their own innovation. He lives in the San Francisco Bay Area with his wife and son. Alain Krok is a Senior Solutions Architect with a passion for emerging technologies. His past experience includes designing and implementing IIoT solutions for the oil and gas industry and working on robotics projects. He enjoys pushing the limits and indulging in extreme sports when he is not designing software. Michael Tran is a Sr. Solutions Architect with Prototyping Acceleration team at Amazon Web Services. He provides technical guidance and helps customers innovate by showing the art of the possible on AWS. He specializes in building prototypes in the AI/ML space. You can contact him @Mike_Trann on Twitter.

Published: 2024-09-03T21:13:59











© Digital Event Horizon . All rights reserved.

Privacy | Terms of Use | Contact Us