typefile
{
"swap_image": "https://replicate.delivery/pbxt/KzYR4BozldWyuyVrRR7kYRrFUZwbIQDnCOnHyUJ5sfIRlEIH/tony.jpg",
"target_video": "https://replicate.delivery/pbxt/KzYR3t8AzCDFrUWWoVdDU5ACvC23TC2AzTUIjwR8pvtIeBuE/input.mp4"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_BZQ**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
import fs from "node:fs";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run arabyai-replicate/roop_face_swap using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"arabyai-replicate/roop_face_swap:11b6bf0f4e14d808f655e87e5448233cceff10a45f659d71539cafb7163b2e84",
{
input: {
swap_image: "https://replicate.delivery/pbxt/KzYR4BozldWyuyVrRR7kYRrFUZwbIQDnCOnHyUJ5sfIRlEIH/tony.jpg",
target_video: "https://replicate.delivery/pbxt/KzYR3t8AzCDFrUWWoVdDU5ACvC23TC2AzTUIjwR8pvtIeBuE/input.mp4"
}
}
);
// To access the file URL:
console.log(output.url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_BZQ**********************************
This is your API token. Keep it to yourself.
import replicate
Run arabyai-replicate/roop_face_swap using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"arabyai-replicate/roop_face_swap:11b6bf0f4e14d808f655e87e5448233cceff10a45f659d71539cafb7163b2e84",
input={
"swap_image": "https://replicate.delivery/pbxt/KzYR4BozldWyuyVrRR7kYRrFUZwbIQDnCOnHyUJ5sfIRlEIH/tony.jpg",
"target_video": "https://replicate.delivery/pbxt/KzYR3t8AzCDFrUWWoVdDU5ACvC23TC2AzTUIjwR8pvtIeBuE/input.mp4"
}
)
# To access the file URL:
print(output.url())
#=> "http://example.com"
# To write the file to disk:
with open("my-image.png", "wb") as file:
file.write(output.read())
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_BZQ**********************************
This is your API token. Keep it to yourself.
Run arabyai-replicate/roop_face_swap using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "arabyai-replicate/roop_face_swap:11b6bf0f4e14d808f655e87e5448233cceff10a45f659d71539cafb7163b2e84",
"input": {
"swap_image": "https://replicate.delivery/pbxt/KzYR4BozldWyuyVrRR7kYRrFUZwbIQDnCOnHyUJ5sfIRlEIH/tony.jpg",
"target_video": "https://replicate.delivery/pbxt/KzYR3t8AzCDFrUWWoVdDU5ACvC23TC2AzTUIjwR8pvtIeBuE/input.mp4"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "vsh1rghq5nrj00cgqzcvxstbx4",
"model": "arabyai-replicate/roop_face_swap",
"version": "11b6bf0f4e14d808f655e87e5448233cceff10a45f659d71539cafb7163b2e84",
"input": {
"swap_image": "https://replicate.delivery/pbxt/KzYR4BozldWyuyVrRR7kYRrFUZwbIQDnCOnHyUJ5sfIRlEIH/tony.jpg",
"target_video": "https://replicate.delivery/pbxt/KzYR3t8AzCDFrUWWoVdDU5ACvC23TC2AzTUIjwR8pvtIeBuE/input.mp4"
},
"logs": "/root/.pyenv/versions/3.8.19/lib/python3.8/site-packages/insightface/utils/transform.py:68: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.\nTo use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.\nP = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4\nProcessing frame 1\nProcessing frame 2\nProcessing frame 3\nProcessing frame 4\nProcessing frame 5\nProcessing frame 6\nProcessing frame 7\nProcessing frame 8\nProcessing frame 9\nProcessing frame 10\nProcessing frame 11\nProcessing frame 12\nProcessing frame 13\nProcessing frame 14\nProcessing frame 15\nProcessing frame 16\nProcessing frame 17\nProcessing frame 18\nProcessing frame 19\nProcessing frame 20\nProcessing frame 21\nProcessing frame 22\nProcessing frame 23\nProcessing frame 24\nProcessing frame 25\nProcessing frame 26\nProcessing frame 27\nProcessing frame 28\nProcessing frame 29\nProcessing frame 30\nProcessing frame 31\nProcessing frame 32\nProcessing frame 33\nProcessing frame 34\nProcessing frame 35\nProcessing frame 36\nProcessing frame 37\nProcessing frame 38\nProcessing frame 39\nProcessing frame 40\nProcessing frame 41\nProcessing frame 42\nProcessing frame 43\nProcessing frame 44\nProcessing frame 45\nProcessing frame 46\nProcessing frame 47\nProcessing frame 48\nProcessing frame 49\nProcessing frame 50\nProcessing frame 51\nProcessing frame 52\nProcessing frame 53\nProcessing frame 54\nProcessing frame 55\nProcessing frame 56\nProcessing frame 57\nProcessing frame 58\nProcessing frame 59\nProcessing frame 60\nProcessing frame 61\nProcessing frame 62\nProcessing frame 63\nProcessing frame 64\nProcessing frame 65\nProcessing frame 66\nProcessing frame 67\nProcessing frame 68\nProcessing frame 69\nProcessing frame 70\nProcessing frame 71\nProcessing frame 72\nProcessing frame 73\nProcessing frame 74\nProcessing frame 75\nProcessing frame 76\nProcessing frame 77\nProcessing frame 78\nProcessing frame 79\nProcessing frame 80\nProcessing frame 81\nProcessing frame 82\nProcessing frame 83\nProcessing frame 84\nProcessing frame 85\nProcessing frame 86\nProcessing frame 87\nProcessing frame 88\nProcessing frame 89\nProcessing frame 90\nProcessing frame 91\nProcessing frame 92\nProcessing frame 93\nProcessing frame 94\nProcessing frame 95\nProcessing frame 96\nProcessing frame 97\nProcessing frame 98\nProcessing frame 99\nProcessing frame 100\nProcessing frame 101\nProcessing frame 102\nProcessing frame 103\nProcessing frame 104\nProcessing frame 105\nProcessing frame 106\nProcessing frame 107\nProcessing frame 108\nProcessing frame 109\nProcessing frame 110\nProcessing frame 111\nProcessing frame 112\nProcessing frame 113\nProcessing frame 114\nProcessing frame 115\nProcessing frame 116\nProcessing frame 117\nProcessing frame 118\nProcessing frame 119\nProcessing frame 120\nProcessing frame 121\nProcessing frame 122\nProcessing frame 123\nProcessing frame 124\nProcessing frame 125\nProcessing frame 126\nProcessing frame 127\nProcessing frame 128\nProcessing frame 129\nProcessing frame 130\nProcessing frame 131\nProcessing frame 132\nProcessing frame 133\nProcessing frame 134\nProcessing frame 135\nProcessing frame 136\nProcessing frame 137\nProcessing frame 138\nProcessing frame 139\nProcessing frame 140\nProcessing frame 141\nProcessing frame 142\nProcessing frame 143\nProcessing frame 144\nProcessing frame 145\nProcessing frame 146\nProcessing frame 147\nProcessing frame 148\nProcessing frame 149\nProcessing frame 150\nProcessing frame 151\nProcessing frame 152\nProcessing frame 153\nProcessing frame 154\nProcessing frame 155\nProcessing frame 156\nProcessing frame 157\nProcessing frame 158\nProcessing frame 159\nProcessing frame 160\nProcessing frame 161\nProcessing frame 162\nProcessing frame 163\nProcessing frame 164\nProcessing frame 165\nProcessing frame 166\nProcessing frame 167\nProcessing frame 168\nProcessing frame 169\nProcessing frame 170\nProcessing frame 171\nProcessing frame 172\nProcessing frame 173\nProcessing frame 174\nProcessing frame 175\nProcessing frame 176\nProcessing frame 177\nProcessing frame 178\nProcessing frame 179\nProcessing frame 180\nProcessing frame 181\nProcessing frame 182\nProcessing frame 183\nProcessing frame 184\nProcessing frame 185\nProcessing frame 186\nProcessing frame 187\nProcessing frame 188\nProcessing frame 189\nProcessing frame 190\nProcessing frame 191\nProcessing frame 192\nProcessing frame 193\nProcessing frame 194\nProcessing frame 195\nProcessing frame 196\nProcessing frame 197\nProcessing frame 198\nProcessing frame 199\nProcessing frame 200\nProcessing frame 201\nProcessing frame 202\nProcessing frame 203\nProcessing frame 204\nProcessing frame 205\nProcessing frame 206\nProcessing frame 207\nProcessing frame 208\nProcessing frame 209\nProcessing frame 210\nProcessing frame 211\nProcessing frame 212\nProcessing frame 213\nProcessing frame 214\nProcessing frame 215\nProcessing frame 216\nProcessing frame 217\nProcessing frame 218\nProcessing frame 219\nProcessing frame 220\nProcessing frame 221\nProcessing frame 222\nProcessing frame 223\nProcessing frame 224\nProcessing frame 225\nProcessing frame 226\nProcessing frame 227\nProcessing frame 228\nProcessing frame 229\nProcessing frame 230\nProcessing frame 231\nProcessing frame 232\nProcessing frame 233\nProcessing frame 234\nProcessing frame 235\nProcessing frame 236\nProcessing frame 237\nProcessing frame 238\nProcessing frame 239\nProcessing frame 240\nProcessing frame 241\nProcessing frame 242\nProcessing frame 243\nProcessing frame 244\nProcessing frame 245\nProcessing frame 246\nProcessing frame 247\nProcessing frame 248\nProcessing frame 249\nProcessing frame 250\nProcessing frame 251\nProcessing frame 252\nProcessing frame 253\nProcessing frame 254\nProcessing frame 255\nProcessing frame 256\nProcessing frame 257\nProcessing frame 258\nProcessing frame 259\nProcessing frame 260\nProcessing frame 261\nProcessing frame 262\nProcessing frame 263\nProcessing frame 264\nProcessing frame 265\nProcessing frame 266\nProcessing frame 267\nProcessing frame 268\nProcessing frame 269\nProcessing frame 270\nffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers\nbuilt with gcc 11 (Ubuntu 11.2.0-19ubuntu1)\nconfiguration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared\nlibavutil 56. 70.100 / 56. 70.100\nlibavcodec 58.134.100 / 58.134.100\nlibavformat 58. 76.100 / 58. 76.100\nlibavdevice 58. 13.100 / 58. 13.100\nlibavfilter 7.110.100 / 7.110.100\nlibswscale 5. 9.100 / 5. 9.100\nlibswresample 3. 9.100 / 3. 9.100\nlibpostproc 55. 9.100 / 55. 9.100\nInput #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/tmp.mp4':\nMetadata:\nmajor_brand : isom\nminor_version : 512\ncompatible_brands: isomiso2mp41\nencoder : Lavf59.27.100\nDuration: 00:00:10.80, start: 0.000000, bitrate: 20236 kb/s\nStream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 20235 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)\nMetadata:\nhandler_name : VideoHandler\nvendor_id : [0][0][0][0]\nStream mapping:\nStream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))\nPress [q] to stop, [?] for help\n[libx264 @ 0x55a2dbcba240] using SAR=1/1\n[libx264 @ 0x55a2dbcba240] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512\n[libx264 @ 0x55a2dbcba240] profile High, level 5.1, 4:2:0, 8-bit\n[libx264 @ 0x55a2dbcba240] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=15 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00\nOutput #0, mp4, to '/tmp/output.mp4':\nMetadata:\nmajor_brand : isom\nminor_version : 512\ncompatible_brands: isomiso2mp41\nencoder : Lavf58.76.100\nStream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 12800 tbn (default)\nMetadata:\nhandler_name : VideoHandler\nvendor_id : [0][0][0][0]\nencoder : Lavc58.134.100 libx264\nSide data:\ncpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A\nframe= 1 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x\nframe= 47 fps= 29 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x\nframe= 56 fps= 26 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x\nframe= 64 fps= 24 q=28.0 size= 256kB time=00:00:00.08 bitrate=26193.7kbits/s speed=0.0299x\nframe= 72 fps= 22 q=28.0 size= 768kB time=00:00:00.40 bitrate=15726.5kbits/s speed=0.123x\nframe= 80 fps= 21 q=28.0 size= 1280kB time=00:00:00.72 bitrate=14562.5kbits/s speed=0.188x\nframe= 88 fps= 20 q=28.0 size= 1792kB time=00:00:01.04 bitrate=14114.8kbits/s speed=0.237x\nframe= 95 fps= 19 q=28.0 size= 2304kB time=00:00:01.32 bitrate=14298.2kbits/s speed=0.27x\nframe= 100 fps= 19 q=28.0 size= 2560kB time=00:00:01.52 bitrate=13796.6kbits/s speed=0.281x\nframe= 106 fps= 18 q=28.0 size= 3072kB time=00:00:01.76 bitrate=14298.3kbits/s speed=0.294x\nframe= 116 fps= 18 q=28.0 size= 3840kB time=00:00:02.16 bitrate=14563.2kbits/s speed=0.332x\nframe= 123 fps= 17 q=28.0 size= 4352kB time=00:00:02.44 bitrate=14611.0kbits/s speed=0.346x\nframe= 130 fps= 17 q=25.0 size= 4864kB time=00:00:02.72 bitrate=14648.9kbits/s speed=0.354x\nframe= 138 fps= 17 q=28.0 size= 5376kB time=00:00:03.04 bitrate=14486.7kbits/s speed=0.369x\nframe= 147 fps= 17 q=28.0 size= 6144kB time=00:00:03.40 bitrate=14803.2kbits/s speed=0.389x\nframe= 154 fps= 17 q=28.0 size= 6656kB time=00:00:03.68 bitrate=14816.6kbits/s speed=0.397x\nframe= 160 fps= 16 q=28.0 size= 7168kB time=00:00:03.92 bitrate=14979.5kbits/s speed=0.398x\nframe= 167 fps= 16 q=28.0 size= 7680kB time=00:00:04.20 bitrate=14979.5kbits/s speed=0.402x\nframe= 174 fps= 16 q=28.0 size= 7936kB time=00:00:04.48 bitrate=14511.4kbits/s speed=0.409x\nframe= 180 fps= 16 q=28.0 size= 8448kB time=00:00:04.72 bitrate=14662.1kbits/s speed=0.411x\nframe= 190 fps= 16 q=28.0 size= 9216kB time=00:00:05.12 bitrate=14745.5kbits/s speed=0.424x\nframe= 199 fps= 16 q=28.0 size= 9728kB time=00:00:05.48 bitrate=14542.2kbits/s speed=0.434x\nframe= 204 fps= 15 q=28.0 size= 10240kB time=00:00:05.68 bitrate=14768.5kbits/s speed=0.428x\nframe= 215 fps= 16 q=28.0 size= 11008kB time=00:00:06.12 bitrate=14734.8kbits/s speed=0.443x\nframe= 223 fps= 16 q=28.0 size= 11264kB time=00:00:06.44 bitrate=14328.3kbits/s speed=0.45x\nframe= 228 fps= 15 q=28.0 size= 11520kB time=00:00:06.64 bitrate=14212.5kbits/s speed=0.445x\nframe= 240 fps= 15 q=28.0 size= 12288kB time=00:00:07.12 bitrate=14138.0kbits/s speed=0.458x\nframe= 248 fps= 15 q=28.0 size= 12800kB time=00:00:07.44 bitrate=14093.7kbits/s speed=0.463x\nframe= 252 fps= 15 q=28.0 size= 13056kB time=00:00:07.60 bitrate=14072.9kbits/s speed=0.456x\nframe= 260 fps= 15 q=28.0 size= 13568kB time=00:00:07.92 bitrate=14033.9kbits/s speed=0.46x\nframe= 270 fps= 13 q=-1.0 Lsize= 18423kB time=00:00:10.68 bitrate=14130.8kbits/s speed=0.511x\nvideo:18420kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.013577%\n[libx264 @ 0x55a2dbcba240] frame I:7 Avg QP:17.91 size:115830\n[libx264 @ 0x55a2dbcba240] frame P:247 Avg QP:20.83 size: 69978\n[libx264 @ 0x55a2dbcba240] frame B:16 Avg QP:22.02 size: 47883\n[libx264 @ 0x55a2dbcba240] consecutive B-frames: 88.1% 11.9% 0.0% 0.0%\n[libx264 @ 0x55a2dbcba240] mb I I16..4: 31.9% 68.0% 0.1%\n[libx264 @ 0x55a2dbcba240] mb P I16..4: 8.2% 20.4% 0.1% P16..4: 46.3% 2.4% 0.7% 0.0% 0.0% skip:21.9%\n[libx264 @ 0x55a2dbcba240] mb B I16..4: 3.3% 7.7% 0.0% B16..8: 42.4% 2.2% 0.1% direct: 1.4% skip:42.9% L0:79.1% L1:19.9% BI: 1.0%\n[libx264 @ 0x55a2dbcba240] 8x8 transform intra:71.0% inter:97.5%\n[libx264 @ 0x55a2dbcba240] coded y,uvDC,uvAC intra: 23.4% 36.7% 2.4% inter: 6.8% 14.2% 0.0%\n[libx264 @ 0x55a2dbcba240] i16 v,h,dc,p: 35% 27% 18% 20%\n[libx264 @ 0x55a2dbcba240] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 23% 34% 1% 1% 1% 1% 1% 1%\n[libx264 @ 0x55a2dbcba240] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 59% 22% 8% 1% 3% 4% 2% 1% 0%\n[libx264 @ 0x55a2dbcba240] i8c dc,h,v,p: 55% 20% 23% 2%\n[libx264 @ 0x55a2dbcba240] Weighted P-Frames: Y:0.0% UV:0.0%\n[libx264 @ 0x55a2dbcba240] ref P L0: 88.0% 3.3% 7.0% 1.7%\n[libx264 @ 0x55a2dbcba240] ref B L0: 91.3% 8.7%\n[libx264 @ 0x55a2dbcba240] kb/s:13971.44",
"output": "https://replicate.delivery/yhqm/dXx7GDfaDYVtZiVuM18AIzW15DfdiKSgKNpUNQwucfqs0mSmA/output.mp4",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-07-17T08:40:02.093Z",
"started_at": "2024-07-17T08:41:13.756895Z",
"completed_at": "2024-07-17T08:45:11.282522Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/vsh1rghq5nrj00cgqzcvxstbx4/cancel",
"get": "https://api.replicate.com/v1/predictions/vsh1rghq5nrj00cgqzcvxstbx4",
"web": "https://replicate.com/p/vsh1rghq5nrj00cgqzcvxstbx4"
},
"metrics": {
"predict_time": 237.525626684,
"total_time": 309.189522
}
}