MogFace: Towards a Deeper Appreciation on Face Detection

Overview

MogFace: Towards a Deeper Appreciation on Face Detection

Introduction

  • In this repo, we propose a promising face detector, termed as MogFace.

  • Our MogFace consists of 3 novel modules, including Ali-AMS, SSE and HCAM.

  • Our MogFace achieves six champions on WIDER FACE.

Prepare Environment

conda create -n MogFace python=3.6
conda activate MogFace
pip install -r requirements.txt
cd utils/nms && python setup.py build_ext --inplace && cd ../..
cd utils/bbox && python setup.py build_ext --inplace && cd ../..

Data Preparation

  1. Download preatrain_weights into pretrain_weights
  2. Download the WIDERFACE dataset.
  3. Organize the dataset directory under Mogface/ as follows; We also provide the organized dataset.
  dataset/WIDERFACE/
    WIDER_train/
      images/
    WIDER_val/
      images/
    WIDER_test/
      images/
    wider_face_split/
      wider_face_train_bbx_gt.txt
      wider_face_val.mat
      wider_face_test.mat
    ground_truth/

Training

  1. Train Ali-AMS
  CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py -c configs/mogface/MogFace_Ali-AMS.yml
  1. Train SSE
  CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py -c configs/mogface/MogFace_SSE.yml
  1. Train HCAM
  CUDA_VISIBLE_DEVICES=0,1,2,3 python train.py -c configs/mogface/MogFace_HCAM.yml

Testing

  1. Single scale test on $CONFIG_FILE$
  CUDA_VISIBLE_DEVICES=0 python test_single.py -c $CONFIG_FILE$
  CUDA_VISIBLE_DEVICES=0 python test_single.py -c configs/mogface/MogFace_Ali-AMS.yml
  1. Multi scale test on $CONFIG_FILE$
  CUDA_VISIBLE_DEVICES=0 python test_multi.py -c $CONFIG_FILE$

MogFace Pretrained Models

Name Easy Medium Hard Link
MogFace_Ali-AMS (SS_test) 94.6 93.6 87.3 download
MogFace_SSE (SS_test) 95.6 94.1 - download
MogFace_HCAM (SS_test) 95.1 94.2 87.4 download
MogFace-E (MS_test) 97.7 96.9 92.0 download
MogFace (MS_test) 97.0 96.3 93.0 download
  • MS_Test: multi-scale testing
  • SS_Test: single-scale testing
  CUDA_VISIBLE_DEVICES=0 python test_multi.py -c configs/mogface/MogFace.yml -n 140 --test_hard 1
  CUDA_VISIBLE_DEVICES=1 python test_multi.py -c configs/mogface/MogFace_E.yml -n 140

The best MogFace model and some tricks will be released soon.

USAGE

  1. Download MogFace-E Pretrained Model from link
  2. mkdir -p snapshots/MogFace-E && mv model_140000.pth snapshots/MogFace-E/
  3. CUDA_VISIBLE_DEVICES=0 python test_multi.py -c configs/mogface/MogFace-E.yml -n 140
You might also like...
[TIP 2021] SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction
[TIP 2021] SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction

SADRNet Paper link: SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction Requirements python

Realtime Face Anti Spoofing with Face Detector based on Deep Learning using Tensorflow/Keras and OpenCV
Realtime Face Anti Spoofing with Face Detector based on Deep Learning using Tensorflow/Keras and OpenCV

Realtime Face Anti-Spoofing Detection 🤖 Realtime Face Anti Spoofing Detection with Face Detector to detect real and fake faces Please star this repo

Swapping face using Face Mesh with TensorFlow Lite
Swapping face using Face Mesh with TensorFlow Lite

Swapping face using Face Mesh with TensorFlow Lite

Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels.
Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels.

The Face Synthetics dataset Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels. It was introduced in ou

VGGFace2-HQ - A high resolution face dataset for face editing purpose
VGGFace2-HQ - A high resolution face dataset for face editing purpose

