[ad_1]
Have you ever wished you might shortly visualize how a brand new outfit would possibly look on you earlier than making a purchase order? Or how a chunk of furnishings would look in your front room? Today, we’re excited to introduce a brand new digital try-on functionality in Amazon Nova Canvas that makes this attainable. In addition, we’re including eight new fashion choices for improved fashion consistency for text-to-image based mostly fashion prompting. These options increase Nova Canvas AI-powered picture technology capabilities making it simpler than ever to create life like product visualizations and stylized photos that may improve the expertise of your clients.
Let’s take a fast take a look at how one can begin utilizing these right this moment.
Getting began
The very first thing is to just remember to have entry to the Nova Canvas mannequin by way of the same old means. Head to the Amazon Bedrock console, select Model entry and allow Amazon Nova Canvas on your account ensuring that you choose the suitable areas on your workloads. If you have already got entry and have been utilizing Nova Canvas, you can begin utilizing the brand new options instantly as they’re robotically accessible to you.
Virtual try-on
The first thrilling new characteristic is digital try-on. With this, you’ll be able to add two footage and ask Amazon Nova Canvas to place them along with life like outcomes. These might be footage of attire, equipment, residence furnishings, and another merchandise together with clothes. For instance, you’ll be able to present the image of a human because the supply picture and the image of a garment because the reference picture, and Amazon Nova Canvas will create a brand new picture with that very same particular person sporting the garment. Let’s do this out!
My start line is to pick two photos. I picked certainly one of myself in a pose that I feel would work nicely for a garments swap and an image of an AWS-branded hoodie.
Note that Nova Canvas accepts photos containing a most of 4.1M pixels – the equal of two,048 x 2,048 – so you should definitely scale your photos to suit these constraints if mandatory. Also, should you’d wish to run the Python code featured on this article, guarantee you might have Python 3.9 or later put in in addition to the Python packages boto3 and pillow.
To apply the hoodie to my photograph, I exploit the Amazon Bedrock Runtime invoke API. You can discover full particulars on the request and response constructions for this API within the Amazon Nova User Guide. The code is easy, requiring only some inference parameters. I exploit the brand new taskType of "VIRTUAL_TRY_ON". I then specify the specified settings, together with each the supply picture and reference picture, utilizing the virtualTryOnParams object to set a number of required parameters. Note that each photos have to be transformed to Base64 strings.
import base64
def load_image_as_base64(image_path):
"""Helper operate for getting ready picture information."""
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.learn()).decode("utf-8")
inference_params = {
"taskType": "VIRTUAL_TRY_ON",
"virtualTryOnParams": {
"supplyImage": load_image_as_base64("particular person.png"),
"referenceImage": load_image_as_base64("aws-hoodie.jpg"),
"maskType": "GARMENT",
"garmentBasedMask": {"garmentClass": "UPPER_BODY"}
}
}
Nova Canvas makes use of masking to govern photos. This is a way that enables AI picture technology to give attention to particular areas or areas of a picture whereas preserving others, just like utilizing painter’s tape to guard areas you don’t need to paint.
You can use three completely different masking modes, which you’ll select by setting maskType to the right worth. In this case, I’m utilizing "GARMENT", which requires me to specify which a part of the physique I need to be masked. I’m utilizing "UPPER_BODY" , however you need to use others equivalent to "LOWER_BODY", "FULL_BODY", or "FOOTWEAR" if you wish to particularly goal the ft. Refer to the documentation for a full listing of choices.
I then name the invoke API, passing in these inference arguments and saving the generated picture to disk.
# Note: The inference_params variable from above is referenced beneath.
import base64
import io
import json
import boto3
from PIL import Image
# Create the Bedrock Runtime shopper.
bedrock = boto3.shopper(service_name="bedrock-runtime", region_name="us-east-1")
# Prepare the invocation payload.
body_json = json.dumps(inference_params, indent=2)
# Invoke Nova Canvas.
response = bedrock.invoke_model(
physique=body_json,
modelId="amazon.nova-canvas-v1:0",
settle for="software/json",
contentType="software/json"
)
# Extract the photographs from the response.
response_body_json = json.masses(response.get("physique").learn())
photos = response_body_json.get("photos", [])
# Check for errors.
if response_body_json.get("error"):
print(response_body_json.get("error"))
# Decode every picture from Base64 and save as a PNG file.
for index, image_base64 in enumerate(photos):
image_bytes = base64.b64decode(image_base64)
image_buffer = io.BytesIO(image_bytes)
picture = Image.open(image_buffer)
picture.save(f"image_{index}.png")
I get a really thrilling outcome!
And similar to that, I’m the proud wearer of an AWS-branded hoodie!
In addition to the "GARMENT" masks kind, you may as well use the "PROMPT" or "IMAGE" masks. With "PROMPT", you additionally present the supply and reference photos, nonetheless, you present a pure language immediate to specify which a part of the supply picture you’d like to get replaced. This is just like how the "INPAINTING" and "OUTPAINTING" duties work in Nova Canvas. If you need to use your personal picture masks, you then select the "IMAGE" masks kind and supply a black-and-white picture for use as masks, the place black signifies the pixels that you just need to get replaced on the supply picture, and white those you need to protect.
This functionality is particularly helpful for retailers. They can use it to assist their clients make higher buying selections by seeing how merchandise look earlier than shopping for.
Using fashion choices
I’ve all the time questioned what I might appear like as an anime superhero. Previously, I may use Nova Canvas to govern a picture of myself, however I must depend on my good immediate engineering expertise to get it proper. Now, Nova Canvas comes with pre-trained types that you may apply to your photos to get high-quality outcomes that observe the inventive fashion of your selection. There are eight accessible types together with 3D animated household movie, design sketch, flat vector illustration, graphic novel, maximalism, midcentury retro, photorealism, and gentle digital portray.
Applying them is as easy as passing in an additional parameter to the Nova Canvas API. Let’s strive an instance.
I need to generate a picture of an AWS superhero utilizing the 3D animated household movie fashion. To do that, I specify a taskType of "TEXT_IMAGE" and a textual contentToImageParams object containing two parameters: textual content and fashion. The textual content parameter comprises the immediate describing the picture I need to create which on this case is “a superhero in a yellow outfit with a big AWS logo and a cape.” The fashion parameter specifies one of many predefined fashion values. I’m utilizing "3D_ANIMATED_FAMILY_FILM" right here, however you will discover the complete listing within the Nova Canvas User Guide.
inference_params = {
"taskType": "TEXT_IMAGE",
"textual contentToImageParams": {
"textual content": "a superhero in a yellow outfit with a giant AWS brand and a cape.",
"fashion": "3D_ANIMATED_FAMILY_FILM",
},
"imageGenerationConfig": {
"width": 1280,
"top": 720,
"seed": 321
}
}
Then, I name the invoke API simply as I did within the earlier instance. (The code has been omitted right here for brevity.) And the outcome? Well, I’ll allow you to choose for your self, however I’ve to say I’m fairly happy with the AWS superhero sporting my favourite colour following the 3D animated household movie fashion precisely as I envisioned.
What’s actually cool is that I can preserve my code and immediate precisely the identical and solely change the worth of the fashion attribute to generate a picture in a totally completely different fashion. Let’s do this out. I set fashion to PHOTOREALISM.
inference_params = {
"taskType": "TEXT_IMAGE",
"textual contentToImageParams": {
"textual content": "a superhero in a yellow outfit with a giant AWS brand and a cape.",
"fashion": "PHOTOREALISM",
},
"imageGenerationConfig": {
"width": 1280,
"top": 720,
"seed": 7
}
}
And the result’s spectacular! A photorealistic superhero precisely as I described, which is a far departure from the earlier generated cartoon and all it took was altering one line of code.
Things to know
Availability – Virtual try-on and elegance choices can be found in Amazon Nova Canvas within the US East (N. Virginia), Asia Pacific (Tokyo), and Europe (Ireland). Current customers of Amazon Nova Canvas can instantly use these capabilities with out migrating to a brand new mannequin.
Pricing – See the Amazon Bedrock pricing web page for particulars on prices.
For a preview of digital try-on of clothes, you’ll be able to go to nova.amazon.com the place you’ll be able to add a picture of an individual and a garment to visualise completely different clothes combos.
If you might be able to get began, please try the Nova Canvas User Guide or go to the AWS Console.





