Skip to content

Commit

Permalink
Merge pull request #31 from CZP-1/detection
Browse files Browse the repository at this point in the history
Detection
  • Loading branch information
SamitHuang authored Dec 8, 2022
2 parents 24b3336 + 9545d28 commit a9e68bd
Show file tree
Hide file tree
Showing 60 changed files with 1,500 additions and 2,140 deletions.
2 changes: 1 addition & 1 deletion .github/pylint.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ persistent=yes

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
load-plugins=no


[MESSAGES CONTROL]
Expand Down
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MindFace mainly has the following features.

### Dependency

- mindspore_gpu==1.8.0
- mindspore_gpu==1.8.1
- numpy==1.21.6
- opencv_python==4.6.0.66
- scipy==1.7.3
Expand Down Expand Up @@ -53,7 +53,7 @@ pip install mindface
To install MindFace from source, please run,
```shell
# Clone the mindface repository.
git clone https://github.com/mindlab-ai/mindface.git
git clone https://github.com/mindspore-lab/mindface.git
cd mindface

# Install
Expand All @@ -62,13 +62,11 @@ python setup.py install

## Tutorials
---
<!-- We provide [jupyter notebook tutorials](tutorials) for
We provide [tutorials](tutorials) for

- [Learn about configs](tutorials/learn_about_config.ipynb)
- [Inference with a pretrained model](tutorials/inference.ipynb)
- [Finetune a pretrained model on custom datasets](tutorials/finetune.ipynb)
- [Customize models](tutorials/customize_model.ipynb)
- [Optimizing performance for vision transformer](tutorials/transformer.ipynb) -->
- [Learn about detection configs](tutorials/detection/config.md)
- [Inference with a pretrained detection model](tutorials/detection/infer.md)
- [Finetune a pretrained detection model on WiderFace](tutorials/detection/finetune.ipynb)

### Projects
---
Expand All @@ -87,16 +85,13 @@ The mindspore implementation of ArcFace and has achieved great performance. We i

#### Detection
---
For Face detection, We choose resnet50 and mobilenet0.25 as the backbone, retinaface as the model architecture to achieve efficient performance of face detection. Detailed results are shown in the table below.
For Face detection, We choose resnet50 and mobilenet0.25 as the backbone, retinaface as the model architecture to achieve efficient performance of face detection. Detailed results are shown in the table below.

##### WiderFace Val Performance in single scale When using ResNet50 or mobileNet025 as backbone.
| Model | Easy | Medium | Hard |
##### WiderFace Val Performance in multiscale When using ResNet50 or mobileNet025 as backbone.
| backbone | Easy | Medium | Hard |
|:-|:-:|:-:|:-:|
| RetinaFace_ResNet50 | 94.42% | 93.37% | 89.25% |
| RetinaFace_ResNet50 (original image scale) | 95.34% | 93.91% | 84.01% |
| RetinaFace_MobileNet025 (same parameter with MXNet) | 88.62% | 86.96% | 79.93% |
| RetinaFace_MobileNet025 (original image scale) | 90.73% | 88.24% | 73.87% |

| mobileNet0.25 | 91.60% | 89.50% | 82.39% |
| ResNet50 | 95.81% | 94.89% | 90.10% |

## License

Expand Down Expand Up @@ -147,3 +142,4 @@ CMIC has won 24 Grand Challenge Champion Awards from premier conferences, includ
- Mohan Jing, ``jing_mohan@mail.ustc.edu.cn``
- Haoxiang Shi, ``shihaoxiang@mail.ustc.edu.cn``
- Keda Lu, ``wujiekd666[at]gmail.com``
- Pengwei Li ``lipw@mail.ustc.edu.cn``
2 changes: 1 addition & 1 deletion mindface/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@

"""init"""
40 changes: 24 additions & 16 deletions mindface/detection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,49 @@ This repository is the mindspore implementation of RetinaFace and has achieved g
Comming soon!


## WiderFace Val Performance in multiscale.
| backbone | Easy | Medium | Hard |
|:-|:-:|:-:|:-:|
| mobileNet0.25 | 91.60% | 89.50% | 82.39% |
| ResNet50 | 95.81% | 94.89% | 90.10% |

## WiderFace Val Performance in single scale When using ResNet50 as backbone.
| Style | Easy | Medium | Hard |
|:-|:-:|:-:|:-:|
| MindSpore (same parameter with MXNet) | 94.42% | 93.37% | 89.25% |
| MindSpore (original image scale) | 95.34% | 93.91% | 84.01% |
| MindSpore (same parameter with MXNet) | 94.46% | 93.64% | 89.42% |
| MindSpore (original image scale) | 95.07% | 93.61% | 84.84% |
| PyTorch (same parameter with MXNet) | 94.82 % | 93.84% | 89.60% |
| PyTorch (original image scale) | 95.48% | 94.04% | 84.43% |
| MXNet | 94.86% | 93.87% | 88.33% |
| MXNet(original image scale) | 94.97% | 93.89% | 82.27% |

## WiderFace Val Performance in single scale When using mobileNet0.25 as backbone.
## WiderFace Val Performance in single scale When using MobileNet0.25 as backbone.
| Style | Easy | Medium | Hard |
|:-|:-:|:-:|:-:|
| MindSpore (same parameter with MXNet) | 88.62% | 86.96% | 79.93% |
| MindSpore (original image scale) | 90.73% | 88.24% | 73.87% |
| MindSpore (same parameter with MXNet) | 88.51% | 86.86% | 80.88% |
| MindSpore (original image scale) | 90.77% | 88.20% | 74.76% |
| PyTorch (same parameter with MXNet) | 88.67% | 87.09% | 80.99% |
| PyTorch (original image scale) | 90.70% | 88.16% | 73.82% |
| MXNet | 88.72% | 86.97% | 79.19% |
| MXNet(original image scale) | 89.58% | 87.11% | 69.12% |



## Quick Start
1. Installation

1.1 Git clone this [repo](https://github.com/harryjun-ustc/MindFace)
1.1 Git clone this [repo](https://github.com/mindspore-lab/mindface.git) and install mindface.

```
git clone https://github.com/harryjun-ustc/MindFace.git
```shell
git clone https://github.com/mindspore-lab/mindface.git
cd mindface
python setup.py install
```

