Instant Real-Time Example-Based Style Transfer to Facial Videos

Overview

FaceBlit: Instant Real-Time Example-Based Style Transfer to Facial Videos

The official implementation of

FaceBlit: Instant Real-Time Example-Based Style Transfer to Facial Videos
A. Texler, O. Texler, M. Kučera, M. Chai, and D. Sýkora
🌐 Project Page, 📄 Paper, 📚 BibTeX

FaceBlit is a system for real-time example-based face video stylization that retains textural details of the style in a semantically meaningful manner, i.e., strokes used to depict specific features in the style are present at the appropriate locations in the target image. As compared to previous techniques, our system preserves the identity of the target subject and runs in real-time without the need for large datasets nor lengthy training phase. To achieve this, we modify the existing face stylization pipeline of Fišer et al. [2017] so that it can quickly generate a set of guiding channels that handle identity preservation of the target subject while are still compatible with a faster variant of patch-based synthesis algorithm of Sýkora et al. [2019]. Thanks to these improvements we demonstrate a first face stylization pipeline that can instantly transfer artistic style from a single portrait to the target video at interactive rates even on mobile devices.

Teaser

Introduction

⚠️ DISCLAIMER: This is a research project, not a production-ready application, it may contain bugs!

This implementation is designed for two platforms - Windows and Android.

  • All C++ sources are located in FaceBlit/app/src/main/cpp, except for main.cpp and main_extension.cpp which can be found in FaceBlit/VS
  • All Java sources are stored in FaceBlit/app/src/main/java/texler/faceblit
  • Style exemplars (.png) are located in FaceBlit/app/src/main/res/drawable
  • Files holding detected landmarks (.txt) and lookup tables (.bytes) for each style are located in FaceBlit/app/src/main/res/raw
  • The algorithm assumes the style image and input video/image have the same resolution

Build and Run

  • Clone the repository git clone https://github.com/AnetaTexler/FaceBlit.git
  • The repository contains all necessary LIB files and includes for both platforms, except for the OpenCV DLL files for Windows
  • The project uses Dlib 19.21 which is added as one source file (FaceBlit/app/src/main/cpp/source.cpp) and will be compiled with other sources; so you don't have to worry about that

Windows

  • The OpenCV 4.5.0 is required, you can download the pre-built version directly from here and add opencv_world450d.dll and opencv_world450.dll files from opencv-4.5.0-vc14_vc15/build/x64/vc15/bin into your PATH
  • Open the solution FaceBlit/VS/FaceBlit.sln in Visual Studio (tested with VS 2019)
  • Provide a facial video/image or use existing sample videos and images in FaceBlit/VS/TESTS.
    • The input video/image has to be in resolution 768x1024 pixels (width x height)
  • In main() function in FaceBlit/VS/main.cpp, you can change parameters:
    • targetPath - path to input images and videos (there are some sample inputs in FaceBlit/VS/TESTS)
    • targetName - name of a target PNG image or MP4 video with extension (e.g. "target2.mp4")
    • styleName - name of a style with extension from the FaceBlit/app/src/main/res/drawable path (e.g. "style_het.png")
    • stylizeBG - true/false (true - stylize the whole image/video, does not always deliver pleasing results; false - stylize only face)
    • NNF_patchsize - voting patch size (odd number, ideal is 3 or 5); 0 for no voting
  • Finally, run the code and see results in FaceBlit/VS/TESTS

Android

  • OpenCV binaries (.so) are already included in the repository (FaceBlit/app/src/main/jniLibs)
  • Open the FaceBlit project in Android Studio (tested with Android Studio 4.1.3 and gradle 6.5), install NDK 21.0.6 via File > Settings > Appearance & Behavior > System Settings > Android SDK > SDK Tools and build the project.
  • Install the application on your mobile and face to the camera (works with both front and back). Press the right bottom button to display styles (scroll right to show more) and choose one. Wait a few seconds until the face detector loads, and enjoy the style transfer!

License

The algorithm is not patented. The code is released under the public domain - feel free to use it for research or commercial purposes.

Citing

If you find FaceBlit useful for your research or work, please use the following BibTeX entry.

