Update plugins/faceswap.js
Browse files- plugins/faceswap.js +20 -8
plugins/faceswap.js
CHANGED
|
@@ -30,6 +30,7 @@ async function faceSwap(img_url1, img_url2) {
|
|
| 30 |
return {
|
| 31 |
success: true,
|
| 32 |
elapsedTime: swapResponse.data.elapsedTime,
|
|
|
|
| 33 |
url: imageUrl
|
| 34 |
};
|
| 35 |
|
|
@@ -40,12 +41,12 @@ async function faceSwap(img_url1, img_url2) {
|
|
| 40 |
|
| 41 |
const handler = async (req, res) => {
|
| 42 |
try {
|
| 43 |
-
const {
|
| 44 |
|
| 45 |
-
if (!
|
| 46 |
return res.status(400).json({
|
| 47 |
success: false,
|
| 48 |
-
error: 'Missing required parameter:
|
| 49 |
});
|
| 50 |
}
|
| 51 |
|
|
@@ -56,12 +57,23 @@ const handler = async (req, res) => {
|
|
| 56 |
});
|
| 57 |
}
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
return res.json({
|
| 62 |
author: "Herza",
|
| 63 |
success: true,
|
| 64 |
-
data:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
});
|
| 66 |
|
| 67 |
} catch (error) {
|
|
@@ -77,11 +89,11 @@ module.exports = {
|
|
| 77 |
name: 'Face Swap',
|
| 78 |
description: 'Swap faces between two images using AI',
|
| 79 |
type: 'GET',
|
| 80 |
-
routes: ['api/
|
| 81 |
tags: ['AI', 'tools'],
|
| 82 |
-
parameters: ['
|
| 83 |
limit: 3,
|
| 84 |
enabled: true,
|
| 85 |
-
main: ['
|
| 86 |
handler
|
| 87 |
};
|
|
|
|
| 30 |
return {
|
| 31 |
success: true,
|
| 32 |
elapsedTime: swapResponse.data.elapsedTime,
|
| 33 |
+
result: swapResponse.data.result,
|
| 34 |
url: imageUrl
|
| 35 |
};
|
| 36 |
|
|
|
|
| 41 |
|
| 42 |
const handler = async (req, res) => {
|
| 43 |
try {
|
| 44 |
+
const { img, img2, key } = req.query;
|
| 45 |
|
| 46 |
+
if (!img) {
|
| 47 |
return res.status(400).json({
|
| 48 |
success: false,
|
| 49 |
+
error: 'Missing required parameter: img'
|
| 50 |
});
|
| 51 |
}
|
| 52 |
|
|
|
|
| 57 |
});
|
| 58 |
}
|
| 59 |
|
| 60 |
+
if (!key) {
|
| 61 |
+
return res.status(400).json({
|
| 62 |
+
success: false,
|
| 63 |
+
error: 'Missing required parameter: key'
|
| 64 |
+
});
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
const result = await faceSwap(img, img2);
|
| 68 |
|
| 69 |
return res.json({
|
| 70 |
author: "Herza",
|
| 71 |
success: true,
|
| 72 |
+
data: {
|
| 73 |
+
elapsedTime: result.elapsedTime,
|
| 74 |
+
result: result.result,
|
| 75 |
+
url: result.url
|
| 76 |
+
}
|
| 77 |
});
|
| 78 |
|
| 79 |
} catch (error) {
|
|
|
|
| 89 |
name: 'Face Swap',
|
| 90 |
description: 'Swap faces between two images using AI',
|
| 91 |
type: 'GET',
|
| 92 |
+
routes: ['api/AI/faceswap'],
|
| 93 |
tags: ['AI', 'tools'],
|
| 94 |
+
parameters: ['img', 'img2', 'key'],
|
| 95 |
limit: 3,
|
| 96 |
enabled: true,
|
| 97 |
+
main: ['AI', 'tools'],
|
| 98 |
handler
|
| 99 |
};
|