1.2 Install dependencies

```
cd MindFace/detection/RetinaFace
cd mindface/detection/
pip install -r requirements.txt
```

Expand All @@ -61,7 +70,7 @@ Comming soon!



2.2. Organise the dataset directory under MindFace/RetinaFace/ as follows:
2.2. Organise the dataset directory under mindface/detection/ as follows:
```
data/WiderFace/
train/
Expand All @@ -80,29 +89,28 @@ Comming soon!

You can Modify the parameters of the config file in ```./configs```.

We provide two versions of configs (MobileNet0.25 and ResNet50).
We provide two versions of configs ([RetinaFace_mobilenet025](./configs/RetinaFace_mobilenet025.yaml) and [RetinaFace_resnet50](./configs/RetinaFace_resnet50.yaml)).

4. Train

```
python tools/train.py --backbone ResNet50 or MobileNet025
python mindface/detection/train.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml
```
5. Eval
```
python tools/eval.py --backbone ResNet50 or MobileNet025 --checkpoint pretrained/weight.ckpt
python eval.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml --checkpoint pretrained/weight.ckpt
```
6. Predict
```
python tools/infer.py --backbone ResNet50 or MobileNet025 --checkpoint pretrained/weight.ckpt --image_path ./imgs/0000.jpg --conf 0.5
python infer.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml --checkpoint pretrained/weight.ckpt --image_path ./imgs/0000.jpg --conf 0.5
```
## RetinaFace Pretrained Models
You can download the pretrained model from RetinaFace-ResNet50 ([baidu cloud](https://pan.baidu.com/s/1AOUY-b21gcU7X0ghQ0CYlw?pwd=qccr) or [googledrive](https://drive.google.com/file/d/1MOw5n7V_LSxcbqw7g5FNtJmeZj4qnd3c/view?usp=sharing)) and RetinaFace-MobileNet025 ([baidu cloud](https://pan.baidu.com/s/1AOUY-b21gcU7X0ghQ0CYlw?pwd=qccr) or [googledrive](https://drive.google.com/file/d/1MOw5n7V_LSxcbqw7g5FNtJmeZj4qnd3c/view?usp=sharing)).
You can download our pretrained model of [RetinaFace-ResNet50](https://download.mindspore.cn/toolkits/mindface/retinaface/RetinaFace_ResNet50.ckpt) and [RetinaFace-MobileNet025](https://download.mindspore.cn/toolkits/mindface/retinaface/RetinaFace_MobileNet025.ckpt).
You can verify the results in the [table](#widerface-val-performance-in-single-scale-when-using-resnet50-as-backbone-net) with the downloaded pretrained model.
Expand Down
66 changes: 36 additions & 30 deletions mindface/detection/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,48 @@ RetinaFace是一种实用的单级SOTA人脸检测器,被[CVPR 2020](https://o
## 更新日志
敬请期待!

## 使用不同backbone进行多尺度测试在WiderFace Val数据集上的表现.

## 使用Resnet50作为backbone进行单尺度训练在WiderFace Val数据集上的表现.
| 版本 | 简单样本 | 中等样本 | 困难样本 |
| backbone | Easy | Medium | Hard |
|:-|:-:|:-:|:-:|
| MindSpore (与MXNet相同参数) | 94.42% | 93.37% | 89.25% |
| MindSpore (原始图像尺寸) | 95.34% | 93.91% | 84.01% |
| PyTorch (与MXNet相同参数) | 94.82 % | 93.84% | 89.60% |
| PyTorch (原始图像尺寸) | 95.48% | 94.04% | 84.43% |
| mobileNet0.25 | 91.60% | 89.50% | 82.39% |
| ResNet50 | 95.81% | 94.89% | 90.10% |

## 使用Resnet50作为backbone进行单尺度测试在WiderFace Val数据集上的表现.
| Style | Easy | Medium | Hard |
|:-|:-:|:-:|:-:|
| MindSpore (same parameter with MXNet) | 94.46% | 93.64% | 89.42% |
| MindSpore (original image scale) | 95.07% | 93.61% | 84.84% |
| PyTorch (same parameter with MXNet) | 94.82 % | 93.84% | 89.60% |
| PyTorch (original image scale) | 95.48% | 94.04% | 84.43% |
| MXNet | 94.86% | 93.87% | 88.33% |
| MXNet(原始图像尺寸) | 94.97% | 93.89% | 82.27% |
| MXNet(original image scale) | 94.97% | 93.89% | 82.27% |

## 使用Mobilenet0.25作为backbone进行单尺度训练在WiderFace Val数据集上的表现.
| 版本 | 简单样本 | 中等样本 | 困难样本 |
## 使用Mobilenet0.25作为backbone进行单尺度测试在WiderFace Val数据集上的表现.
| Style | Easy | Medium | Hard |
|:-|:-:|:-:|:-:|
| MindSpore (与MXNet相同参数) | 88.62% | 86.96% | 79.93% |
| MindSpore (原始图像尺寸) | 90.73% | 88.24% | 73.87% |
| PyTorch (与MXNet相同参数) | 88.67% | 87.09% | 80.99% |
| PyTorch (原始图像尺寸) | 90.70% | 88.16% | 73.82% |
| MindSpore (same parameter with MXNet) | 88.51% | 86.86% | 80.88% |
| MindSpore (original image scale) | 90.77% | 88.20% | 74.76% |
| PyTorch (same parameter with MXNet) | 88.67% | 87.09% | 80.99% |
| PyTorch (original image scale) | 90.70% | 88.16% | 73.82% |
| MXNet | 88.72% | 86.97% | 79.19% |
| MXNet(原始图像尺寸) | 89.58% | 87.11% | 69.12% |

| MXNet(original image scale) | 89.58% | 87.11% | 69.12% |

## 快速入门
1. 安装

1.1 从[此处](https://github.com/harryjun-ustc/MindFace)进行Git clone
1.1 从[此处](https://github.com/mindspore-lab/mindface.git)下载mindface仓库并安装mindface

```
git clone https://github.com/harryjun-ustc/MindFace.git
```shell
git clone https://github.com/mindspore-lab/mindface.git
cd mindface
python setup.py install
```