The first open source high resolution dataset for face swapping!!! A high resolution version of VGGFace2 for academic face editing purpose

A large-scale face dataset for face parsing, recognition, generation and editing.
A large-scale face dataset for face parsing, recognition, generation and editing.

CelebAMask-HQ [Paper] [Demo] CelebAMask-HQ is a large-scale face image dataset that has 30,000 high-resolution face images selected from the CelebA da

Python tools for 3D face: 3DMM, Mesh processing(transform, camera, light, render), 3D face representations.
Python tools for 3D face: 3DMM, Mesh processing(transform, camera, light, render), 3D face representations.

face3d: Python tools for processing 3D face Introduction This project implements some basic functions related to 3D faces. You can use this to process

Face-Recognition-Attendence-System - This face recognition Attendence system using Python

Face-Recognition-Attendence-System I have developed this face recognition Attend

Video-face-extractor - Video face extractor with Python

Python face extractor Setup Create the srcvideos and faces directories Put your

Comments
  • mask_fp_context_ft[tmp_shift] = 1,IndexError: index 5 is out of bounds for dimension 2 with size 5

    mask_fp_context_ft[tmp_shift] = 1,IndexError: index 5 is out of bounds for dimension 2 with size 5

    Thank you for sharing this project. I always encounter similar mistakes, can you help me to see the reason?

    【cpu environment,python 3.6.7,torch 1.10.2】 Load model from ./model_70000.pth Finish load model. img-id1-object-1.png width: 327, height: 314 C:/Users/**/Downloads/MogFace-master/aa.py:53: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. x = Variable(x, volatile=True) C:\my_dir*\venv\lib\site-packages\torch\nn\functional.py:3509: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.") C:\my_dir*\venv\lib\site-packages\torch\nn\functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. "See the documentation of nn.Upsample for details.".format(mode) C:\my_dir*\venv\lib\site-packages\torch\nn\functional.py:1806: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.") pyramid_feature_list: 6 Traceback (most recent call last): File "C:/Users//Downloads/MogFace-master/aa.py", line 237, in boxes = process_img(img, net, generate_anchors_fn, normalize_setting) File "C:/Users//Downloads/MogFace-master/aa.py", line 152, in process_img boxes = detect_face(net, img, shrink, generate_anchors_fn) # origin test File "C:/Users//Downloads/MogFace-master/aa.py", line 55, in detect_face out = net(x) File "C:\my_dir*\venv\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "C:\Users*\Downloads\MogFace-master\modelling\architectures\widerface_basenet.py", line 83, in forward conf, loc, mask_fp_context_fts = self.pred_net(pyramid_feature_list) File "C:\my_dir*\venv\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "C:\Users*\Downloads\MogFace-master\modelling\pred_modules\pred_net.py", line 267, in forward mask_fp_context_ft[tmp_shift] = 1 IndexError: index 5 is out of bounds for dimension 2 with size 5 Process finished with exit code 1

    【gpu environment,python 3.7.13,torch 1.10.0+cu111】 Load model from ./model_70000.pth Finish load model. face_wujian.jpg width: 500, height: 500 /root/code//MogFace-master/aa.py:54: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. x = Variable(x.cuda(), volatile=True) /usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:3509: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.") /usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. "See the documentation of nn.Upsample for details.".format(mode) /usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:1806: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.") Inference time : 865 The image with bbox is saved as ./tmp_img/0.13437671850930222.jpg face_age.png width: 1160, height: 304 Inference time : 655 The image with bbox is saved as ./tmp_img/0.6703785369022076.jpg img_00106.png width: 540, height: 640 Inference time : 487 The image with bbox is saved as ./tmp_img/0.9521100804886025.jpg single_face.jpeg width: 700, height: 720 /pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [0,0,0], thread: [6,0,0] Assertion index >= -sizes[i] && index < sizes[i] && "index out of bounds" failed. /pytorch/aten/src/ATen/native/cuda/IndexKernel.cu:93: operator(): block: [0,0,0], thread: [10,0,0] Assertion index >= -sizes[i] && index < sizes[i] && "index out of bounds" failed. Traceback (most recent call last): File "/root/code//MogFace-master/aa.py", line 234, in boxes = process_img(img, net, generate_anchors_fn, normalize_setting) File "/root/code//MogFace-master/aa.py", line 153, in process_img boxes = detect_face(net, img, shrink, generate_anchors_fn) # origin test File "/root/code//MogFace-master/aa.py", line 56, in detect_face out = net(x) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, **kwargs) File "/root/code//MogFace-master/modelling/architectures/widerface_basenet.py", line 75, in forward conf, loc, mask_fp_context_fts = self.pred_net(pyramid_feature_list) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, **kwargs) File "/root/code//MogFace-master/modelling/pred_modules/pred_net.py", line 266, in forward mask_fp_context_ft[tmp_shift] = 1 RuntimeError: CUDA error: device-side assert triggered CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1. Process finished with exit code 1

    opened by JayL323 0
