PiAPI commited on
Commit
c3e8d0e
·
verified ·
1 Parent(s): 94da309

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +107 -3
README.md CHANGED
@@ -1,3 +1,107 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ # Faceswap API
6
+
7
+ **Model Page:** [Faceswap API](https://piapi.ai/faceswap-api)
8
+
9
+ This model card illustartes the steps to use Faceswap API's endpoint.
10
+ You can also check out other model cards:
11
+
12
+ - [Midjourney API](https://huggingface.co/PiAPI/Midjourney-API)
13
+ - [Suno API](https://huggingface.co/PiAPI/Suno-API)
14
+ - [Dream Machine API](https://huggingface.co/PiAPI/Dream-Machine-API)
15
+
16
+ **Model Information**
17
+
18
+ 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.
19
+
20
+
21
+ ## Usage Steps
22
+
23
+ Below we share the code snippets on how to use the Faceswap API's endpoint.
24
+ - The programming language is Python
25
+ - Have 2 images (Each image must only contain one visible face)
26
+
27
+ **Create a task ID from the Faceswap endpoint**
28
+
29
+ <pre><code class="language-python">
30
+ <span class="hljs-keyword">import</span> http.client
31
+
32
+ conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>)
33
+
34
+ payload = <span class="hljs-string">"{\n \"target_image\": \"image1.png\",\n \"swap_image\": \"image2.png\",\n \"result_type\": \"url\"\n}"</span>
35
+
36
+ headers = {
37
+ <span class="hljs-built_in">'X-API-Key': "{{x-api-key}}"</span>, //Insert your API Key here
38
+ <span class="hljs-built_in">'Content-Type': "application/json"</span>,
39
+ <span class="hljs-built_in">'Accept': "application/json"</span>
40
+ }
41
+
42
+ conn.request("POST", "/api/face_swap/v1/async", payload, headers)
43
+
44
+ res = conn.getresponse()
45
+ data = res.read()
46
+
47
+ <span class="hljs-keyword">print</span>(data.decode("utf-8"))
48
+ </code></pre>
49
+
50
+
51
+
52
+ **Retrieve the task ID**
53
+
54
+ <pre><code class="language-python">
55
+ {
56
+ <span class="hljs-built_in">"code"</span>: 200,
57
+ <span class="hljs-built_in">"data"</span>: {
58
+ <span class="hljs-built_in">"task_id"</span>: "7a7ba527************1974d4316e22" //Record the taskID provided in your response terminal
59
+ },
60
+ <span class="hljs-built_in">"message"</span>: "success"
61
+ }
62
+ </code></pre>
63
+
64
+
65
+
66
+ **Insert the Faceswap task ID into the fetch endpoint**
67
+
68
+ <pre><code class="language-python">
69
+ <span class="hljs-keyword">import</span> http.client
70
+
71
+ conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>)
72
+
73
+ payload = <span class="hljs-string">"{\n \"task_id\": \"7a7ba527************1974d4316e22\"\n}"</span> //Replace the task ID with your task ID
74
+
75
+ headers = {
76
+ <span class="hljs-built_in">'X-API-Key': "{{x-api-key}}"</span>, //Insert your API Key here
77
+ <span class="hljs-built_in">'Content-Type': "application/json"</span>,
78
+ <span class="hljs-built_in">'Accept': "application/json"</span>
79
+ }
80
+
81
+ conn.request("POST", "/api/face_swap/v1/fetch", payload, headers)
82
+
83
+ res = conn.getresponse()
84
+ data = res.read()
85
+
86
+ <span class="hljs-keyword">print</span>(data.decode("utf-8"))
87
+ </code></pre>
88
+
89
+
90
+
91
+ **For fetch endpoint responses** - Refer to our [documentation](https://piapi.ai/docs) for more detailed information.
92
+
93
+
94
+
95
+ <br>
96
+
97
+
98
+
99
+ ## Contact us
100
+
101
+ Contact us at <a href="mailto:[email protected]">[email protected]</a> for any inquires.
102
+
103
+ <br>
104
+
105
+
106
+
107
+