K-FACE Analysis Project on Pytorch

Related tags

Deep Learningmixface
Overview

Installation

Setup with Conda

# create a new environment
conda create --name insightKface python=3.7 # or over
conda activate insightKface

#install the appropriate cuda version of pytorch(https://pytorch.org/)
#example:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge

# install requirements
pip install -r requirements.txt

Data prepration

K-FACE Database

K-FACE AI-hub.

Detail configuration about K-FACE is provided in the paper below.

K-FACE: A Large-Scale KIST Face Database in Consideration with Unconstrained Environments

K-FACE sample images

title

Structure of the K-FACE database

title

Configuration of K-FACE

Configuration_of_KFACE

Detection & Alignment on K-FACE

"""
    ###################################################################

    K-Face : Korean Facial Image AI Dataset
    url    : http://www.aihub.or.kr/aidata/73

    Directory structure : High-ID-Accessories-Lux-Emotion
    ID example          : '19062421' ... '19101513' len 400
    Accessories example : 'S001', 'S002' .. 'S006'  len 6
    Lux example         : 'L1', 'L2' .. 'L30'       len 30
    Emotion example     : 'E01', 'E02', 'E03'       len 3
    
    ###################################################################
"""

# example
cd detection

python align_kfaces.py --ori_data_path '/data/FACE/KFACE/High' --detected_data_path 'kface_retina_align_112x112'

Training and test datasets on K-FACE

Train ID Accessories Lux Expression Pose #Image Variance
T1 A1 1000 E1 C4-10 2,590 Very Low
T2 A1-2 400-1000 E1 C4-10 46,620 Low
T3 A1-A4 200-1000 E1-2 C4-13 654,160 Middle
T4 A1-A6 40-1000 E1-3 C1-20 3,862,800 High
Test ID Accessories Lux Expression Pose #Pairs Variance
Q1 A1 1000 E1 C4-10 1,000 Very Low
Q2 A1-2 400-1000 E1 C4-10 100,000 Low
Q3 A1-4 200-1000 E1-2 C4-13 100,000 Middle
Q4 A1-6 40-1000 E1-3 C1-20 100,000 High

MS1M-RetinaFace (MS1M-R)

MS1M-RetinaFace download link:

  1. The Lightweight Face Recognition Challenge & Workshop.

  2. https://github.com/deepinsight/insightface/wiki/Dataset-Zoo

#Preprocess 'train.rec' and 'train.idx' to 'jpg'

# example
cd detection

python rec2image.py --include '/data/FACE/ms1m-retinaface-t1/' --output 'MS1M-RetinaFace'

Inference

After downloading the pretrained model, run test.py.

Pretrained Model

For all experiments, ResNet-34 was chosen as the baseline backbone.

The model was trained on KFACE

Head&Loss Q1 Q2 Q3 Q4
ArcFace (s=16, m=0.25) 98.30 94.77 87.87 85.41
SN-pair (s=64) 99.20 95.01 91.84 89.74
MixFace (e=1e-22, m=0.25) 100 96.37 92.36 89.80

Note:

  • For ArcFace, We tested (s,m)={(16,0.5), (32,0.25), (64,0.25), (32,0.5), (64,0.5)}, but the model was not trained properly So, we apply (s,m)=(16,0.25).
cd recognition

# example
python test.py --weights 'kface.mixface.1e-22m0.25.best.pt' --dataset 'kface' --data_cfg 'data/KFACE/kface.T4.yaml'

The model was trained on MS1M-R

Head&Loss Q2 Q3 Q4 LFW CFP-FP AgeDB-30
ArcFace (s=64, m=0.5) 98.71 86.60 82.03 99.80 98.41 98.80
SN-pair (s=64) 92.85 76.36 70.08 99.55 96.20 95.46
MixFace (e=1e-22, m=0.5) 97.36 82.89 76.95 99.68 97.74 97.25
cd recognition