1.2 安装依赖包

```
cd MindFace/detection/RetinaFace
cd mindface/detection/
pip install -r requirements.txt
```

Expand All @@ -64,7 +71,7 @@ RetinaFace是一种实用的单级SOTA人脸检测器,被[CVPR 2020](https://o



2.2. 在 MindFace/RetinaFace/ 目录下存放数据集,结构树如下所示:
2.2. 在 mindface/detection/ 目录下存放数据集,结构树如下所示:
```
data/WiderFace/
train/
Expand All @@ -83,31 +90,30 @@ RetinaFace是一种实用的单级SOTA人脸检测器,被[CVPR 2020](https://o

请在配置文件 ```./configs```中修改参数.

我们提供了两种配置文件(MobileNet0.25和ResNet50).
4. 训练
我们提供了两种配置文件([RetinaFace_mobilenet025](./configs/RetinaFace_mobilenet025.yaml) and [RetinaFace_resnet50](./configs/RetinaFace_resnet50.yaml)).

4. Train

```
python tools/train.py --backbone ResNet50 or MobileNet025
python mindface/detection/train.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml
```
5. 评估
5. Eval
```
python tools/eval.py --backbone ResNet50 or MobileNet025 --checkpoint pretrained/weight.ckpt
python eval.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml --checkpoint pretrained/weight.ckpt
```
6. 预测
6. Predict
```
python tools/infer.py --backbone ResNet50 or MobileNet025 --checkpoint pretrained/weight.ckpt --image_path ./imgs/0000.jpg --conf 0.5
python infer.py --config mindface/detection/configs/RetinaFace_mobilenet025.yaml --checkpoint pretrained/weight.ckpt --image_path ./imgs/0000.jpg --conf 0.5
```
## RetinaFace预训练模型
从此处下载预训练模型
RetinaFace-ResNet50 :[百度云](https://pan.baidu.com/s/1AOUY-b21gcU7X0ghQ0CYlw?pwd=qccr) 或 [谷歌云盘](https://drive.google.com/file/d/1MOw5n7V_LSxcbqw7g5FNtJmeZj4qnd3c/view?usp=sharing)
RetinaFace-MobileNet025 :[百度云](https://pan.baidu.com/s/1AOUY-b21gcU7X0ghQ0CYlw?pwd=qccr) 或 [谷歌云盘](https://drive.google.com/file/d/1MOw5n7V_LSxcbqw7g5FNtJmeZj4qnd3c/view?usp=sharing)
[RetinaFace-ResNet50](https://download.mindspore.cn/toolkits/mindface/retinaface/RetinaFace_ResNet50.ckpt)
[RetinaFace-MobileNet025](https://download.mindspore.cn/toolkits/mindface/retinaface/RetinaFace_MobileNet025.ckpt)
你可以在此[表格](#widerface-val-performance-in-single-scale-when-using-resnet50-as-backbone-net)中核验预训练模型和结果.
Expand Down
1 change: 1 addition & 0 deletions mindface/detection/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""init"""
60 changes: 0 additions & 60 deletions mindface/detection/configs/RetinaFace_mobilenet.py

This file was deleted.

Loading

0 comments on commit a9e68bd

Please sign in to comment.