Consistentidentities
Swap generate v2 - one face head swap
Only for enterprise customers This endpoint initiate a new face swap.
Example:
import requests
import json
url_api = 'https://api.piktid.com/api'
identity_id = "" # Identity to swap identifier, from the response of the endpoint /consistent_identities/upload_face
image_id = "" # Target image identifier, from the response of the endpoint /consistent_identities/upload_target
face_id = 0 # Index of the face. 0: if the target image has only one face detected.
options = {
'flag_replace_and_download': True,
'watermark_url':'watermark url',
'prompt_strength':0.55, # from 0.0 to 1.0, default: 0.55
}
response = requests.post(url_api+'/consistent_identities/generate/v2',
headers={'Authorization': 'Bearer '+TOKEN},
json={
"identity_name": identity_id, # IDENTITY_ID
"id_image": image_id, # IMAGE_ID
"id_face": face_id, # FACE_ID
"options": json.dumps(options),
},
)
response_json = json.loads(response.text)This function is asynchronous. To retrieve the result, continuously poll (for example every 3 seconds) the endpoint /consistent_identities/notification/read.
response_n = requests.post(url_api+'/consistent_identities/notification/read',
headers={'Authorization': 'Bearer '+TOKEN},
json={'name_list':'swap'},
)
response_notifications_json = json.loads(response_n.text)
swap_image_link = response_notifications_json.get('notifications_list',[])[0].get('data',{}).get('links',[])[0].get('l')AuthorizationBearer <token>
In: header
id_image?string
id_face?integer
identity_name?string
description_type?string
options?string
flag_sync?boolean
id_generation?integer
prompt?string
Response Body
Examples
curl -X POST "https://api.piktid.com/api/consistent_identities/generate/v2" \
-H "Content-Type: application/json" \
-d '{}'{
"image_id": "string",
"faces": [
"string"
],
"coordinates_list": [
"string"
],
"thumbnails": [
"string"
],
"blurred_faces_list": [
"string"
],
"face_description_list": [
"string"
]
}{
"code": 0,
"message": "string",
"description": "string"
}{
"code": 0,
"message": "string",
"description": "string"
}{
"code": 0,
"message": "string",
"description": "string"
}