<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Awwal</title>
    <description>The latest articles on DEV Community by Awwal (@clouddev).</description>
    <link>https://dev.to/clouddev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1116007%2Fb4a06aa9-6f7e-42fe-8fb4-9bb31072516b.jpg</url>
      <title>DEV Community: Awwal</title>
      <link>https://dev.to/clouddev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/clouddev"/>
    <language>en</language>
    <item>
      <title>Deploying Text to Image App on ECS</title>
      <dc:creator>Awwal</dc:creator>
      <pubDate>Wed, 18 Sep 2024 20:17:19 +0000</pubDate>
      <link>https://dev.to/clouddev/deploying-text-to-image-app-on-ecs-4le5</link>
      <guid>https://dev.to/clouddev/deploying-text-to-image-app-on-ecs-4le5</guid>
      <description>&lt;p&gt;Lets start by creating a cluster. &lt;a href="https://us-east-1.console.aws.amazon.com/ecs/v2/create-cluster?region=us-east-1" rel="noopener noreferrer"&gt;Cluster&lt;/a&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to the Amazon ECS service page. 
Click clusters to create a new cluster. 
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2htjbbjda0g7j3oa2ctr.png" alt="ECS cluster" width="800" height="292"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Give your cluster what ever name you like&lt;br&gt;
We leave other options as default.&lt;br&gt;
Scroll to the bottom and click &lt;code&gt;create&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ewbrqyf21o9ld6b9024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ewbrqyf21o9ld6b9024.png" alt="Click create cluster" width="748" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating Task Definition
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8tabxikotqa8aajx4pl.png" alt="Task definition" width="800" height="237"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Click &lt;code&gt;task definitions&lt;/code&gt; on the left menu.&lt;br&gt;
On the task definition screen click on &lt;code&gt;create new task definition&lt;/code&gt;&lt;br&gt;
We will use an already built docker image on Amazon ECR (Elastic Container Registry) to save time. link to git page of the &lt;a href="https://github.com/build-on-aws/building-gen-ai-apps-with-found-models-workshop/blob/main/fm_poster_public_st.py" rel="noopener noreferrer"&gt;streamlit app code&lt;/a&gt;&lt;br&gt;
Under &lt;code&gt;Container 1&lt;/code&gt; use the public image URI &lt;code&gt;public.ecr.aws/o3s1z9h7/build-on-poster:latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Give your task definintion a name&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffu4bpn7mw90ftbmy8cqx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffu4bpn7mw90ftbmy8cqx.png" alt="Naming task definition" width="800" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leave the rest of the pages configuration as default, scroll to the bottom and click &lt;code&gt;Next&lt;/code&gt;.&lt;br&gt;
Under &lt;code&gt;Environment variables&lt;/code&gt; click &lt;code&gt;Add environment variable&lt;/code&gt; button.&lt;br&gt;
For Variable Name use &lt;br&gt;
&lt;code&gt;IMAGE_API&lt;/code&gt; and &lt;code&gt;TEXT_API&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Since we are utilizing code from someone else’s public container image, it is essential that our variable names align with those used in the code. Let’s create two variables: one to call our stable diffusion lambda function and the other for Text Summarization lambda function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0203vwcsyrv0aczh47it.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0203vwcsyrv0aczh47it.png" alt="Adding variables" width="593" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo0gi0qxyknow8dvxvd6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo0gi0qxyknow8dvxvd6.png" alt="Adding Variable names and values" width="727" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leave the remaining configurations as default, scroll to the bottom and click &lt;code&gt;Next&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Go to the IAM service page or scroll to &lt;code&gt;Task roles&lt;/code&gt; above &lt;code&gt;Task role&lt;/code&gt; click the link to the &lt;a href="https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-1#/roles" rel="noopener noreferrer"&gt;IAM console&lt;/a&gt; to navigate to the page (to grants permission to containers enabling them interact with other AWS services). &lt;br&gt;
Select create role on the IAM page&lt;br&gt;
Leave the defaults select elastic container registry for service below. Then scroll down click next&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvt4sbgkdibofut17fjxu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvt4sbgkdibofut17fjxu.png" alt="Creating IAM role" width="660" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under services select Elastic container registry&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdiw4q1h0v195ubgij8yg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdiw4q1h0v195ubgij8yg.png" alt="Navigating to Elastic container registry" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;Add permissions&lt;/code&gt; page search for and select AmazonECSTaskExecutionRolePolicy&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lndch7b7ywv7jv0u8pl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lndch7b7ywv7jv0u8pl.png" alt="Add permission page select AmazonECSTaskExecutionRolePolicy" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clear filter after selecting AmazonECSTaskExecutionRolePolicy.&lt;/p&gt;