@Article{Texler21-I3D,
    author    = "Aneta Texler and Ond\v{r}ej Texler and Michal Ku\v{c}era and Menglei Chai and Daniel S\'{y}kora",
    title     = "FaceBlit: Instant Real-time Example-based Style Transfer to Facial Videos",
    journal   = "Proceedings of the ACM in Computer Graphics and Interactive Techniques",
    volume    = "4",
    number    = "1",
    year      = "2021",
}
Comments
  • Problems with building the codes

    Problems with building the codes

    Hi, the work you guys have on here looks amazing!

    I was trying to build it on my machine, but I've encountered this error:

    image

    How can I fix this?

    Thanks in advance!

    opened by bycloudai 5
  • How to generate custom landmarks and lookup tables for custom styles?

    How to generate custom landmarks and lookup tables for custom styles?

    Hi, Is it possible to use custom style images? I presume that we need to generate custom landmarks and lookup tables if we want custom images right?

    thank you!

    opened by bycloudai 4
  • How to reach 16FPS as your video demonstrated

    How to reach 16FPS as your video demonstrated

    I tried on several mobile phone include Samsung Galaxy S9 with Exynos 9810 and Huawei with Kirin 990. I'v never found the app reach even more than 1 FPS.

    I was wondering if there is anything I can do with the Android code to reach the 16 FPS? thanks

    opened by Chalet37 3
  • Android App crashed after tap on style

    Android App crashed after tap on style

    I put model into downloads but got these crashes

    First crash

    2021-04-28 15:33:33.189 24926-26079/texler.faceblit A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 26079 (pool-3-thread-1), pid 24926 (texler.faceblit)

    Second crash

    Process: texler.faceblit, PID: 27296 java.lang.OutOfMemoryError: Failed to allocate a 67108880 byte allocation with 25165824 free bytes and 57MB until OOM, target footprint 166366248, growth limit 201326592 at java.util.Arrays.copyOf(Arrays.java:3161) at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:191) at texler.faceblit.utils.ResourceHelper.getCubeFromResource(ResourceHelper.java:176) at texler.faceblit.fragments.StyleSelectorFragment.setStyleData(StyleSelectorFragment.java:73) at texler.faceblit.RecyclerViewAdapter$1.onClick(RecyclerViewAdapter.java:63) at android.view.View.performClick(View.java:8160) at android.view.View.performClickInternal(View.java:8137) at android.view.View.access$3700(View.java:888) at android.view.View$PerformClick.run(View.java:30250) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:246) at android.app.ActivityThread.main(ActivityThread.java:8443) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

    Device: Samsung A51

    opened by n00ner 2
  • Android app crash when I tap a style image

    Android app crash when I tap a style image

    Thank you for sharing your project.

    After successfully built with (Android Studio 4.1.3, Gradle 6.5, NDK 21.1.6, arm64-v8a), the app crashes throwing error logs below when I tap a style image. Tested with PIXEL 3 XL, Galaxy Note10 5G

    Abort message: 'terminating with uncaught exception of type dlib::serialization_error: Unable to open /storage/emulated/0/Download/models/shape_predictor_68_face_landmarks.dat for reading.'

    04-27 22:27:09.710 1008 1008 I EaselThermalMonit.txt

    adb shell crosshatch:/ $ cd /storage/emulated/0/Download/models /system/bin/sh: cd: /storage/emulated/0/Download/models: No such file or directory

    There was no model directory inside Download. I also check all permissions including storage are granted.

    Could anyone help me figure this out?

    opened by j52y 2
  • How to set the compiling configuration in VS2019 to increase speed?

    How to set the compiling configuration in VS2019 to increase speed?

    Hi @AnetaTexler, Thank you for sharing this brilliant project. I am facing a time-cost issue needing your help. I saw the paper said that the synthesis costs about 0.05 s. But when I compile the C++ project in VS2019, the synthesis time is much longer as below:

    • Landmarks detection time: 180 ms
    • Style transfer time: 111 ms.

    I have already changed the project in 'release' mode. In the code, NNF_patchsize=3; frame_size=768x1024. I guess there may be some configurations different from the paper. Please help.

    Thank you!

    opened by sd707589 1
  • Face Re-enactment

    Face Re-enactment

    Hey @AnetaTexler Thanks for sharing such awesome work. I can think of so many fun applications for this :)

    I was wondering if I can use the work to do the re-enactment of human videos? What if i select the same source image as style and this will help me achieve neural head re-enactment work?

    opened by amil-rp-work 1
  • Adding style takes much longer after the second update of the code

    Adding style takes much longer after the second update of the code

    Hi, sorry to trouble you again!

    I've just tested the newest codes (5 days ago) and adding one style takes significantly longer (5 mins vs 40 mins+) than the code 11 days ago. I noticed the change when I was trying to create a tutorial on how to run this with the latest code for my viewers.

    Is it because the increase in landmarks accuracy? Or is it something else affecting in the background? I also noticed a slightly longer runtime for running the main() module too. I'm guessing it might be related?

    Thank you in advance!

    opened by bycloudai 1
  • Would the author like to share an ios demo?

    Would the author like to share an ios demo?

    I like the demo very much, and run successfuly on my android phone. I want to run it on an ios phone, but do not know what to do, Would you like to share a demo runs on ios. The ios demo has the same function with android demo

    opened by yangjingbo 1
