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

~2.89s
~$0.004
 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

POSThttps://api.segmind.com/v1/models/faceswap-v2

Parameters

source_imgrequired
string (base64)

Your face goes here. A closeup shot would be ideal.(image url/base64)

target_imgrequired
string (base64)

The face you want to swap with.(image url/base64)

base64optional
boolean

Base64 encoding of the output image.

Default: false
face_restoreoptional
string

which face restore model to use

Default: "codeformer-v0.1.0.pth"
Allowed values :
"codeformer-v0.1.0.pth""GFPGANv1.4.pth""GFPGANv1.3.pth"
input_faces_indexoptional
string

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 (,)

Default: "0"
source_faces_indexoptional
string

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 (,)

Default: "0"

Response Type

Returns: Image

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out