# example
python test.py --weights 'face.mixface.1e-22m0.5.best.pt' --dataset 'face' --data_cfg 'data/face.all.yaml'

The model was trained on MS1M-R+T4

Head&Loss Q2 Q3 Q4 LFW CFP-FP AgeDB-30
ArcFace (s=8, m=0.25) 76.58 73.13 71.38 99.46 96.75 93.83
SN-pair (s=64) 98.37 94.98 93.33 99.45 94.90 93.45
MixFace (e=1e-22, m=0.5) 99.27 96.85 94.79 99.53 96.32 95.56

Note:

  • For ArcFace, we tested (s,m)={(8, 0.5), (16, 0.25), (16,0.5), (32,0.25), (64,0.25), (32,0.5), (64,0.5)}, but the model was not trained properly So, we apply (s,m)=(8,0.25).
cd recognition

# example
python test.py --weights 'merge.mixface.1e-22m0.5.best.pt' --dataset 'merge' --data_cfg 'data/merge.yaml'

Training

Multi-GPU DataParallel Mode

Example script for training on KFACE

cd recognition

# example 
python train.py --dataset 'kface' --head 'mixface' --data_cfg 'data/KFACE/kface.T4.yaml' --hyp 'data/face.hyp.yaml' --head_cfg 'models/head.kface.cfg.yaml' --name 'example' --device 0,1

Multi-GPU DistributedDataParallel Mode

Example script for training on KFACE

cd recognition

# example
python -m torch.distributed.launch --nproc_per_node 2 train.py --dataset 'kface' --head 'mixface' --data_cfg 'data/KFACE/kface.T4.yaml' --hyp 'data/face.hyp.yaml' --head_cfg 'models/head.kface.cfg.yaml' --name 'example' --device 0,1

Note:

  • For MS1M-R, change args --dataset face, --data_cfg data/face.all.yaml, and --head_cfg model/head.face.cfg.yaml.
  • For MS1M-R+T4, change args --dataset merge, --data_cfg data/merge.yaml, and --head_cfg model/head.merge.cfg.yaml.
  • The args --nodrop should be used if you train with the metric loss(e.g., SN-pair, N-pair, etc.) on MS1M-R or MS1M-R+T4.
  • The args --double should be used if you train with the metric loss(e.g., SN-pair, N-pair, etc.) or MixFace on MS1M-R or MS1M-R+T4.
  • DistributedDataParallel is only available to classification loss(e.g., arcface, cosface, etc.)

Reference code

Thanks for these source codes porviding me with knowledges to complete this repository.

  1. https://github.com/biubug6/Pytorch_Retinaface.
  2. https://github.com/deepinsight/insightface.
  3. https://github.com/ultralytics/yolov5
Owner
Jung Jun Uk
Jung Jun Uk
Joint deep network for feature line detection and description

SOLD² - Self-supervised Occlusion-aware Line Description and Detection This repository contains the implementation of the paper: SOLD² : Self-supervis

Computer Vision and Geometry Lab 427 Dec 27, 2022
TensorFlow 2 AI/ML library wrapper for openFrameworks

ofxTensorFlow2 This is an openFrameworks addon for the TensorFlow 2 ML (Machine Learning) library

Center for Art and Media Karlsruhe 96 Dec 31, 2022
wmctrl ported to Python Ctypes

work in progress wmctrl is a command that can be used to interact with an X Window manager that is compatible with the EWMH/NetWM specification. wmctr

Iyad Ahmed 22 Dec 31, 2022
Source code of article "Towards Toxic and Narcotic Medication Detection with Rotated Object Detector"

Towards Toxic and Narcotic Medication Detection with Rotated Object Detector Introduction This is the source code of article: Towards Toxic and Narcot

Woody. Wang 3 Oct 29, 2022
Official code of the paper "ReDet: A Rotation-equivariant Detector for Aerial Object Detection" (CVPR 2021)