Owner
Aneta Texler
Aneta Texler
Stitch it in Time: GAN-Based Facial Editing of Real Videos

STIT - Stitch it in Time [Project Page] Stitch it in Time: GAN-Based Facial Edit

null 1.1k Jan 4, 2023
Official PyTorch implementation of Retrieve in Style: Unsupervised Facial Feature Transfer and Retrieval.

Retrieve in Style: Unsupervised Facial Feature Transfer and Retrieval PyTorch This is the PyTorch implementation of Retrieve in Style: Unsupervised Fa

null 60 Oct 12, 2022
Unofficial pytorch implementation of 'Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization'

pytorch-AdaIN This is an unofficial pytorch implementation of a paper, Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization [Hua

Naoto Inoue 873 Jan 6, 2023
Web service for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation based on OpenFace 2.0

OpenGaze: Web Service for OpenFace Facial Behaviour Analysis Toolkit Overview OpenFace is a fantastic tool intended for computer vision and machine le

Sayom Shakib 4 Nov 3, 2022
OpenFace – a state-of-the art tool intended for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation.

OpenFace 2.2.0: a facial behavior analysis toolkit Over the past few years, there has been an increased interest in automatic facial behavior analysis

Tadas Baltrusaitis 5.8k Dec 31, 2022
Automatically measure the facial Width-To-Height ratio and get facial analysis results provided by Microsoft Azure

fwhr-calc-website This project is to automatically measure the facial Width-To-Height ratio and get facial analysis results provided by Microsoft Azur

SoohyunPark 1 Feb 7, 2022
Real-Time-Student-Attendence-System - Real Time Student Attendence System

Real-Time-Student-Attendence-System The Student Attendance Management System Pro

Rounak Das 1 Feb 15, 2022
Facial detection, landmark tracking and expression transfer library for Windows, Linux and Mac

Welcome to the CSIRO Face Analysis SDK. Documentation for the SDK can be found in doc/documentation.html. All code in this SDK is provided according t

Luiz Carlos Vieira 7 Jul 16, 2020
Only a Matter of Style: Age Transformation Using a Style-Based Regression Model

Only a Matter of Style: Age Transformation Using a Style-Based Regression Model The task of age transformation illustrates the change of an individual

null 444 Dec 30, 2022
PyTorch implementation of MuseMorphose, a Transformer-based model for music style transfer.

MuseMorphose This repository contains the official implementation of the following paper: Shih-Lun Wu, Yi-Hsuan Yang MuseMorphose: Full-Song and Fine-

Yating Music, Taiwan AI Labs 142 Jan 8, 2023
StyleTransfer - Open source style transfer project, based on VGG19

StyleTransfer - Open source style transfer project, based on VGG19

Patrick martins de lima 9 Dec 13, 2021
Instant-Teaching: An End-to-End Semi-Supervised Object Detection Framework

This repo is the official implementation of "Instant-Teaching: An End-to-End Semi-Supervised Object Detection Framework". @inproceedings{zhou2021insta

null 34 Dec 31, 2022
Torch-ngp - A pytorch implementation of the hash encoder proposed in instant-ngp

HashGrid Encoder (WIP) A pytorch implementation of the HashGrid Encoder from ins

hawkey 1k Jan 1, 2023
HashNeRF-pytorch - Pure PyTorch Implementation of NVIDIA paper on Instant Training of Neural Graphics primitives

HashNeRF-pytorch Instant-NGP recently introduced a Multi-resolution Hash Encodin

Yash Sanjay Bhalgat 616 Jan 6, 2023
Instant-nerf-pytorch - NeRF trained SUPER FAST in pytorch

instant-nerf-pytorch This is WORK IN PROGRESS, please feel free to contribute vi

null 94 Nov 22, 2022
Fast Neural Style for Image Style Transform by Pytorch

FastNeuralStyle by Pytorch Fast Neural Style for Image Style Transform by Pytorch This is famous Fast Neural Style of Paper Perceptual Losses for Real

Bengxy 81 Sep 3, 2022
Neon-erc20-example - Example of creating SPL token and wrapping it with ERC20 interface in Neon EVM

Example of wrapping SPL token by ERC2-20 interface in Neon Requirements Install

null 7 Mar 28, 2022
Example-custom-ml-block-keras - Custom Keras ML block example for Edge Impulse

Custom Keras ML block example for Edge Impulse This repository is an example on

Edge Impulse 8 Nov 2, 2022
Python-kafka-reset-consumergroup-offset-example - Python Kafka reset consumergroup offset example

Python Kafka reset consumergroup offset example This is a simple example of how

Willi Carlsen 1 Feb 16, 2022