AI Face Swap (image and video)

AI Face Swap: Effortlessly replace faces online. Fine-tune swaps with advanced controls for age, gender, and resolution.


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 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/ai-face-swap" # Request payload data = { "source_image": image_url_to_base64("https://segmind-resources.s3.amazonaws.com/input/8d67068b-dc76-4069-b231-acdbb644ab54-ai-video-swap-ip2.png"), # Or use image_file_to_base64("IMAGE_PATH") "target": "https://segmind-resources.s3.amazonaws.com/input/1f234efe-9867-475f-8ef2-81eef026fb50-7eb8f231-ace8-4dbe-bb6a-43ae13d1a89e.mp4", "pixel_boost": "384x384", "face_selector_mode": "reference", "face_selector_order": "large-small", "face_selector_age_start": 0, "face_selector_age_end": 100, "reference_face_distance": 0.6, "reference_frame_number": 1, "base64": False } headers = {'x-api-key': api_key} response = requests.post(url, json=data, 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


source_imageimage *

Source face image URL for face swap


targetstr *

Target Video URL for face swap


pixel_boostenum:str ( default: 384x384 )

Upscale resolution for enhanced quality

Allowed values:


face_selector_modeenum:str ( default: reference )

Selection strategy for multiple faces

Allowed values:


face_selector_orderenum:str ( default: large-small )

Order priority for face selection

Allowed values:


face_selector_genderenum:str ( default: 1 )

Gender filter for face selection

Allowed values:


face_selector_raceenum:str ( default: 1 )

Race filter for face selection

Allowed values:


face_selector_age_startint ( default: 1 )

Minimum age for face selection

min : 0,

max : 100


face_selector_age_endint ( default: 100 )

Maximum age for face selection

min : 0,

max : 100


reference_face_distancefloat ( default: 0.6 )

Maximum distance for reference face matching

min : 0,

max : 1


reference_frame_numberint ( default: 1 )

Specify the frame used to create the reference face


base64bool ( default: 1 )

Base64 encoding of the output

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.

AI Face Swap

Swap faces in your images and videos effortlessly with our AI Face Swap tool. This tool utilizes advanced artificial intelligence to provide realistic and high-quality face swaps. Perfect for creating engaging content, fun edits, and more.

Key Features of AI Face Swap

  1. AI Face Swapping: Replace faces in target images or videos with faces from a source image.

  2. Versatile Input: Use image or video as input.

  3. Enhanced Quality: Improve output resolution with the pixel_boost parameter.

How to Use AI Face Swap

  1. Provide Input: Use URLs for both the source face image and the target image or video.

  2. Adjust Parameters: Several parameters allow for fine-tuning the face swap.

  • The pixel_boost parameter upscales the resolution for better quality.

  • The face_selector_mode determines the selection strategy when multiple faces appear.

  • The face_selector_order sets the priority for face selection, with "large-small" as the default.

  • Additional filters include face_selector_gender and face_selector_race to refine face selection.

  • The face_selector_age_start and face_selector_age_end set the minimum and maximum age for face selection, ranging from 0 to 100.

  • The reference_face_distance sets the maximum distance for reference face matching, ranging from 0 to 1.

  • The reference_frame_number specifies a frame for reference.

Cookie settings

We use cookies to enhance your browsing experience, analyze site traffic, and personalize content. By clicking "Accept all", you consent to our use of cookies.