Coder Social home page Coder Social logo

conv-mlp's Introduction

Conv-MLP:A Convolution and MLP Mixed Model for Multi-Modal Face Anti-Spoofing

Introduction

This repo is a python reimplementation of Conv-MLP.

Conv-MLP is a simple yet effective architecture which incorporates local patch convolution with global MLP and breaks the inductive bias limitation of traditional full CNNs and can be expected to better exploit long-range dependencies.

Here we give the implementation of multi-modal face anti-spoofing on the WMCA dataset. We also provide Conv-MLP RGB-mode on the OULU-NPU dataset.

The overall pipeline of Conv-MLP.

Performance

We conduct experiments to evaluate the performance of Conv-MLP in terms of accuracy and computational efficiency on multi-modal and RGB benchmarks in comparison with existing state-of-the-art methods, including full CNN models and transformer-based ViT models.

Results on WMCA

  • ACER (Average Classification Error Rate) alt text

As shown, Conv-MLP ranks first in terms of the mean ACER on the seven unseen protocols (7.16 ± 11.10%), which implies Conv-MLP can extract discriminative representations and performs well on unseen scenarios.

  • Visualization

The visualized gradient map of typical samples from WMCA dataset.

Get Started

Package Requirement

  • Python 3.7
  • torch 1.6.0
  • opencv-python, numpy, shutil, torchvision, tqdm

Datasets

We train and test on the multi-modal datasets including WMCA and CeFA, and RGB datasets including OULU-NPU and SiW. According to the usage license agreement, we do not have the right to provide the datasets in public. If you need to use them, please refer to the link and apply to the relevant scientific institutions for research usage.

Training

  • Starting from scratch
python train.py
  • Pretraining
python train.py --pretrained_model='model_name.pth'

Note that for every training, you need to goto ./data/prepare_data.py and modify the corresponding data path.

You can also find variables, such as batch_size, patch_size, learning rate, and number of epoches in the train.py.

In addition, if the pre-trained model is used for fine-tuning, the initial learning rate should be set smaller, e.g. 1e-4.

Evaluation

python train.py --mode='infer_val' --pretrained_model='model_name.pth'

Note that for every testing, you also need to goto ./data/prepare_data.py and modify the corresponding data path.

Pretrained Models

We provide pre-trained models on two datasets separately.

You need to place the pre-trained model under the path specified in train.py, for example ./models_wmca/Conv-MLP_48/checkpoint/pretrained_model.pth. If no existing path, please build it by yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.