&lt;p&gt;Search for lambd_fullAccess and select it. To grant ECS containers unrestricted access to our lambda functions.&lt;br&gt;
Click &lt;code&gt;Next&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovjfykcfiv79663inv3a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovjfykcfiv79663inv3a.png" alt="Attach policy AWSLambda_FullAccess" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give your role any name&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08mg3ej5nnbzhmtl9k1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08mg3ej5nnbzhmtl9k1x.png" alt="Naming Role" width="490" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll to the bottom click &lt;code&gt;create role&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After successful Role creation we move back to ECS Task definition and select our newly created role under &lt;code&gt;Task role&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdep880rbixrdfeedzxci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdep880rbixrdfeedzxci.png" alt="Select our recently created role" width="648" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can turn off cloudwatch &lt;code&gt;log collection&lt;/code&gt; under &lt;code&gt;Logging&lt;/code&gt; to save cost.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7szlakgkn9mgau0wpb5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7szlakgkn9mgau0wpb5.png" alt="turn of cloudwatch monitoring" width="702" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;code&gt;Next&lt;/code&gt; below to proceed&lt;/p&gt;

&lt;p&gt;Review&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzier8e8r535j07tdudua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzier8e8r535j07tdudua.png" alt="Review and create Task Definition" width="537" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2a886cswjg51wyjm0zp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2a886cswjg51wyjm0zp.png" alt="Review and create Task Definition continued" width="541" height="213"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;code&gt;create&lt;/code&gt; below&lt;/p&gt;

&lt;h3&gt;
  
  
  Running A Task with Our Task Definition
&lt;/h3&gt;

&lt;p&gt;On the left menu click cluster&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3wzlqwptt2d2f85ehad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3wzlqwptt2d2f85ehad.png" alt="Navigate to clusters" width="524" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the cluster you created earlier on the cluster page&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F38u8fcilz96emtiwj72r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F38u8fcilz96emtiwj72r.png" alt="Select recently created cluster" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;code&gt;Tasks&lt;/code&gt; tab as shown above, then click the &lt;code&gt;Run new task&lt;/code&gt; button&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq86ncxzp8hz1kao1z2yu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq86ncxzp8hz1kao1z2yu.png" alt="Running the Task" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the create task page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ozdzzqdkam0xnsbg78a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ozdzzqdkam0xnsbg78a.png" alt="Compute Configuration" width="707" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under &lt;code&gt;Compute configuration&lt;/code&gt;,  select &lt;code&gt;Launch type&lt;/code&gt; as your compute option to keep things simple. &lt;/p&gt;

&lt;p&gt;Under Deployments select the task definition we just created using the drop down as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv8plmfn4qw7pmqkhrze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv8plmfn4qw7pmqkhrze.png" alt="Selecting Task definintion" width="552" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under Networks&lt;br&gt;
We could either edit our default security group to allow inbound traffic or create a new one which does. We would create a new one. &lt;br&gt;
Select &lt;code&gt;create a new security group&lt;/code&gt; under security group &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw11wnu5xntbbtku4cl0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw11wnu5xntbbtku4cl0.png" alt="creating sec groups contd" width="717" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give your security group a name&lt;br&gt;
Give your security group any description.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqphh2p07r26twwi5e49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqphh2p07r26twwi5e49.png" alt="describing sec group" width="731" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For inbound rules under &lt;code&gt;Type&lt;/code&gt; select &lt;code&gt;HTTP&lt;/code&gt;&lt;br&gt;
For &lt;code&gt;Source&lt;/code&gt; select "Anywhere"&lt;br&gt;
Also ensure the &lt;code&gt;Public IP&lt;/code&gt; button is toggle On, so we know our IP address and connect to it. &lt;/p&gt;

&lt;p&gt;Leave &lt;code&gt;Task overrides&lt;/code&gt; as default&lt;/p&gt;

