API
If you're looking for an API, you can choose from your desired programming language.
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
Attributes
Source face image URL for face swap
Target Video URL for face swap
Upscale resolution for enhanced quality
Allowed values:
Selection strategy for multiple faces
Allowed values:
Order priority for face selection
Allowed values:
Gender filter for face selection
Allowed values:
Race filter for face selection
Allowed values:
Minimum age for face selection
min : 0,
max : 100
Maximum age for face selection
min : 0,
max : 100
Maximum distance for reference face matching
min : 0,
max : 1
Specify the frame used to create the reference face
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
-
AI Face Swapping: Replace faces in target images or videos with faces from a source image.
-
Versatile Input: Use image or video as input.
-
Enhanced Quality: Improve output resolution with the pixel_boost parameter.
How to Use AI Face Swap
-
Provide Input: Use URLs for both the source face image and the target image or video.
-
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.
Other Popular Models
sdxl-img2img
SDXL Img2Img is used for text-guided image-to-image translation. This model uses the weights from Stable Diffusion to generate new images from an input image using StableDiffusionImg2ImgPipeline from diffusers

sdxl-controlnet
SDXL ControlNet gives unprecedented control over text-to-image generation. SDXL ControlNet models Introduces the concept of conditioning inputs, which provide additional information to guide the image generation process

storydiffusion
Story Diffusion turns your written narratives into stunning image sequences.

idm-vton
Best-in-class clothing virtual try on in the wild
