# PyTorch-JAANet
This repository is the PyTorch implementation of [JAA-Net](http://openaccess.thecvf.com/content_ECCV_2018/papers/Zhiwen_Shao_Deep_Adaptive_Attention_ECCV_2018_paper.pdf), as well as [its extended journal version](https://arxiv.org/pdf/2003.08834.pdf). "*v1.py" is for the ECCV version, and "*v2.py" is for the IJCV version. The trained models can be downloaded [here](https://sjtueducn-my.sharepoint.com/:f:/g/personal/shaozhiwen_sjtu_edu_cn/Eu3SDFcZYG9Ah5RdRYqfYxoBWDyWici_FdWJP8TnYFqaZw?e=ogNmZv). The original Caffe implementation can be found [here](https://github.com/ZhiwenShao/JAANet)
# Getting Started
## Installation
- This code was tested with PyTorch 1.1.0 and Python 3.5
- Clone this repo:
```
git clone https://github.com/ZhiwenShao/PyTorch-JAANet
cd PyTorch-JAANet
```
## Datasets
[BP4D](http://www.cs.binghamton.edu/~lijun/Research/3DFE/3DFE_Analysis.html) and [DISFA](http://www.engr.du.edu/mmahoor/DISFA.htm)
Put these datasets into the folder "dataset" following the paths shown in the list files of the folder "data/list". You can refer to the example images for BP4D and DISFA
## Preprocessing
- Put the landmark annotation files into the folder "dataset". Two example files "BP4D_combine_1_2_land.txt" and "DISFA_combine_1_2_66land.txt" are also provided
- For DISFA dataset, we need to select the annotations of 49 landmarks from original 66 landmarks:
```
cd dataset
python read_disfa_49land.py
```
- Conduct similarity transformation for face images:
```
cd dataset
python face_transform.py
```
- Compute the inter-ocular distance of each face image:
```
cd dataset
python write_biocular.py
```
- Compute the weight of the loss of each AU for the training set:
- The AU annoatation files should be in the folder "data/list"
```
cd dataset
python write_AU_weight.py
```
## Training
- Train on BP4D with the first two folds for training and the third fold for testing:
```
python train_JAAv1.py --run_name='JAAv1' --gpu_id=0 --train_batch_size=16 --eval_batch_size=28 --train_path_prefix='data/list/BP4D_combine_1_2' --test_path_prefix='data/list/BP4D_part3' --au_num=12
```
- Train on DISFA with the first two folds for training and the third fold for testing, using the the well-trained BP4D model for initialization:
```
python train_JAAv1_disfa.py --run_name='JAAv1_DISFA' --gpu_id=0 --train_batch_size=16 --eval_batch_size=32 --train_path_prefix='data/list/DISFA_combine_1_2' --test_path_prefix='data/list/DISFA_part3' --au_num=8 --pretrain_path='JAAv1_combine_1_3' --pretrain_epoch=5
```
## Testing
- Test the models saved in different epochs:
```
python test_JAAv1.py --run_name='JAAv1' --gpu_id=0 --start_epoch=1 --n_epochs=12 --eval_batch_size=28 --test_path_prefix='data/list/BP4D_part3' --au_num=12
```
- Visualize attention maps
```
python test_JAAv1.py --run_name='JAAv1' --gpu_id=0 --pred_AU=False --vis_attention=True --start_epoch=5 --n_epochs=5 --test_path_prefix='data/list/BP4D_part3' --au_num=12
```
## Supplement
- The PyTorch implementation for the ECCV version conducts two minor revisions to make the proposed method more general:
- The redundant cropping of attention maps is removed
- The assembling of local feature maps uses element-wise average instead of element-wise sum
- The differences in the extended journal version are detailed [here](https://arxiv.org/pdf/2003.08834.pdf)
## Citation
- If you use this code for your research, please cite our papers
```
@inproceedings{shao2018deep,
title={Deep Adaptive Attention for Joint Facial Action Unit Detection and Face Alignment},
author={Shao, Zhiwen and Liu, Zhilei and Cai, Jianfei and Ma, Lizhuang},
booktitle={European Conference on Computer Vision},
year={2018},
pages={725--740},
organization={Springer}
}
@article{shao2020jaa,
title={J{\^A}A-Net: Joint Facial Action Unit Detection and Face Alignment via Adaptive Attention},
author={Shao, Zhiwen and Liu, Zhilei and Cai, Jianfei and Ma, Lizhuang},
journal={International Journal of Computer Vision},
year={2020},
publisher={Springer}
}
```
王二空间
- 粉丝: 7569
- 资源: 2110
最新资源
- VCU整车控制器主控芯片MPC5744,原理图+源代码
- 基于非线性干扰观测器的直升机滑模反演控制,期刊simulink模型复现
- 51单片机串口通信程序源码,注释详细,包含接收和传输代码,以及文档说明
- FX3U和三菱伺服控制的框架标准程序,适合新手学习定位用 用 标签分层,说明了定位控制中的公共参数设定、回原点、JOG手动、绝对定位、相对定位、控制等部分,有伺服驱动器的针脚接线 ‘包括有: 1、
- 电动汽车有序充电参与电网负荷削峰填谷
- 热电联产系统智能经济调度:一种深度强化学习方法 关键词:热电联产,经济调度,深度强化学习,近端优化 一种热电组合(CHP)系统经济调度的深度强化学习(DRL)方法,该方法具有对不同操作场景的适应性,显
- 魔术轮胎,dugoff轮胎建模 软件使用:Matlab Simulink 适用场景:采用模块化建模方法,搭建非线性魔术轮胎PAC2002,dugoff模型 非线性轮胎模型输入: 轮胎侧偏角,轮胎滑
- 啊阿斯顿撒法公分的身高是是
- 基于时域信号 逆变器 阻抗模型 特征值识别 稳定性分析 关键词 系统识别、导纳模型、阻抗模型、基于逆变器的资源、稳定性分析 测试环境:MATLAB 由于越来越多的基于逆变器的资源(IBR)的集成,电
- 有源电力滤波器matlab仿真, 并联型apf仿真fft分析 谐波电流检测ipiq法 跟踪电流控制(传统滞环控制 空间电压矢量滞环控制) 总谐波畸变率降至3%以下
- 编程领域中正则表达式的全面介绍与典型应用场景解析
- 使用STM32DSP库制作的数字滤波器, 滤波器系数通过MATLAB生成 配合STM32串口输出,在Excel中绘图,上面只是演示了低通滤波器 源码,包括滤波器系数生成教程
- 基于VHDL的数字密码锁设计,使用FPGA作为控制器,包括相应的功能仿真和相关设计资料
- 深入解析 Vue3 框架:新特性、改进与应用案例的技术指南
- 胶钉机程序 用国产三菱3U和威纶触摸屏编写 此程序已经实际设备上批量应用,程序成熟可靠,借鉴价值高,程序有注释
- 在IEEE-14总线系统中执行连续功率流 测试环境:MATLAB 读取IEEE14和 IEEE30系统数据 连续潮流又称为延拓潮流,是电力系统电压稳定性分析的有力工具 PV曲线由于反映了系统随着负
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