&lt;p&gt;Edit &lt;code&gt;container overrides&lt;/code&gt;&lt;br&gt;
We copy the output url of the lambda functions we created in the previous post to summarize text and the function to convert text to image as values of our container environment variables. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpz76wc4viem5kxol9oe6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpz76wc4viem5kxol9oe6.png" alt="Copy image to text func url" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the Function url of both functions and paste them into container IMAGE_API and TEXT_API values. &lt;br&gt;
One at a time                                                                                                                                                                                                                                      &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy407cv15asm7qz40vzhy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy407cv15asm7qz40vzhy.png" alt="Copy and use the function url text summary as environment variable" width="800" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use function url of diffusion function as value of &lt;code&gt;IMAGE_API&lt;/code&gt; and the function url of text_summary function as value of &lt;code&gt;TEXT_API&lt;/code&gt;.&lt;br&gt;
Click &lt;code&gt;save&lt;/code&gt; button to run task. After pasting function url your enviroment variables should like the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjctzg6vo6h0ns57r0w9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjctzg6vo6h0ns57r0w9.png" alt="dipiction on env var under container overrides" width="652" height="593"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Test your site&lt;br&gt;
Under &lt;code&gt;Tasks&lt;/code&gt; click your &lt;code&gt;task&lt;/code&gt; when it gets to the &lt;code&gt;Running&lt;/code&gt; state&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0tq3gqqniv2tw95zdk3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0tq3gqqniv2tw95zdk3w.png" alt="Click Tasks to test site" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll down on the task page&lt;br&gt;
Under Configuration setting &lt;br&gt;
Click the public url&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwurxfg8k9a2ywu6b664h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwurxfg8k9a2ywu6b664h.png" alt="clicking public url" width="800" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It displays loads our site on a new page&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8j2mucv6ik48gc9sfsbh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8j2mucv6ik48gc9sfsbh.png" alt="dipiction of our site" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets test it&lt;br&gt;
paste or write an article to be summarized and converted to text&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74b7bg6h5nu9ttzqk2qr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74b7bg6h5nu9ttzqk2qr.png" alt="cloud house" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use an article &lt;a href="https://community.aws" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fon5wnbq3we76fkihamvt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fon5wnbq3we76fkihamvt.png" alt="image from text from aws community article" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Comprehensive Tutorial: Deploying SageMaker Endpoint on Lambda for AI-powered Text Summarization and Image Generation</title>
      <dc:creator>Awwal</dc:creator>
      <pubDate>Thu, 13 Jul 2023 10:14:35 +0000</pubDate>
      <link>https://dev.to/clouddev/comprehensive-tutorial-deploying-sagemaker-endpoint-on-lambda-for-ai-powered-text-summarization-and-image-generation-3c4c</link>
      <guid>https://dev.to/clouddev/comprehensive-tutorial-deploying-sagemaker-endpoint-on-lambda-for-ai-powered-text-summarization-and-image-generation-3c4c</guid>
      <description>&lt;h2&gt;
  
  
  Deploying Sagemaker Endpoint on Lambda
&lt;/h2&gt;

&lt;p&gt;To deploy a SageMaker endpoint on AWS Lambda, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Log in to your Amazon Web Services (AWS) account and search for "Lambda" in the search bar. Click on the "Lambda" service to access the Lambda console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the Lambda console, click on the "Create function" button to create a new function.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7afnz4b2hjzliid055o5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7afnz4b2hjzliid055o5.png" alt="Lambda console"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create two functions as follows:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;a. Function 1: This function will interact with your stable diffusion endpoint by sending text and receiving image outputs. You can choose any name for this function, such as "create_image_func".&lt;/p&gt;

&lt;p&gt;b. Function 2: This function will interact with the flan-T5 XL model endpoint to produce a summarized text of the initial input text. Name this function "create_summary_func" or any other name you prefer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the "Create function" page, leave the defaults as they are.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under the "Basic information" section, provide a name for your function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, select the runtime for your function. In this case, choose Python 3.9.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Proceed with the remaining steps and configurations required to complete the creation of your Lambda function. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kd2447nwmb9vmnxddam.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kd2447nwmb9vmnxddam.png" alt="Image description creating lambda function"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Creating an IAM Role for Lambda
&lt;/h2&gt;

&lt;p&gt;To allow the Lambda function to interact with other services, you need to create an IAM role. Follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the AWS Identity and Access Management (IAM) page. You can find it in the left navigation pane under "Access Management." Click on "Roles" to access the roles page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the roles page, click the "Create role" button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leave the Trusted entity type as "AWS service" and select "Lambda" under common use cases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the "Next" button.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdi7rf7vyqs30h10yeiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmdi7rf7vyqs30h10yeiv.png" alt="Image description select trusted entity"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the next page, add permissions to the role. Perform the following steps:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;a. In the search bar, type "SageMakerFullAccess" and add the "SageMakerFullAccess" policy.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmq1czthijdozvcw7tp1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmq1czthijdozvcw7tp1a.png" alt="Image description: Add permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. Click "Clear filters."&lt;/p&gt;

&lt;p&gt;c. Search for "S3FullAccess" and select the "S3FullAccess" policy from the results.&lt;/p&gt;

