Development Documents
AI Model API
IDM-VTON AI Model Usage Guide
11min
introduction this document describes how to use the aonweb library to call the idm vton ai model this model is used for virtual try on, allowing specified clothing images to be applied to human images prerequisites node js environment aonweb library installed valid aonet appid basic usage 1\ import required modules import { ai, aioptions } from 'aonweb'; 2\ initialize ai instance const ai options = new aioptions({ appid 'your app id here', dev mode true }); const aonweb = new ai(ai options); 3\ prepare input data example const data = { input { "crop" false, "seed" 42, "steps" 30, "category" "upper body", "force dc" false, "garm img" "https //replicate delivery/pbxt/kgwtlzyfx5auu3gc5gmikud5nnptglimlluwx160g4z99yjo/sweater webp", "mask img" "https //replicate delivery/pbxt/knadkqnn0h1ddf5cnk7irsskfnjrk9kyriqlcc5gbcy8gppa/replicate prediction wfj8g6sgmxrgp0cf1gnv7btfh8 jpg", "human img" "https //replicate delivery/pbxt/kgwtlhcmvdagrrcvzzjbuoznj8espqinaijs3emghryuhmw4/kakaotalk photo 2024 04 04 21 44 45 png", "garment des" "cute pink top" } }; 4\ call the ai model const price = 8; // cost of the ai call try { const response = await aonweb prediction("/predictions/ai/idm vton\@cuuupid", data, price); // handle response console log("idm vton response ", response); } catch (error) { // error handling console error("error generate ", error); } parameter description seed number,random seed for generating reproducible results steps number,provide the steps required for model inference garm img string,garment, should match the category, can be a product image or even a photo of someone human img string,model, if this is not 3 4 check crop garment des string,description of garment e g short sleeve round neck t shirt crop boolean,use cropping? (check this if your image is not 3 4) category string,category of garment force dc boolean,use the dresscode version of idm vton (this is default false, except if category=dresses) mask img string,mask image, optional (but faster) handling the response the model's response will contain the processed results depending on your application's needs, you may need to parse and use specific fields from the response error handling use try catch blocks to catch and handle possible errors best practices store and manage api keys do not hard code api keys in your code use environment variables or secure key management systems input validation validate all input parameters before sending requests error handling implement comprehensive error handling, including network errors, api limits, and invalid responses caching strategy consider implementing caching mechanisms to reduce duplicate requests and improve application performance asynchronous processing use async/await or promises to handle asynchronous operations, ensuring the main thread is not blocked notes ensure you have enough api call quota ensure the validity and accessibility of image urls adhere to the api provider's terms of use and restrictions conclusion by following this guide, you should be able to successfully integrate and use the idm vton ai model for virtual try on application development if you encounter any issues or need further assistance, please refer to the official aonweb documentation or contact technical support