POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 const axios = require('axios'); const fs = require('fs'); const path = require('path'); async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/try-on-diffusion"; const data = { "model_image": toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/model.png'), "cloth_image": "toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/cloth.jpg')", "category": "Upper body", "num_inference_steps": 35, "guidance_scale": 2, "seed": 12467, "base64": false }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


model_imageimage *

Input Image.


cloth_imageimage *

Cloth Image


categoryenum:str *

What type of clothes

Allowed values:


num_inference_stepsint ( default: 25 ) Affects Pricing

Number of denoising steps.

min : 20,

max : 100


guidance_scalefloat ( default: 2 )

Scale for classifier-free guidance

min : 1,

max : 25


seedint ( default: -1 )

Seed for image generation.

min : -1,

max : 999999999999999


base64boolean ( default: 1 )

Base64 encoding of the output image.

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Try-on Diffusion

TryOnDiffusion, a virtual try-on AI technique can realistically superimpose clothing onto a person's image despite variations in body shape and pose. By warping the garment image and blending it seamlessly with the person's image. It is designed to address two challenges in virtual try-on. One is preserving the garment or clothing details and the other one is adapting to body pose and shape changes.

Key Components of Try-on Diffusion

TryOnDiffusion uses a system called Parallel-UNet. The parallel-Unet has two parts: Person-UNet and Garment-UNet.

  1. Person-UNet analyzes a picture of a person with some added noise to capture detail.

  2. Garment-UNet focuses on the image of the clothing that needs be to overlayed on the person.

To make the clothes fit perfectly, TryOnDiffusion uses a technique called "implicit warping." This lets the garment-UNet adjust the clothing's shape on the fly, while the person-UNet seamlessly blends it onto the person's image. This two-UNet teamwork with implicit warping is what allows TryOnDiffusion to create such realistic virtual try-on experiences.

How to use Try-on Diffusion

  1. Input image: Provide an image of a person.

  2. Cloth Image: Upload a clothing image, preferably with a white or transparent background. Ensure the image contains only the clothing piece.

    a. Upper body: This involves overlaying clothing items such as t-shirts, tank tops, shirts, jackets, etc.,

    b. Lower body: This involves overlaying lower body clothing items like pants, trousers, skirts, shorts, etc

    c. Full Body: It involves overlaying a complete dress on a person's image.

Try-on Diffusion in Pixelflow Workflows

Try-on Diffusion is used in many virtual try-on workflows in Pixelflow. It is ideal for virtual try-on use cases in the e-commerce industry. Some of the workflows that utilize Try-On Diffusion include:

Full body virtual try-on: Superimposes any clothing (upper, lower and full body) onto a person’s image.