&lt;p&gt;d. Click "Clear filters."&lt;/p&gt;

&lt;p&gt;e. Search for "IAMFullAccess" and select the "IAMFullAccess" policy.&lt;/p&gt;

&lt;p&gt;f. Search for "AWSLambdaBasicExecutionRole" and select the "AWSLambdaBasicExecutionRole" policy.&lt;/p&gt;

&lt;p&gt;g. Click the "Next" button.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Give the role a name in the "Role name" text box under Role details.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsonw8fy6sg6bol5auh6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsonw8fy6sg6bol5auh6e.png" alt="Image description role name"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Review the policies you have added to the role.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8aauofeb7qs02u50ha21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8aauofeb7qs02u50ha21.png" alt="Image description review"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the "Create role" button to create the role.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You will have successfully created an IAM role to be used by your Lambda function for interacting with other services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Returning to the Lambda Function
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Scroll to the bottom of the page and select the "Enable function URL" option. This will generate a unique URL for your Lambda function to invoke it later.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnivkfnfsdwjwuwfdw08y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnivkfnfsdwjwuwfdw08y.png" alt="Image description: Enabling function URL"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the "Create function" button located below.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4lz66tdhmcea13ytupr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4lz66tdhmcea13ytupr.png" alt="Image description: Create function button"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will be redirected to the Lambda function page. On the left navigation pane, click on the "Code" tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the "Code" tab, locate and click on &lt;code&gt;lambda_function.py&lt;/code&gt; to open the file.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9s7byleo3su0zowkts0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9s7byleo3su0zowkts0.png" alt="Image Click Lambda_function.py"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Erase the existing code in &lt;code&gt;lambda_function.py&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the code from the provided GitHub link &lt;a href="https://github.com/build-on-aws/building-gen-ai-apps-with-found-models-workshop/blob/main/fm_create_image.py" rel="noopener noreferrer"&gt;GitHub link&lt;/a&gt; and paste it into the &lt;code&gt;lambda_function.py&lt;/code&gt; file.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65xokj749y90ynrh9y6j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65xokj749y90ynrh9y6j.png" alt="Image description: Pasting code into lambda_function.py"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import json
import boto3

def parse_response(query_response):
    """Parse response and return generated image and the prompt"""

    response_dict = json.loads(query_response)
    return response_dict["generated_image"], response_dict["prompt"]


def lambda_handler(event, context):

    client = boto3.client('sagemaker-runtime')

    data_string = event["body"]
    text = json.loads(data_string)["text"]

    encoded_text = text.encode("utf-8")


    CONTENT_TYPE = 'application/x-text'
    endpoint_name = # "YOUR_MODEL_ENDPOINT" # Replace with your model endpoint

    response = client.invoke_endpoint(EndpointName=endpoint_name, 
                                  ContentType=CONTENT_TYPE, 
                                  Body=encoded_text)

    print(response)

    response_payload = json.loads(response['Body'].read().decode("utf-8"))
    print(text)

    resp = json.dumps(response_payload)

    return {
        'statusCode': 200,
        'body': resp
    }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once you have completed these steps, you will have returned to the Lambda function and updated the code with the new content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Copying the Stable Diffusion Endpoint Name
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the Amazon SageMaker console to find the name of the stable diffusion endpoint you want to use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scroll down to "Inference" on the left menu and click on "Endpoints".&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjjgfdrwk267fcq3ozh0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjjgfdrwk267fcq3ozh0.png" alt="Image SageMaker console endpoint nav pane"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the endpoint name of the stable diffusion jumpstart (pretrained) model that was deployed in the previous tutorial.&lt;br&gt;
(the image highlights flan 5 but copy the name of the stable diffusion image function)&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl35s1x7frd1eu5sd65vc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl35s1x7frd1eu5sd65vc.png" alt="Image description coping highlighted endpoint name"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After Copying the endpoint name from the SageMaker console. You will need to paste it into your &lt;code&gt;create_image_func&lt;/code&gt; code around line 22.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65xokj749y90ynrh9y6j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65xokj749y90ynrh9y6j.png" alt="Image description: Editing Model Endpoint in Code"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the "Deploy" button to save the changes in the function.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwebdtffbkf7ezhoq70cs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwebdtffbkf7ezhoq70cs.png" alt="Image description deploy and test buttons"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Testing the Function
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click the "Test" button to create a test for the function.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx1tern25oq19xb0li3a3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx1tern25oq19xb0li3a3.png" alt="Image description: Test button"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give your test a name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Paste the following JSON into the JSON box for the test:&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;{&lt;br&gt;
  "body": "{\"text\":\"clouds over the ocean\"}"&lt;br&gt;
}&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;![Image description: Configuring test](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk26j973i9aqx1o4en16.png)

