maynulcmd's picture
|
download
raw
3.27 kB
metadata
license: mit

Faceswap API

Model Page: Faceswap API

This model card illustartes the steps to use Faceswap API's endpoint. You can also check out other model cards:

Model Information

The FaceSwap API, built on a custom AI model, allows developers to effortlessly integrate advanced face-swapping capabilities to their platforms, offering users the ability to rapidly personalize images of their choice.

Usage Steps

Below we share the code snippets on how to use the Faceswap API's endpoint.

  • The programming language is Python
  • Have 2 images (Each image must only contain one visible face)

Create a task ID from the Faceswap endpoint


  import http.client
  
  conn = http.client.HTTPSConnection("api.piapi.ai")
  
  payload = "{\n  \"target_image\": \"image1.png\",\n  \"swap_image\": \"image2.png\",\n  \"result_type\": \"url\"\n}"
  
  headers = {
      'X-API-Key': "{{x-api-key}}",                  //Insert your API Key here
      'Content-Type': "application/json",
      'Accept': "application/json"
  }
  
  conn.request("POST", "/api/face_swap/v1/async", payload, headers)
  
  res = conn.getresponse()
  data = res.read()
  
  print(data.decode("utf-8"))

Retrieve the task ID


  {
      "code": 200,
      "data": {
          "task_id": "7a7ba527************1974d4316e22"        //Record the taskID provided in your response terminal
      },
      "message": "success"
  }

Insert the Faceswap task ID into the fetch endpoint


  import http.client
  
  conn = http.client.HTTPSConnection("api.piapi.ai")
  
  payload = "{\n  \"task_id\": \"7a7ba527************1974d4316e22\"\n}"    //Replace the task ID with your task ID
  
  headers = {
      'X-API-Key': "{{x-api-key}}",                           //Insert your API Key here
      'Content-Type': "application/json",
      'Accept': "application/json"
  }
  
  conn.request("POST", "/api/face_swap/v1/fetch", payload, headers)
  
  res = conn.getresponse()
  data = res.read()
  
  print(data.decode("utf-8"))

For fetch endpoint responses - Refer to our documentation for more detailed information.


Contact us

Contact us at contact@piapi.ai for any inquires.


Xet Storage Details

Size:
3.27 kB
·
Xet hash:
67d17aa76d7accb7130892847c1cb14922a0b79fcf24403a8fe7487c635837fb

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.