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
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/faceswap-v4"
# Request payload
data = {
"source_image": image_url_to_base64("https://segmind-resources.s3.amazonaws.com/input/b872c581-a20a-4fda-98aa-b78d2e221ccb-v4-source-img.jpg"), # Or use image_file_to_base64("IMAGE_PATH")
"target_image": image_url_to_base64("https://segmind-resources.s3.amazonaws.com/output/7401f2ea-5652-4f2a-93d9-a587f1ccb62f-fs-v4-target.png"), # Or use image_file_to_base64("IMAGE_PATH")
"model_type": "speed",
"swap_type": "head",
"style_type": "normal",
"seed": 4208875,
"image_format": "png",
"image_quality": 90,
"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
The image URL of the source image
The image on which the face swap will be applied, url
The model type to use for face swapping
Allowed values:
Determines whether to swap the entire head or just the face
Allowed values:
The style to apply during face swapping
Allowed values:
Random seed for reproducibility
The output image format
Allowed values:
The quality of the output image
min : 10,
max : 100
Output as base64
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.
Segmind Faceswap v4
Our advanced Face Swap model empowers users to seamlessly transfer faces between images. Ideal for content creators, designers, and anyone seeking creative image manipulation, our model offers unique customization options and ensures reproducible results for precise control over face swap outcomes.
Key Features
-
Source Image Input - Allows users to upload the image containing the face they wish to transfer. This provides the flexibility to use any image as the source for the face swap.
-
Target Image Input - Enables users to specify the image onto which the face swap will be applied. This allows for versatile application of the face swap effect on various base images.
-
Model Type: Speed - Utilizes a speed-optimized algorithm for fast and efficient face swapping. This ensures a quick turnaround time for generating the desired output.
-
Swap Type Selection - Offers the choice between swapping the entire head or just the face. This provides control over the scope of the face replacement.
-
Style Application - Includes a normal style type for standard face swapping. This ensures a natural-looking integration of the swapped face.
-
Reproducibility via Seed - Incorporates a random seed parameter, allowing for consistent results when the same seed is used. This feature is valuable for maintaining consistency across multiple generations.
-
Output Format Choice - Supports outputting the final image in either JPEG or PNG format. This provides flexibility based on user needs for file size and image quality.
-
Adjustable Image Quality - Enables users to control the output image quality, ranging from 10 to 100, with a default of 90. This allows for balancing file size and visual fidelity.
Use Cases
-
Entertainment and Social Media - Creating humorous or engaging content by swapping faces in photos for social sharing, providing lighthearted entertainment.
-
Content Creation - Create unique visuals for marketing campaigns or artistic projects by altering existing images with face swaps.
-
Privacy and Anonymization - Obscuring identities in images for privacy purposes by replacing faces, particularly useful in sensitive contexts.
-
Prototyping and Design - Quickly visualizing different appearances or character designs by swapping faces onto various models or templates.
The Face Swap model provides a user-friendly and efficient way to perform image manipulation through face or head replacement. With its speed optimization and customizable options for swap type, output format, and quality, it offers a versatile tool for various applications, from entertainment to content creation.
Other Popular Models
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

sadtalker
Audio-based Lip Synchronization for Talking Head Video

fooocus
Fooocus enables high-quality image generation effortlessly, combining the best of Stable Diffusion and Midjourney.

sd2.1-faceswapper
Take a picture/gif and replace the face in it with a face of your choice. You only need one image of the desired face. No dataset, no training