4. Click the "Save" button to create the test event.

5. Click the "Deploy" button to save the code changes in the function and then click the "Test" button to run the test. Note that the test may fail due to a timeout error in the function. We will address this issue in the next steps.

## Configuring Timeout

1. Under the Configurations tab, click on "General configurations".

2. Click the "Edit" button.
![Image description: Edit General Configurations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puw5qi9z7w4u04mwpyft.png)

3. Increase the timeout value to a higher value to prevent the timeout error. Adjust it according to the requirements of your function.
![Image description: Increase Timeout](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jbixh8ky2iw7cenka0p.png)

4. Click "Save" to save the changes.


## Testing the Function Again

1. Proceed to test the function by clicking the "Test" button either on the "Test" tab or the "Code" tab. The output of the test should now run successfully without the timeout error.
![Image description: Image Test output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh8c0xhaesn53kkvdq30.png)

## Configuring CORS (Cross-Origin Resource Sharing)

If your function doesn't have a URL. Under "Configuration", follow these additional steps:

1. Select "Function URL" from the left menu.

2. Click on "Create Function URL".

3. Under Additional Settings, select "Configure cross-origin resource sharing (CORS)".

4. Scroll down and click the "Save" button.

The Function URL should now appear under "Configuration".

Once you have completed these steps, you will have copied the stable diffusion endpoint name, updated the code in the Lambda function, tested the function, configured the timeout, and configured CORS.

## Creating the Summary Function

1. On the Lambda landing page, click on "Create function" to start creating a new function.
![Image description creation lambda function for flan model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce1iqhlyvjozystzorvf.png)

2. Repeat the steps used to create the image function (create_image_func) above to create the summary function. Give the function a name of your choice.
![Image description: Creating a Lambda function for the Flan model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce1iqhlyvjozystzorvf.png)

3. Under Permissions, select the execution role that was created for the Lambda function.
![Image description: Selecting the Lambda execution role](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6irnuvkjgin0fuh3hpe4.png)

4. Under "Advanced settings," select "Enable function URL" to enable invoking the function using a URL. Also, select "Configure CORS" to configure cross-origin resource sharing for the function.
![Image description: Enabling function URL and configuring CORS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97dnwxfw92wkkl0syslu.png)

