|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 | 5 | "execution_count": 1,
|
6 |
| - "id": "tested-scope", |
| 6 | + "id": "joined-nelson", |
7 | 7 | "metadata": {},
|
8 | 8 | "outputs": [
|
9 | 9 | {
|
10 | 10 | "name": "stderr",
|
11 | 11 | "output_type": "stream",
|
12 | 12 | "text": [
|
13 | 13 | "/home/jovyan/conda/envs/faceshift_env/lib/python3.8/site-packages/kornia/augmentation/augmentation.py:1830: DeprecationWarning: GaussianBlur is no longer maintained and will be removed from the future versions. Please use RandomGaussianBlur instead.\n",
|
14 |
| - " warnings.warn(\n" |
| 14 | + " warnings.warn(\n", |
| 15 | + "/home/jovyan/final_repo/sber-swap/models/networks/normalization.py:68: DeprecationWarning: invalid escape sequence \\D\n", |
| 16 | + " parsed = re.search('spade(\\D+)(\\d)x\\d', config_text)\n", |
| 17 | + "/home/jovyan/final_repo/sber-swap/utils/inference/util.py:165: DeprecationWarning: invalid escape sequence \\d\n", |
| 18 | + " return [atoi(c) for c in re.split('(\\d+)', text)]\n" |
15 | 19 | ]
|
16 | 20 | }
|
17 | 21 | ],
|
|
35 | 39 | },
|
36 | 40 | {
|
37 | 41 | "cell_type": "markdown",
|
38 |
| - "id": "neutral-constant", |
| 42 | + "id": "provincial-polymer", |
39 | 43 | "metadata": {},
|
40 | 44 | "source": [
|
41 | 45 | "### Load Models"
|
|
44 | 48 | {
|
45 | 49 | "cell_type": "code",
|
46 | 50 | "execution_count": 2,
|
47 |
| - "id": "elder-temperature", |
| 51 | + "id": "pregnant-grant", |
48 | 52 | "metadata": {},
|
49 | 53 | "outputs": [
|
50 | 54 | {
|
|
77 | 81 | "app = Face_detect_crop(name='antelope', root='./insightface_func/models')\n",
|
78 | 82 | "app.prepare(ctx_id= 0, det_thresh=0.6, det_size=(640,640))\n",
|
79 | 83 | "\n",
|
80 |
| - "# основная модель для генерации\n", |
| 84 | + "# main model for generation\n", |
81 | 85 | "G = AEI_Net(c_id=512)\n",
|
82 | 86 | "G.eval()\n",
|
83 | 87 | "G.load_state_dict(torch.load('weights/G_0_035000_init_arch_arcface2.pth', map_location=torch.device('cpu')))\n",
|
84 | 88 | "G = G.cuda()\n",
|
85 | 89 | "G = G.half()\n",
|
86 | 90 | "\n",
|
87 |
| - "# модель arcface для того, чтобы достать эмбеддинг лица\n", |
| 91 | + "# arcface model to get face embedding\n", |
88 | 92 | "netArc = iresnet100(fp16=False)\n",
|
89 | 93 | "netArc.load_state_dict(torch.load('arcface_model/backbone.pth'))\n",
|
90 | 94 | "netArc=netArc.cuda()\n",
|
91 | 95 | "netArc.eval()\n",
|
92 | 96 | "\n",
|
93 |
| - "# модель, которая позволяет находить точки лица\n", |
| 97 | + "# model to get face landmarks\n", |
94 | 98 | "handler = Handler('./coordinate_reg/model/2d106det', 0, ctx_id=0, det_size=640)\n",
|
95 | 99 | "\n",
|
96 |
| - "# модель, увеличивающая четкость лица\n", |
97 |
| - "use_sr = True\n", |
| 100 | + "# model to make superres of face, set use_sr=True if you want to use super resolution or use_sr=False if you don't\n", |
| 101 | + "use_sr = False\n", |
98 | 102 | "if use_sr:\n",
|
99 | 103 | " os.environ['CUDA_VISIBLE_DEVICES'] = '0'\n",
|
100 | 104 | " torch.backends.cudnn.benchmark = True\n",
|
|
106 | 110 | },
|
107 | 111 | {
|
108 | 112 | "cell_type": "markdown",
|
109 |
| - "id": "geographic-stream", |
| 113 | + "id": "public-match", |
110 | 114 | "metadata": {},
|
111 | 115 | "source": [
|
112 | 116 | "### Set here path to source image and video for faceswap"
|
|
115 | 119 | {
|
116 | 120 | "cell_type": "code",
|
117 | 121 | "execution_count": 3,
|
118 |
| - "id": "familiar-prime", |
| 122 | + "id": "tracked-memorial", |
119 | 123 | "metadata": {},
|
120 | 124 | "outputs": [
|
121 | 125 | {
|
|
142 | 146 | {
|
143 | 147 | "cell_type": "code",
|
144 | 148 | "execution_count": 4,
|
145 |
| - "id": "therapeutic-regression", |
| 149 | + "id": "virtual-correlation", |
146 | 150 | "metadata": {},
|
147 | 151 | "outputs": [
|
148 | 152 | {
|
|
175 | 179 | {
|
176 | 180 | "cell_type": "code",
|
177 | 181 | "execution_count": 5,
|
178 |
| - "id": "selected-position", |
| 182 | + "id": "individual-planet", |
179 | 183 | "metadata": {},
|
180 | 184 | "outputs": [
|
181 | 185 | {
|
|
195 | 199 | },
|
196 | 200 | {
|
197 | 201 | "cell_type": "markdown",
|
198 |
| - "id": "opposite-discretion", |
| 202 | + "id": "aerial-rolling", |
199 | 203 | "metadata": {},
|
200 | 204 | "source": [
|
201 | 205 | "### Model Inference"
|
|
204 | 208 | {
|
205 | 209 | "cell_type": "code",
|
206 | 210 | "execution_count": 6,
|
207 |
| - "id": "numeric-forth", |
| 211 | + "id": "adjacent-personal", |
208 | 212 | "metadata": {},
|
209 | 213 | "outputs": [
|
210 | 214 | {
|
|
223 | 227 | {
|
224 | 228 | "cell_type": "code",
|
225 | 229 | "execution_count": 7,
|
226 |
| - "id": "increased-malaysia", |
| 230 | + "id": "vocal-facility", |
227 | 231 | "metadata": {},
|
228 | 232 | "outputs": [
|
229 | 233 | {
|
|
232 | 236 | "text": [
|
233 | 237 | "/home/jovyan/.local/lib/python3.8/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
|
234 | 238 | " and should_run_async(code)\n",
|
235 |
| - "100%|██████████| 262/262 [00:02<00:00, 97.92it/s]\n", |
| 239 | + "100%|██████████| 262/262 [00:02<00:00, 102.30it/s]\n", |
236 | 240 | "/home/jovyan/conda/envs/faceshift_env/lib/python3.8/site-packages/torch/nn/functional.py:3000: UserWarning: The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and uses scale_factor directly, instead of relying on the computed output size. If you wish to keep the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details. \n",
|
237 | 241 | " warnings.warn(\"The default behavior for interpolate/upsample with float scale_factor changed \"\n",
|
238 |
| - "262it [00:00, 5828.70it/s]\n", |
239 |
| - "100%|██████████| 5/5 [00:07<00:00, 1.43s/it]\n", |
240 |
| - "100%|██████████| 262/262 [00:00<00:00, 924228.47it/s]\n" |
| 242 | + "262it [00:00, 4874.78it/s]\n", |
| 243 | + "100%|██████████| 5/5 [00:06<00:00, 1.39s/it]\n", |
| 244 | + "100%|██████████| 262/262 [00:00<00:00, 542135.00it/s]\n" |
241 | 245 | ]
|
242 | 246 | }
|
243 | 247 | ],
|
|
253 | 257 | {
|
254 | 258 | "cell_type": "code",
|
255 | 259 | "execution_count": 8,
|
256 |
| - "id": "spoken-cinema", |
| 260 | + "id": "recovered-council", |
257 | 261 | "metadata": {},
|
258 | 262 | "outputs": [
|
259 | 263 | {
|
|
262 | 266 | "text": [
|
263 | 267 | "/home/jovyan/.local/lib/python3.8/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
|
264 | 268 | " and should_run_async(code)\n",
|
265 |
| - "14it [00:07, 1.93it/s]\n" |
| 269 | + "14it [00:07, 1.86it/s]\n" |
266 | 270 | ]
|
267 | 271 | }
|
268 | 272 | ],
|
|
274 | 278 | {
|
275 | 279 | "cell_type": "code",
|
276 | 280 | "execution_count": 9,
|
277 |
| - "id": "heavy-charm", |
| 281 | + "id": "grave-nancy", |
278 | 282 | "metadata": {},
|
279 | 283 | "outputs": [
|
280 | 284 | {
|
|
285 | 289 | " and should_run_async(code)\n",
|
286 | 290 | " 0%| | 0/262 [00:00<?, ?it/s]/home/jovyan/conda/envs/faceshift_env/lib/python3.8/site-packages/kornia/geometry/transform/imgwarp.py:184: UserWarning: The align_corners default value has been changed. By default now is set True in order to match cv2.warpAffine. In case you want to keep your previous behaviour set it to False. This warning will disappear in kornia > v0.6.\n",
|
287 | 291 | " warnings.warn(message)\n",
|
288 |
| - "/home/jovyan/FaceShifterMulti/sber-swap/utils/inference/video_processing.py:199: UserWarning: Mixed memory format inputs detected while calling the operator. The operator will output contiguous tensor even if some of the inputs are in channels_last format. (Triggered internally at /pytorch/aten/src/ATen/native/TensorIterator.cpp:918.)\n", |
| 292 | + "/home/jovyan/final_repo/sber-swap/utils/inference/video_processing.py:199: UserWarning: Mixed memory format inputs detected while calling the operator. The operator will output contiguous tensor even if some of the inputs are in channels_last format. (Triggered internally at /pytorch/aten/src/ATen/native/TensorIterator.cpp:918.)\n", |
289 | 293 | " final = (mask_t*swap_t + (1-mask_t)*frame).type(torch.uint8).squeeze().permute(1,2,0).cpu().detach().numpy()\n",
|
290 |
| - "100%|██████████| 262/262 [00:06<00:00, 40.30it/s]\n" |
| 294 | + "100%|██████████| 262/262 [00:05<00:00, 47.31it/s]\n" |
291 | 295 | ]
|
292 | 296 | }
|
293 | 297 | ],
|
|
304 | 308 | {
|
305 | 309 | "cell_type": "code",
|
306 | 310 | "execution_count": 10,
|
307 |
| - "id": "breeding-assistant", |
| 311 | + "id": "emerging-toolbox", |
308 | 312 | "metadata": {},
|
309 | 313 | "outputs": [
|
310 | 314 | {
|
|
323 | 327 | {
|
324 | 328 | "cell_type": "code",
|
325 | 329 | "execution_count": 11,
|
326 |
| - "id": "academic-theme", |
| 330 | + "id": "color-conditions", |
327 | 331 | "metadata": {},
|
328 | 332 | "outputs": [
|
329 | 333 | {
|
330 | 334 | "name": "stdout",
|
331 | 335 | "output_type": "stream",
|
332 | 336 | "text": [
|
333 |
| - "Full pipeline took 26.875646114349365\n", |
| 337 | + "Full pipeline took 26.246086597442627\n", |
334 | 338 | "Video saved with path examples/results/elon2dora.mp4\n"
|
335 | 339 | ]
|
336 | 340 | },
|
|
351 | 355 | {
|
352 | 356 | "cell_type": "code",
|
353 | 357 | "execution_count": null,
|
354 |
| - "id": "fresh-hazard", |
| 358 | + "id": "weekly-vitamin", |
355 | 359 | "metadata": {},
|
356 | 360 | "outputs": [],
|
357 | 361 | "source": []
|
358 | 362 | },
|
359 | 363 | {
|
360 | 364 | "cell_type": "code",
|
361 | 365 | "execution_count": null,
|
362 |
| - "id": "defensive-romantic", |
| 366 | + "id": "double-debate", |
363 | 367 | "metadata": {},
|
364 | 368 | "outputs": [],
|
365 | 369 | "source": []
|
366 | 370 | },
|
367 | 371 | {
|
368 | 372 | "cell_type": "code",
|
369 | 373 | "execution_count": null,
|
370 |
| - "id": "reflected-hepatitis", |
| 374 | + "id": "respected-sperm", |
371 | 375 | "metadata": {},
|
372 | 376 | "outputs": [],
|
373 | 377 | "source": []
|
374 | 378 | },
|
375 | 379 | {
|
376 | 380 | "cell_type": "code",
|
377 | 381 | "execution_count": null,
|
378 |
| - "id": "varying-tracker", |
| 382 | + "id": "legitimate-uganda", |
379 | 383 | "metadata": {},
|
380 | 384 | "outputs": [],
|
381 | 385 | "source": []
|
382 | 386 | },
|
383 | 387 | {
|
384 | 388 | "cell_type": "code",
|
385 | 389 | "execution_count": null,
|
386 |
| - "id": "stylish-batman", |
| 390 | + "id": "organic-macro", |
387 | 391 | "metadata": {},
|
388 | 392 | "outputs": [],
|
389 | 393 | "source": []
|
390 | 394 | }
|
391 | 395 | ],
|
392 | 396 | "metadata": {
|
393 | 397 | "kernelspec": {
|
394 |
| - "display_name": "fs", |
| 398 | + "display_name": "fsh", |
395 | 399 | "language": "python",
|
396 |
| - "name": "fs" |
| 400 | + "name": "fsh" |
397 | 401 | },
|
398 | 402 | "language_info": {
|
399 | 403 | "codemirror_mode": {
|
|
0 commit comments