Specific Face Swap Endpoint
Overview
Specific Face Swap endpoint allows swapping faces in a single image
Request
--request POST 'https://modelslab.com/api/v6/deepfake/single_face_swap' \
Make a POST
request to https://modelslab.com/api/v6/deepfake/single_face_swap endpoint and pass the required parameters in the request body.
Body Attributes
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization. | string |
init_image | The first image containing the face to replace the face in the initial image. | URL |
target_image | The second image containing the face to be swapped. | URL |
reference_image | Reference image is the image which has a particular face we want to swap from given init image. | URL |
watermark | Indicate if you want the generated result to have a watermark. Default is true. | true/false |
webhook | Provide a URL to receive a POST API call once the image generation is complete. | URL |
track_id | This ID will be included in the response to the webhook API call to identify the request. | integral value |
Example
Body
Body
{
"key":"",
"init_image":" https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/DTs2zg3HELltVoQElpO3ec0f9BsAtS-metaNzExMTY5My1zYWxtYW4ta2hhbi1zaGFocnVraC1raGFuLTJbMV0ucG5n-.png",
"target_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/jznUIJy6FoM1nUkXZBCvhyrlbetau1-metabGljZW5zZWQtaW1hZ2UuanBn-.jpg",
"reference_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/9Mhbi9i0r9ADMfTpwTOqmyEQQyb6AK-metaSEQtd2FsbHBhcGVyLXNoYWhydWtoLWtoYW4tc3JrLWFjdG9yLWhlcm9bMV0uanBn-.jpg",
"webhook": null,
"track_id": null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key":"",
"init_image":" https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/DTs2zg3HELltVoQElpO3ec0f9BsAtS-metaNzExMTY5My1zYWxtYW4ta2hhbi1zaGFocnVraC1raGFuLTJbMV0ucG5n-.png",
"target_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/jznUIJy6FoM1nUkXZBCvhyrlbetau1-metabGljZW5zZWQtaW1hZ2UuanBn-.jpg",
"reference_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/9Mhbi9i0r9ADMfTpwTOqmyEQQyb6AK-metaSEQtd2FsbHBhcGVyLXNoYWhydWtoLWtoYW4tc3JrLWFjdG9yLWhlcm9bMV0uanBn-.jpg",
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v6/deepfake/single_face_swap", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"init_image" =>"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/DTs2zg3HELltVoQElpO3ec0f9BsAtS-metaNzExMTY5My1zYWxtYW4ta2hhbi1zaGFocnVraC1raGFuLTJbMV0ucG5n-.png",
"target_image" => "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/jznUIJy6FoM1nUkXZBCvhyrlbetau1-metabGljZW5zZWQtaW1hZ2UuanBn-.jpg",
"reference_image" => "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/9Mhbi9i0r9ADMfTpwTOqmyEQQyb6AK-metaSEQtd2FsbHBhcGVyLXNoYWhydWtoLWtoYW4tc3JrLWFjdG9yLWhlcm9bMV0uanBn-.jpg",
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/deepfake/single_face_swap',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v6/deepfake/single_face_swap',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"init_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/DTs2zg3HELltVoQElpO3ec0f9BsAtS-metaNzExMTY5My1zYWxtYW4ta2hhbi1zaGFocnVraC1raGFuLTJbMV0ucG5n-.png",
"target_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/jznUIJy6FoM1nUkXZBCvhyrlbetau1-metabGljZW5zZWQtaW1hZ2UuanBn-.jpg",
"reference_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/9Mhbi9i0r9ADMfTpwTOqmyEQQyb6AK-metaSEQtd2FsbHBhcGVyLXNoYWhydWtoLWtoYW4tc3JrLWFjdG9yLWhlcm9bMV0uanBn-.jpg",
"webhook": null,
"track_id": null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v6/deepfake/single_face_swap"
payload = json.dumps({
"key": "",
"init_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/DTs2zg3HELltVoQElpO3ec0f9BsAtS-metaNzExMTY5My1zYWxtYW4ta2hhbi1zaGFocnVraC1raGFuLTJbMV0ucG5n-.png",
"target_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/jznUIJy6FoM1nUkXZBCvhyrlbetau1-metabGljZW5zZWQtaW1hZ2UuanBn-.jpg",
"reference_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/9Mhbi9i0r9ADMfTpwTOqmyEQQyb6AK-metaSEQtd2FsbHBhcGVyLXNoYWhydWtoLWtoYW4tc3JrLWFjdG9yLWhlcm9bMV0uanBn-.jpg",
"webhook": None,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"key\": \"\",\r\n \"init_image\":\"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/DTs2zg3HELltVoQElpO3ec0f9BsAtS-metaNzExMTY5My1zYWxtYW4ta2hhbi1zaGFocnVraC1raGFuLTJbMV0ucG5n-.png\",\r\n \"target_image\":\"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/jznUIJy6FoM1nUkXZBCvhyrlbetau1-metabGljZW5zZWQtaW1hZ2UuanBn-.jpg\",\r\n \"reference_image\":\"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/9Mhbi9i0r9ADMfTpwTOqmyEQQyb6AK-metaSEQtd2FsbHBhcGVyLXNoYWhydWtoLWtoYW4tc3JrLWFjdG9yLWhlcm9bMV0uanBn-.jpg\",\r\n \"webhook\": null,\r\n \"track_id\": null\r\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/deepfake/single_face_swap")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 2.71,
"id": 118409305,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/964bd881-f141-4e8f-b240-b7f48132a998.jpg"
],
"proxy_links": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/964bd881-f141-4e8f-b240-b7f48132a998.jpg"
],
"meta": {
"init_image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/DTs2zg3HELltVoQElpO3ec0f9BsAtS-metaNzExMTY5My1zYWxtYW4ta2hhbi1zaGFocnVraC1raGFuLTJbMV0ucG5n-.png",
"target_image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/jznUIJy6FoM1nUkXZBCvhyrlbetau1-metabGljZW5zZWQtaW1hZ2UuanBn-.jpg",
"reference_image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/9Mhbi9i0r9ADMfTpwTOqmyEQQyb6AK-metaSEQtd2FsbHBhcGVyLXNoYWhydWtoLWtoYW4tc3JrLWFjdG9yLWhlcm9bMV0uanBn-.jpg",
"seed": 2154158797,
"temp": "no",
"file_prefix": "964bd881-f141-4e8f-b240-b7f48132a998",
"model_save_format": "jpg",
"watermark": "yes",
"watermark_image": null
}
}