5. In the Code section, click on `lambda_function.py` in the left menu. Replace the code in `lambda_function.py` with the code from the provided GitHub [link](https://github.com/build-on-aws/building-gen-ai-apps-with-found-models-workshop/blob/main/fm_create_summary.py) or below.
![Image description: Replacing the code with the Flan Lambda code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wz8amvahhl3vc9mx9adb.png)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;import json&lt;br&gt;
import boto3&lt;/p&gt;

&lt;p&gt;def lambda_handler(event, context):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client = boto3.client('sagemaker-runtime')

data_string = event["body"]
text = json.loads(data_string)["text"]

query = 'write a summary'

prompt = f'{text}\n{query}'

MAX_LENGTH = 150 # 256
NUM_RETURN_SEQUENCES = 1
TOP_K = 0
TOP_P = 0.7
DO_SAMPLE = True 
CONTENT_TYPE = 'application/json'


payload = {'text_inputs': prompt, 
      'max_length': MAX_LENGTH, 
      'num_return_sequences': NUM_RETURN_SEQUENCES,
      'top_k': TOP_K,
      'top_p': TOP_P,
      'do_sample': DO_SAMPLE}


payload = json.dumps(payload).encode('utf-8')

endpoint_name = # "YOUR_MODEL_ENDPOINT" # Replace with your model endpoint

response = client.invoke_endpoint(EndpointName=endpoint_name, 
                              ContentType=CONTENT_TYPE, 
                              Body=payload)
model_predictions = json.loads(response['Body'].read())
generated_text = model_predictions['generated_texts'][0]
print(f'Response: {generated_text}')

resp = json.dumps({"text":generated_text})


return {
    'statusCode': 200,
    'body': resp
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

6. Replace line 33 in the code with the endpoint name of your Text Model endpoint. To find the endpoint name, follow these steps:

   a. Go to the SageMaker console.
![Image Sagemaker console endpoint nav pane](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njjgfdrwk267fcq3ozh0.png)

   b. Scroll down to "Inference" on the left menu and click on "Endpoints".

   c. Copy the endpoint name of the Text-to-text jumpstart (pretrained) model that was deployed in the previous tutorial.
![Image description coping highlighted endpoint name from SageMaker console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l35s1x7frd1eu5sd65vc.png)

7. After pasting the endpoint name into your code, it should look like the code snippet provided.
![Image description: Replacing the endpoint name in the code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pus6vgs8kje60hbt2p0a.png)

By following these steps, you will have created the summary function in AWS Lambda, updated the code with the provided GitHub link, and replaced the endpoint name with the one from your Text Model endpoint in SageMaker.


## Testing the Function

1. Click the blue "Test" button above to create a new test function.
![Image description: Test button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1tern25oq19xb0li3a3.png)

2. Give your test a name.

3. Replace the default test values with the following JSON text (you can change the text to anything you want to summarize):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;{&lt;br&gt;
  "body": "{\"text\":\"The internet fundamentally changed things. We weren’t only sending messages back and forth anymore; we were visiting digital locations called websites. These websites needed a place to store their text and images, and eventually they started doing more than displaying stored information; they began to facilitate sales, coordinate deliveries, and much more. All the storage and computing for these countless websites had to come from somewhere, and that somewhere was a server.\"}"&lt;br&gt;
}&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;![Image description: flan-5 test event configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xj6u5iw3y7v4kz6rxb9w.png)


4. Click the "Save" button to create the test event.

## Deploying and Testing the Code

1. Click the "Deploy" button to save the code changes.

2. Click the "Test" button to test the function with the created test event.
![Image description: Deploying and testing the function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8qb5s8jiudiarpspjcpr.png)

Additionally, to avoid timeout errors, you can increase the timeout value to about 30 seconds. Configure the timeout as shown in the previous instructions.

After testing the function, the expected result should indicate successful execution, similar to the following:
![Image description: Successful execution of the Flan test](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8hao0sjvscxk8a7z4u1f.png)

Please note that the actual output may vary based on the specifics of your Lambda function and the code you have implemented.

If you encounter a timeout error, it may be due to various factors such as the complexity of the task or insufficient resources. Increasing the timeout and configuring it appropriately can help resolve such issues.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>machinelearning</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Comprehensive Guide: Deploying Prebuilt Models using Amazon SageMaker</title>
      <dc:creator>Awwal</dc:creator>
      <pubDate>Thu, 13 Jul 2023 10:13:53 +0000</pubDate>
      <link>https://dev.to/clouddev/comprehensive-guide-deploying-prebuilt-models-using-amazon-sagemaker-1ila</link>
      <guid>https://dev.to/clouddev/comprehensive-guide-deploying-prebuilt-models-using-amazon-sagemaker-1ila</guid>
      <description>&lt;h2&gt;
  
  
  Objective
&lt;/h2&gt;

&lt;p&gt;The objective of this article is to provide a step-by-step guide on deploying an end-to-end machine learning model using a prebuilt AWS Jump Start model. The focus will be on leveraging low-code and no-code options provided by AWS. The article covers various aspects of the deployment process, including the creation of a SageMaker domain, deploying Jump Start models to SageMaker Inference Endpoint, and interacting with the deployed model in an open SageMaker notebook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Overview:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9jnz9idD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34eq9ljulii8osi0g447.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9jnz9idD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34eq9ljulii8osi0g447.png" alt="Image description: Architecture diagram" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://catalog.workshops.aws/building-gen-ai-apps-with-found-models/en-US"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is part of a three-part series that aims to demonstrate how to deploy machine learning models using AWS's low-code and no-code options. Specifically, this article focuses on deploying a prebuilt AWS Jump Start model and hosting it on a Streamlit server.&lt;/p&gt;

&lt;p&gt;In this part of the article series, you will learn the following based on SageMaker:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to create a SageMaker domain.&lt;/li&gt;
&lt;li&gt;How to deploy Jump Start models to the SageMaker Inference Endpoint.&lt;/li&gt;
&lt;li&gt;How to interact with the deployed model in an open SageMaker notebook (optional).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Assumptions: You are familiar with navigating the AWS console and have an AWS account with SageMaker Full Access. If you don't have an account, you can sign up for one using the following &lt;a href="https://docs.aws.amazon.com/sagemaker/latest/dg/gs-set-up.html"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost:&lt;/strong&gt;&lt;br&gt;
Please note that the labs from the workshop page costs around $10 if completed within 2 hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Get Free Access SageMaker (Optional):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Utilize the AWS Free Tier.&lt;/li&gt;
&lt;li&gt;For students, consider joining the AWS DeepRacer Challenge or AWS Educate.&lt;/li&gt;
&lt;li&gt;Participate in AWS events to receive free credits.&lt;/li&gt;
&lt;li&gt;Attend AWS workshops to gain access to temporary accounts.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Jump Start
&lt;/h2&gt;

&lt;p&gt;SageMaker Jump Start is a repository of pretrained end-to-end models that serve as baseline models for building upon. This low-code, no-code solution allows you to quickly leverage ready-to-use models for various use cases, including tabular regression, classification, and state-of-the-art models from Amazon and its partners like Stability AI, Cohere, AI21, and AlexTM. You can also enhance these models by performing additional training on them. Examples of JumpStart models can be found on the JumpStart landing page, which showcases available end-to-end machine learning solutions, pretrained models, and example notebooks.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C_8NQuoD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b310as55ltyjna80exqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C_8NQuoD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b310as55ltyjna80exqt.png" alt="Image description: Jump Start model" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Domain
&lt;/h2&gt;

&lt;p&gt;In SageMaker, a domain refers to a logical grouping of files and resources within a workspace. It provides a structured environment for managing machine learning deployments. Each domain in SageMaker consists of a collection of resources specifically tailored to facilitate machine learning workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model Endpoint
&lt;/h2&gt;

&lt;p&gt;A SageMaker Endpoint is an API that allows you to access a model for inference. It serves as the interface for making predictions using your trained model. When deploying a model, SageMaker provides the necessary infrastructure based on your chosen deployment type. For prebuilt models, the infrastructure specifications are already defined. However, if you are creating your own model, you will need to specify the infrastructure type required to host your model. SageMaker leverages Docker containers for hosting the models, ensuring scalability and flexibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model Parsing
&lt;/h2&gt;

&lt;p&gt;Model parsing is the process of interpreting and analyzing the structure and content of a model. It involves understanding the input and output formats, data transformations, and any pre- or post-processing steps required. Accurate model parsing is essential for seamless integration and efficient utilization of the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stable Diffusion
&lt;/h2&gt;

&lt;p&gt;Stable Diffusion is a text-to-image model that utilizes generative modeling techniques to generate photorealistic images based on text prompts. It offers a powerful solution for transforming textual descriptions into visually compelling images. To learn more about Stable Diffusion and its capabilities, refer to this &lt;a href="https://aws.amazon.com/blogs/machine-learning/generate-images-from-text-with-the-stable-diffusion-model-on-amazon-sagemaker-jumpstart/"&gt;blog&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a SageMaker Domain
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the AWS Management Console and enter "Sagemaker" in the search bar. Click on "Amazon SageMaker" to access the SageMaker console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the left navigation pane, click on "Domains" to go to the SageMaker Domain configuration page.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Dh4Ba0hN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z29j630puus72bna5hjo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Dh4Ba0hN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z29j630puus72bna5hjo.png" alt="Image description: Navigating to the Domains page" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new domain by clicking on the "Create domain" button. Then, click on "Quick setup" (default) for easier domain configuration.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KzUxhCkS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qqlseznlqhbedf506x1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KzUxhCkS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qqlseznlqhbedf506x1.png" alt="Image description: Creating a new domain" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the "Quick Setup" section, leave the default settings as they are.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a name for your domain in the "Domain name" text box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under "User profile," you can enter a friendly user name or use the default name provided.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the "Execution role" section, click on the "Create new role" option.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KZPKfey3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozoipc21w5zri3j3695c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KZPKfey3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozoipc21w5zri3j3695c.png" alt="Image description: Creating a new execution role" width="725" height="310"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the "Create an Execution role" dialog, select "Any S3 bucket" and leave the defaults as they are. Then, click the "Create role" button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p0GaKx4v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6rbmsjs3s4h2411gxva.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p0GaKx4v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6rbmsjs3s4h2411gxva.png" alt="Image description: Creating a new execution role" width="778" height="510"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You'll see a message confirming the successful creation of the IAM role.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scroll to the bottom of the page and click the "Submit" button to create the domain.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BQF3yt-4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hj6qezehqpntyyu1sl7d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BQF3yt-4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hj6qezehqpntyyu1sl7d.png" alt="Image description: Submitting the domain creation" width="765" height="532"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wait for the domain creation process to complete. Once the domain is created, click on the domain you just created.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these steps, you will be able to create a SageMaker domain and proceed with configuring and utilizing it for your machine learning workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Launching SageMaker Studio
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the SageMaker Domain page, click on the newly created domain. This will redirect you to the domain details page.&lt;br&gt;
Image description: Domain details page&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RSs0ivja--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/balwume91l7mlh1wsd4u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RSs0ivja--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/balwume91l7mlh1wsd4u.png" alt="Image description domain details" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Look for the "User profiles" section on the page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Under "User profiles," click on the "Launch" button located on the right side of the page.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;From the dropdown list that appears, select "Studio." This will launch a SageMaker Studio notebook.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qOQc6ZKN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7zdj369zxsyhz78nf9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qOQc6ZKN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7zdj369zxsyhz78nf9u.png" alt="Image description: Launching SageMaker Studio" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please note that launching the SageMaker Studio may take some time to complete.&lt;/p&gt;

&lt;p&gt;Once SageMaker Studio has launched successfully, you will be redirected to the SageMaker Studio landing page, as shown below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ry-XT48e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gw9c9c787yeggbu2us7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ry-XT48e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gw9c9c787yeggbu2us7a.png" alt="Image description: SageMaker Studio landing page" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying JumpStart Models
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the SageMaker Studio page, navigate to the left navigation pane and click on "SageMaker JumpStart" to expand the menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Models, Notebooks, Solutions" to access the JumpStart models.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b4xXDobz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lq102nfn8igbx18dxrfp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b4xXDobz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lq102nfn8igbx18dxrfp.png" alt="Image description: Selecting JumpStart Models" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the next screen, select "Stable Diffusion 2.1 base" from the available models, as shown in the image below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GqIDXloi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0878z74qps9xg52j70li.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GqIDXloi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0878z74qps9xg52j70li.png" alt="Image description: Selecting Stable Diffusion model" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the Stable Diffusion details page, click the "Deploy" button to deploy the model. This will create an endpoint that can be used to interact with the model. The deployment process will also launch an instance to host the endpoint.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hqRAC0iZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7o0e4a8qsa51opvoblkh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hqRAC0iZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7o0e4a8qsa51opvoblkh.png" alt="Image description: Deploying the model" width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Deploy" to initiate the deployment process. Please note that the deployment may take some time to complete.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these steps, you will be able to deploy the JumpStart model, specifically the Stable Diffusion 2.1 base model. Once deployed, you will have an endpoint that can be used to interact with the model for inference tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Model's Notebook
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Once the endpoint is deployed and in service. You can click "Open Notebook" button to interact with the model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After starting the model's new notebook, please allow some time for the notebook to initialize.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scroll down to the setup section and run the first cells as indicated in the notebook.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--njceDGtY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ihwdbj3yxuqe2kymymu7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--njceDGtY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ihwdbj3yxuqe2kymymu7.png" alt="Image description: run cells" width="800" height="318"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please note: Running the first cells and testing the model on a notebook are optional and can be done if desired.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying the Flan-T5 XL Model
&lt;/h2&gt;

&lt;p&gt;To deploy the Flan model, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Search for "Flan-t5 xl" in the available models.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the "Flan-t5 xl" model to access the Flan-t5 xl model details page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the Flan model details page, click on the "Deploy" button to initiate the deployment process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The flan-t5 xl model is deployed just as the stable diffusion model was deployed.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IrPhJvWj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fym3yhyihma89by8pqt0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IrPhJvWj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fym3yhyihma89by8pqt0.png" alt="Image description: Deploying the Flan model" width="776" height="423"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these steps, you will be able to set up the model's notebook, run the necessary setup cells, and deploy the Flan model for further usage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Viewing Endpoints
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the SageMaker homepage, navigate to the "Inference" section and select "Endpoints". This will take you to the page displaying all the endpoints.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4syX4ArO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bj143jgk1gzhnawmrx4k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4syX4ArO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bj143jgk1gzhnawmrx4k.png" alt="Image description: Selecting Endpoints" width="537" height="587"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The endpoints page provides an overview of the endpoints that have been created. This will be useful in Part 2 of this tutorial.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mERRPYEa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha8u5r1g8ofxj8srf8dx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mERRPYEa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha8u5r1g8ofxj8srf8dx.png" alt="Image description: endpoints" width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these steps, you will be able to navigate to the endpoints page on the SageMaker homepage, which will be useful for the &lt;a href="https://dev.to/clouddev/comprehensive-tutorial-deploying-sagemaker-endpoint-on-lambda-for-ai-powered-text-summarization-and-image-generation-29f9-temp-slug-4083371?preview=8ee8d72f11d82a9b5a1c0c93baae8c62f89dd578bd54cd3695e010eb20d43b198c4def7c7bc795e4faa3cc15da1306eb7b12f0f0a480476475ff0b3f"&gt;subsequent parts&lt;/a&gt; of this tutorial.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>machinelearning</category>
      <category>stablediffusion</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
