Faceswap V2
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
1import requests
2import json
3
4url = "https://api.segmind.com/v1/models/faceswap-v2"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "sample text",
12 "target_img": "sample text",
13 "input_faces_index": "0",
14 "source_faces_index": "0",
15 "face_restore": "codeformer-v0.1.0.pth",
16 "base64": false
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text)
1import requests
2import json
3
4url = "https://api.segmind.com/v1/models/faceswap-v2"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "sample text",
12 "target_img": "sample text",
13 "input_faces_index": "0",
14 "source_faces_index": "0",
15 "face_restore": "codeformer-v0.1.0.pth",
16 "base64": false
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text)
API Endpoint
https://api.segmind.com/v1/models/faceswap-v2
Parameters
source_img
requiredstring (base64)
Your face goes here. A closeup shot would be ideal.(image url/base64)
target_img
requiredstring (base64)
The face you want to swap with.(image url/base64)
base64
optionalboolean
Base64 encoding of the output image.
false
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"
input_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"
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