Fashion AI

This model is capable of editing clothing in an image using a premier clothing segmentation algorithm.


API

If you're looking for an API, you can choose from your desired programming language.

POST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import requests api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/fashion-ai" # Prepare data and files data = {} files = {} # For parameter "image", you can send a raw file or a URI: # files['image'] = open('IMAGE_PATH', 'rb') # To send a file # data['image'] = 'IMAGE_URI' # To send a URI data['prompt'] = "a person wearing blue jeans" data['clothing'] = "topwear" headers = {'x-api-key': api_key} response = requests.post(url, data=data, files=files, headers=headers) print(response.content) # The response is the generated image
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


imagestr *

Input image to in-paint. The image will be center cropped and resized to size 512*512.


promptstr *

Image prompt that will edit the clothing.


clothingstr ( default: topwear )

This value should be one of the following - [topwear, bottomwear]

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.

Fashion AI

Fashion AI model can effectively replace a piece of clothing in an image with a new one, creating a seamless and realistic result. The fashion AI model working in two steps:

  1. The model first identifies and separates the piece of clothing from the rest of the image. This precise segmentation allows the model to focus solely on the clothing item.

  2. Once the clothing item is segmented, the model then inpaints the segmented image. This process is guided by a text prompt, which describes the new piece of clothing that should replace the original one.

Key Components of Fashion AI

Under the hood, the Fashion AI model is a combination of object detection, segmentation and inpainting.

Object Detection: The Grounding DINO model is used for object detection. It identifies the object of interest in the image, such as clothing. This is achieved by inputting the image and the object category into the Grounding DINO model, which uses both language and vision modalities to detect objects.

Segmentation: The Segment Anything Model (SAM) is employed for segmentation. It precisely segments elements in images based on semantic text prompts.

Inpainting: Following segmentation, a mask is created for the segmented clothing image. White pixels represent the clothing that will be inpainted, while black pixels are preserved. Based on the text prompt, a new clothing item replaces the old one. This process is known as inpainting.

How to use Fashion AI

  1. Input Image: Provide an image of a person wearing clothing. This will serve as the base for the clothing replacement.

  2. Text Prompt: Specify your desired changes to the clothing. This could include color, design, etc.

  3. Clothing: Adjust the ‘clothing’ parameter to select the type of clothing you want to modify. This could be topwear, bottomwear, or full body wear, depending on the input image.

*Please note, if there is a mismatch between the clothing in the input image and the selected clothing type, it may result in unsatisfactory results. Always ensure that the clothing type matches the clothing present in the input image for the best results.