Faceswap V3
Face Swap V3 is a cutting-edge tool that empowers you to seamlessly swap faces in images. With customizable features and advanced technology, you can achieve professional-quality results.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/faceswap-v3"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "https://segmind-sd-models.s3.amazonaws.com/display_images/faceswapv2_target.jpg",
12 "target_img": "https://segmind-sd-models.s3.us-east-1.amazonaws.com/elon.jpg",
13 "input_faces_index": "0",
14 "source_faces_index": "0",
15 "face_restore": "codeformer-v0.1.0.pth",
16 "interpolation": "Bilinear",
17 "detection_face_order": "large-small",
18 "facedetection": "retinaface_resnet50",
19 "detect_gender_input": "no",
20 "detect_gender_source": "no",
21 "face_restore_weight": 0.75,
22 "image_format": "jpeg",
23 "image_quality": 95,
24 "base64": false
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text)
1import requests
2import json
3
4url = "https://api.segmind.com/v1/faceswap-v3"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "https://segmind-sd-models.s3.amazonaws.com/display_images/faceswapv2_target.jpg",
12 "target_img": "https://segmind-sd-models.s3.us-east-1.amazonaws.com/elon.jpg",
13 "input_faces_index": "0",
14 "source_faces_index": "0",
15 "face_restore": "codeformer-v0.1.0.pth",
16 "interpolation": "Bilinear",
17 "detection_face_order": "large-small",
18 "facedetection": "retinaface_resnet50",
19 "detect_gender_input": "no",
20 "detect_gender_source": "no",
21 "face_restore_weight": 0.75,
22 "image_format": "jpeg",
23 "image_quality": 95,
24 "base64": false
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text)
API Endpoint
https://api.segmind.com/v1/faceswap-v3
Parameters
source_img
requiredstring (uri)
Your face goes here. A closeup shot would be ideal.(image url)
target_img
requiredstring (uri)
The face you want to swap with (image url).
base64
optionalboolean
Base64 encoding of the output image.
false
detect_gender_input
optionalstring
Detect the gender of the target face
"no"
"no"
"female"
"male"
detect_gender_source
optionalstring
Detect the gender of the input face
"no"
"no"
"female"
"male"
detection_face_order
optionalstring
The order in which faces are detected.
"large-small"
"large-small"
"small-large"
"top-bottom"
"bottom-top"
"left-right"
"right-left"
face_restore
optionalstring
which face restore model to use
"codeformer-v0.1.0.pth"
"codeformer-v0.1.0.pth"
"GFPGANv1.4.pth"
"GFPGANv1.3.pth"
face_restore_weight
optionalnumber
Face Restore Weight
0.75
Range: 0 - 1facedetection
optionalstring
The model used to detect the face
"retinaface_resnet50"
"retinaface_resnet50"
"retinaface_mobile0.25"
"YOLOv5l"
"YOLOv5n"
image_format
optionalstring
Output image format
"jpeg"
"jpeg"
"png"
"webp"
image_quality
optionalinteger
Image quality setting for output
95
Range: 10 - 100input_faces_index
optionalstring
Index of the input faces: By default the model detects faces in images from 'large' to 'small'.Index of the first detected face is 0. Multiple faces can be selected using a comma (,)
"0"
interpolation
optionalstring
Face restore interpolation method
"Bilinear"
"Nearest"
"Bilinear"
"Bicubic"
"Lanczos"
source_faces_index
optionalstring
Index of the source faces: By default the model detects faces in images from 'large' to 'small'.Index of the first detected face is 0. Multiple faces can be selected using a comma (,)
"0"
Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out