Owner
A vision team from Alibaba
null
U2-Net: Going Deeper with Nested U-Structure for Salient Object Detection

The code for our newly accepted paper in Pattern Recognition 2020: "U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection."

Xuebin Qin 6.5k Jan 9, 2023
[Preprint] "Bag of Tricks for Training Deeper Graph Neural Networks A Comprehensive Benchmark Study" by Tianlong Chen*, Kaixiong Zhou*, Keyu Duan, Wenqing Zheng, Peihao Wang, Xia Hu, Zhangyang Wang

Bag of Tricks for Training Deeper Graph Neural Networks: A Comprehensive Benchmark Study Codes for [Preprint] Bag of Tricks for Training Deeper Graph

VITA 101 Dec 29, 2022
Deeper DCGAN with AE stabilization

AEGeAN Deeper DCGAN with AE stabilization Parallel training of generative adversarial network as an autoencoder with dedicated losses for each stage.

Tyler Kvochick 36 Feb 17, 2022
img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation

img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation Figure 1: We estimate the 6DoF rigid transformation of a 3D face (rendered in si

VĂ­tor Albiero 519 Dec 29, 2022
Code for HLA-Face: Joint High-Low Adaptation for Low Light Face Detection (CVPR21)

HLA-Face: Joint High-Low Adaptation for Low Light Face Detection The official PyTorch implementation for HLA-Face: Joint High-Low Adaptation for Low L

Wenjing Wang 77 Dec 8, 2022
Face Library is an open source package for accurate and real-time face detection and recognition

Face Library Face Library is an open source package for accurate and real-time face detection and recognition. The package is built over OpenCV and us

null 52 Nov 9, 2022
AI Face Mesh: This is a simple face mesh detection program based on Artificial intelligence.

AI Face Mesh: This is a simple face mesh detection program based on Artificial Intelligence which made with Python. It's able to detect 468 different

Md. Rakibul Islam 1 Jan 13, 2022
《Towards High Fidelity Face Relighting with Realistic Shadows》(CVPR 2021)

Towards High Fidelity Face-Relighting with Realistic Shadows Andrew Hou, Ze Zhang, Michel Sarkis, Ning Bi, Yiying Tong, Xiaoming Liu. In CVPR, 2021. T

null 114 Dec 10, 2022
End-to-end face detection, cropping, norm estimation, and landmark detection in a single onnx model

onnx-facial-lmk-detector End-to-end face detection, cropping, norm estimation, and landmark detection in a single onnx model, model.onnx. Demo You can

atksh 42 Dec 30, 2022
DVG-Face: Dual Variational Generation for Heterogeneous Face Recognition, TPAMI 2021

DVG-Face: Dual Variational Generation for HFR This repo is a PyTorch implementation of DVG-Face: Dual Variational Generation for Heterogeneous Face Re

null 52 Dec 30, 2022