ReDet: A Rotation-equivariant Detector for Aerial Object Detection ReDet: A Rotation-equivariant Detector for Aerial Object Detection (CVPR2021), Jiam

csuhan 334 Dec 23, 2022
Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or columns of a 2d feature map, as a standalone package for Pytorch

Triangle Multiplicative Module - Pytorch Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or c

Phil Wang 22 Oct 28, 2022
Official Implementation of Neural Splines

Neural Splines: Fitting 3D Surfaces with Inifinitely-Wide Neural Networks This repository contains the official implementation of the CVPR 2021 (Oral)

Francis Williams 56 Nov 29, 2022
Text Summarization - WCN — Weighted Contextual N-gram method for evaluation of Text Summarization

Text Summarization WCN — Weighted Contextual N-gram method for evaluation of Text Summarization In this project, I fine tune T5 model on Extreme Summa

Aditya Shah 1 Jan 03, 2022
Tensorflow port of a full NetVLAD network

netvlad_tf The main intention of this repo is deployment of a full NetVLAD network, which was originally implemented in Matlab, in Python. We provide

Robotics and Perception Group 225 Nov 08, 2022
Pixel Consensus Voting for Panoptic Segmentation (CVPR 2020)

Implementation for Pixel Consensus Voting (CVPR 2020). This codebase contains the essential ingredients of PCV, including various spatial discretizati

Haochen 23 Oct 25, 2022
Implementation of Convolutional LSTM in PyTorch.

ConvLSTM_pytorch This file contains the implementation of Convolutional LSTM in PyTorch made by me and DavideA. We started from this implementation an

Andrea Palazzi 1.3k Dec 29, 2022
Code and data form the paper BERT Got a Date: Introducing Transformers to Temporal Tagging

BERT Got a Date: Introducing Transformers to Temporal Tagging Satya Almasian*, Dennis Aumiller*, and Michael Gertz Heidelberg University Contact us vi

54 Dec 04, 2022
FaRL for Facial Representation Learning

FaRL for Facial Representation Learning This repo hosts official implementation of our paper General Facial Representation Learning in a Visual-Lingui

Microsoft 19 Jan 05, 2022
Trying to understand alias-free-gan.

alias-free-gan-explanation Trying to understand alias-free-gan in my own way. [Chinese Version 中文版本] CC-BY-4.0 License. Tzu-Heng Lin motivation of thi

Tzu-Heng Lin 12 Mar 17, 2022
Spatial Single-Cell Analysis Toolkit

Single-Cell Image Analysis Package Scimap is a scalable toolkit for analyzing spatial molecular data. The underlying framework is generalizable to spa

Laboratory of Systems Pharmacology @ Harvard 30 Nov 08, 2022
StarGAN2 for practice

StarGAN2 for practice This version of StarGAN2 (coined as 'Post-modern Style Transfer') is intended mostly for fellow artists, who rarely look at scie

vadim epstein 87 Sep 24, 2022
Code for "Adversarial Attack Generation Empowered by Min-Max Optimization", NeurIPS 2021

Min-Max Adversarial Attacks [Paper] [arXiv] [Video] [Slide] Adversarial Attack Generation Empowered by Min-Max Optimization Jingkang Wang, Tianyun Zha

Jingkang Wang 12 Nov 23, 2022
Repository For Programmers Seeking a platform to show their skills

Programming-Nerds Repository For Programmers Seeking Pull Requests In hacktoberfest ❓ What's Hacktoberfest 2021? Hacktoberfest is the easiest way to g

42 Oct 29, 2022
SMCA replication There are no extra compiled components in SMCA DETR and package dependencies are minimal

Usage There are no extra compiled components in SMCA DETR and package dependencies are minimal, so the code is very simple to use. We provide instruct

22 May 06, 2022
Kinetics-Data-Preprocessing

Kinetics-Data-Preprocessing Kinetics-400 and Kinetics-600 are common video recognition datasets used by popular video understanding projects like Slow

Kaihua Tang 7 Oct 27, 2022