Pytorch implementation of face attention network

Overview

Face Attention Network

Pytorch implementation of face attention network as described in Face Attention Network: An Effective Face Detector for the Occluded Faces. The baseline is RetinaNet followed by this repo.

img1

Requirements

  • Python3
  • Pytorch0.4
  • torchvision
  • tensorboardX

Installation

Install packages.

sudo apt-get install tk-dev python-tk
pip install cffi
pip install cython
pip install pandas
pip install tensorboardX

Build NMS.

cd Face_Attention_Network/lib
sh build.sh

Create folders.

cd Face_Attention_Network/
mkdir ckpt mAP_txt summary weight

Datasets

You should prepare three CSV or TXT files including train annotations file, valid annotations file and label encoding file.

Annotations format

Two examples are as follows:

$image_path/img_1.jpg x1 y1 x2 y2 label
$image_path/img_2.jpg . . . . .

Images with more than one bounding box should use one row per box. When an image does not contain any bounding box, set them '.'.

Label encoding file

A TXT file (classes.txt) is needed to map label to ID. Each line means one label name and its ID. One example is as follows:

face 0

Pretrained Model

We use resnet18, 34, 50, 101, 152 as the backbone. You should download them and put them to /weight.

Training

python train.py --csv_train <$path/train.txt> --csv_val <$path/val.txt> --csv_classes <$path/classes.txt> --depth <50> --pretrained resnet50-19c8e357.pth --model_name <model name to save>

Visualization Result

Detection result

img2

Attention map at different level (P3~P7)

img3

Reference

Comments
  • classification and regression branch

    classification and regression branch

    @rainofmine HI

    paper3.1节3段指出:For face detection K = 1 since we use sigmoid activation 换句话说,就是不考虑背景类.结合你的code,确实没有考虑背景类. 想问下,为什么用了sigmoid activation就可以不考虑背景类??

    paper3.1节3段指出:The regression subnet is identical to the classification subnet except that it terminates in 4A convolution filters with linear activation. 想问下,这个linear activation该如何实现?? 结合你的code,在conv之后(out = self.output(out)),并没有任何操作.

    非常感谢,麻烦了

    opened by foralliance 3
  • Undefined names: model_urls and ConvOffset2d

    Undefined names: model_urls and ConvOffset2d

    flake8 testing of https://github.com/rainofmine/Face_Attention_Network on Python 3.7.1

    $ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

    ./model_level_attention.py:352:50: F821 undefined name 'model_urls'
            model.load_state_dict(model_zoo.load_url(model_urls['resnet18'], model_dir='.'), strict=False)
                                                     ^
    ./utils.py:95:22: F821 undefined name 'ConvOffset2d'
            self.conv2 = ConvOffset2d(planes,
                         ^
    2     F821 undefined name 'model_urls'
    2
    
    opened by cclauss 2
  •  What is the attention technique applied to this paper?

    What is the attention technique applied to this paper?

    Hello, thank you for your interesting research.

    I've been studying to understand the attention technique featured in this paper, but I'm not sure how exactly it works.

    I studied RNN, LSTM, ATTENTION, Self-Attention (Transformer), etc.

    However, these are explained in terms of natural language processing.

    I saw that the attention technique was used on the vision side, but I didn't understand in detail yet. How exactly does attention work in this paper?

    If you let me know, it will be very helpful to me. Thank you.

    opened by yonghwan1994 0
  • Question about demo images

    Question about demo images

    So the repo and research paper is aimed at detecting faces, then why is it that the demo image in the repo's READme file has bounding boxes around the entire person, instead of just face

    opened by Ashwin-Ramesh2607 0
  • About   the attention supervised information.

    About the attention supervised information.

    You say that the attention supervision information is obtained by filling the ground-truth box. How to make the attention supervision information? In which process to do this work. Whether should i to filling the ground-truth box when i prepare the dataset?

    opened by mochaojie 1
  • what is the model.pt and image_retangles.jpg

    what is the model.pt and image_retangles.jpg

    i read the issues and check ehp's code ,in Detection part "python detector.py --model<$path/model.pt> --image <$path/image.jpg> --rect <$path/image_faces_rectangles.jpg> i wonder know what is the "image.jpg and image_faces_rectangles.jpg",can i found a image from the dataset?and model.pt is ?

    opened by Liuqiyuan670 3
  • images with more than a bounding box

    images with more than a bounding box

    if an image has more than a bounding box what is the correct formate is it: 12--Group/12_Group_Group_12_Group_Group_12_285.jpg 912 239 37 38 face 864 268 34 43 face

    or 12--Group/12_Group_Group_12_Group_Group_12_285.jpg 912 239 37 38 face 12--Group/12_Group_Group_12_Group_Group_12_285.jpg 864 268 34 43 face

    please help

    opened by sosha90 0
Owner
Hooks
Deep bug maker
Hooks
Implementation of Transformer in Transformer, pixel level attention paired with patch level attention for image classification, in Pytorch

Transformer in Transformer Implementation of Transformer in Transformer, pixel level attention paired with patch level attention for image c

Phil Wang 272 Dec 23, 2022
Official Pytorch Implementation of Relational Self-Attention: What's Missing in Attention for Video Understanding

Relational Self-Attention: What's Missing in Attention for Video Understanding This repository is the official implementation of "Relational Self-Atte

mandos 43 Dec 7, 2022
Implementation of Deformable Attention in Pytorch from the paper "Vision Transformer with Deformable Attention"

Deformable Attention Implementation of Deformable Attention from this paper in Pytorch, which appears to be an improvement to what was proposed in DET

Phil Wang 128 Dec 24, 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
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
[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

Multimedia Computing Group, Nanjing University 99 Dec 30, 2022
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

Prem Kumar 86 Aug 3, 2022
Swapping face using Face Mesh with TensorFlow Lite

Swapping face using Face Mesh with TensorFlow Lite

iwatake 17 Apr 26, 2022
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

Microsoft 608 Jan 2, 2023
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
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

Naiyuan Liu 232 Dec 29, 2022
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

switchnorm 1.7k Dec 26, 2022
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

Yao Feng 2.3k Dec 30, 2022
Face-Recognition-Attendence-System - This face recognition Attendence system using Python

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

Riya Gupta 4 May 10, 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
Video-face-extractor - Video face extractor with Python

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

null 2 Feb 3, 2022
Face and Pose detector that emits MQTT events when a face or human body is detected and not detected.

Face Detect MQTT Face or Pose detector that emits MQTT events when a face or human body is detected and not detected. I built this as an alternative t

Jacob Morris 38 Oct 21, 2022
Implementation of the 😇 Attention layer from the paper, Scaling Local Self-Attention For Parameter Efficient Visual Backbones

HaloNet - Pytorch Implementation of the Attention layer from the paper, Scaling Local Self-Attention For Parameter Efficient Visual Backbones. This re

Phil Wang 189 Nov 22, 2022